I'm trying to make an HTML page from LaTEX document that recently achieve it, I used the following mathjax, script configuration, after the head tag:
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true
},
"HTML-CSS": { fonts: ["TeX"] }
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS": {
styles: {".MathJax": {color: "#FF0000 ! important"}}
}
});
MathJax.Hub.Queue(
["resetEquationNumbers",MathJax.InputJax.TeX],
["PreProcess",MathJax.Hub],
["Reprocess",MathJax.Hub]
);
</script>
When I try to write the following equation:
\[
\det A=|A|=\left\{
\begin{array}{ll}
-\textrm{fixation d'une \textcolor{red}{ligne:}} i=\color{red}{p} \Rightarrow |A|=(-1)^{\color{red}{p}+j}\Delta_{\color{red}{p}j}\\
-\textrm{fixation d'une colonne: } j=\color{red}{p} \Rightarrow |A|=(-1)^{\color{red}{p}+i}\Delta_{i\color{red}{p}}
\end{array}
\right.
\]
The command textcolor{red}
doesn't work. What can I do it with MathJax to configure it in order to get a colorful text in equation?
This is the result of my compilation:
As per the documentation, MathJax does does not focus on textmode and only allows the following within its text-mode macros (\text{}
etc): $
for re-entering math mode, \ref
and \eqref
.
So there is no way to get anything like \textcolor
inside \text
to work.
However, you can wrap \color
around \text
to color the text and thus you could define a custom macro \textwithcolor{red}{some text mode}
, e.g., by using $\require{color}\newcommand{\textwithColor}[2]{\color{#1}{\text{#2}}} \textwithColor{red}{halleo}$
.
You would still need to drop out of text mode to use it.
FWIW, there is an open issue for MathJax v3 to reconsider macros within text mode.