1

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:

img

Can someone show me a fix for that?

J. Doe
  • 243

1 Answers1

1

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

MadyYuvi
  • 13,693
  • Hi! I am using Auto-LaTex add-on for Google Docs. That formula does not render right with it. Do you have any pointer? – J. Doe Mar 05 '20 at 10:26
  • @J.Doe Sorry, I don't know enough about Auto-LaTeX add-on for Google Docs... – MadyYuvi Mar 05 '20 at 10:47