0

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 }}
  • Just an extra option, that you might find useful: marginnote - it is great for non-permanent comments in the compiled document. sharelatex.com/learn/Margin_notes – hpekristiansen Sep 17 '18 at 17:00
  • 2
    what did you try? the standard color command should do that {\color{red} text \begin{equation}.... – David Carlisle Sep 17 '18 at 17:16
  • Wow sorry for asking this. That was really stupid. I did try something and it didn't work but now I can't even find anymore how I can not make it work. All the intuitive methods work. Even using textcolor which I thought might have been my mistake. I must have made a stupid different mistake. (I was tired) – Kvothe Sep 18 '18 at 8:45
3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.