# Removing indent after an equation which was wrapped in a command

I have found that if one wraps a command around an equation, for example

Text here!
\textcolor{red}{%
$$% E = mc^2$$%
}%
Text here too!


then the text following this equation will have an additional indentation. How can this indentation be removed?

• Not on my machine. And you could always do $$\textcolor{red}{ E = mc^2 }$$Text.... – marmot Jun 5 '18 at 20:36
• @marmot I need to wrap the equations in a command. The example given is just an example. – rhombidodecahedron Jun 6 '18 at 8:14

How can this indentation be removed?

Answer: Don't place the equation environment in a \textcolor{red}{...} "wrapper". Instead, write

$$\color{red} E = mc^2$$


Note that the scope of the statement \color{red} ends at .

• I need to wrap the equations in a command. I am submitting corrections to a referee and all the corrections should be marked in red, which is to be achieved by wrapping the all corrections in a function. I have created a function \newcommand{\lr}[1]{\ifreferee\textcolor{red}{#1}\else#1\fi} and a corresponding boolean referee that I can toggle. Now I wrap everything in \lr{} when I want corrections. The {} around the #1 is the source of the problems. Can your answer be please updated to account for this? – rhombidodecahedron Jun 6 '18 at 8:13
• @rhombidodecahedron - please provide more information about how \ifreferee is defined. – Mico Jun 6 '18 at 13:57

I see no indent. Anyway, that's not the best way to color equations.

\documentclass{article}
\usepackage{amsmath,xcolor}
\usepackage{showframe}

\newenvironment{colordisplay}[1]
{\leavevmode\color{#1}\ignorespaces}
{\ignorespacesafterend}

\begin{document}

Text here too! Text here too! Text here too! Text here too!
Text here too! Text here too! Text here too! Text here too!
$$E = mc^2$$
Text here too! Text here too! Text here too! Text here too!
Text here too! Text here too! Text here too! Text here too!
\begin{align}
E&=mc^2 \\
F&=nd^2
\end{align}
Text here too! Text here too! Text here too! Text here too!
Text here too! Text here too! Text here too! Text here too!
\begin{colordisplay}{red}
$$E = mc^2$$
\end{colordisplay}
Text here too! Text here too! Text here too! Text here too!
Text here too! Text here too! Text here too! Text here too!
\begin{colordisplay}{red}
\begin{align}
E&=mc^2 \\
F&=nd^2
\end{align}
\end{colordisplay}
Text here too! Text here too! Text here too! Text here too!
Text here too! Text here too! Text here too! Text here too!

\end{document}


The showframe package is used just to see the text block margins.