Skip to content

How to style all links created by \eqref command

Davide P. Cervone edited this page May 26, 2013 · 2 revisions

I am trying to color the links formed by \eqref command black.

I have managed to do this by using a CSS like this:

<style type="text/css">
.MathJax a {
    color: black;
}
</style>

Complete code example given below as well as at: http://jsfiddle.net/Z4HSr/

<!DOCTYPE html>
<html>
<head>
<title>eqref PDF like style</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  jax: ["input/TeX","output/HTML-CSS"],
  extensions: ["tex2jax.js"],
  TeX: {equationNumbers: {
    autoNumber: "AMS"
  }}
});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/2.0-beta/MathJax.js">
</script>
<style type="text/css">
.MathJax a {
    color: black;
}
</style>
</head>
<body>
<p>
\begin{equation}
\label{foo}
\binom{n}{k} = \frac{n!}{k! (n - k)!}
\end{equation}
</p><p>
From \eqref{foo}, we get \(\binom{n}{k} = \binom{n}{n - k}\).
<a href="http://en.wikipedia.org">Wikipedia</a>
</p>
</body>
</html>

I want to know whether this is the recommended way to style the links created by \eqref command or if there is another better way to do it.


Yes, that is a reasonable way to do it. You can add the style into your MathJax configuration if you want:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  jax: ["input/TeX","output/HTML-CSS"],
  extensions: ["tex2jax.js"],
  TeX: {equationNumbers: {
    autoNumber: "AMS"
  }},
  "HTML-CSS": {
    styles: {
      ".MathJax a": { color: "black" }
    }
  }
});
</script>

That way all the MathJax information is in one place.

Clone this wiki locally