[Tex/LaTex] Change color in both text and equations

colorcomments

Is it possible to make a command that changes the color of both text and math, including in equations, for everything between brackets.

So for example something that does either

Either:

\toRed{
 text
\begin{equation}
1+1=2
\end{equation}
}

or

{\toRed text
\begin{equation}
1+1=2
\end{equation}
}

such that both the equation and the text are shown red.

P.S. If it screws up formatting it is okay with me as long as it is readable as this would be used only to put comments which won't be in any final product.


Update:

I had tried

\textcolor{red}{text
\begin{equation}
1+1=2
\end{equation}
more text

some more text
}

which gives an error. The problem was that the paragraph ended before the textcolor was closed. I see that \color as suggested in the answer does allow closing in a different paragraph. Since I want this to be allowed and prefer a command that opens and closes over including color within brackets I chose to go with:

\newcommand{\myname}[1]{ {\color{red} #1 }}

Best Answer

Like David Carlisle wrote in the comments, it is possible by simply using the \color command inside of a block:

Some text ...

{
  \color{red}
  Red text ...
  \begin{equation}
    1+1=2
  \end{equation}
}

Some more text ...

The result looks like:

enter image description here

Related Question