I want to color the number 2 in my formula in red using the following:
\textrm{var}(X) = \frac{(b−a)(b−a+\color{red}{2})}{12}
However, what I got is:
Can someone show me a fix for that?
I want to color the number 2 in my formula in red using the following:
\textrm{var}(X) = \frac{(b−a)(b−a+\color{red}{2})}{12}
However, what I got is:
Can someone show me a fix for that?
From your MWE understood that you need color only for the text 2, but now the parenthesis also comes in color, if my assumption correct, try the following:
\documentclass{book}
\usepackage{xcolor}
\begin{document}
\[
\textrm{var}(X) = \frac{(b-a)(b-a+{\color{red}{2}})}{12}
\]
\end{document}
Just introduce an extra grouping will solve the issue
Auto-LaTeX add-on for Google Docs...
– MadyYuvi
Mar 05 '20 at 10:47
\textcolorinstead of\color(\coloris a declaration). Please add a minimal working example to your question. – frougon Mar 05 '20 at 11:10