1

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

Text here!
\textcolor{red}{%
    \begin{equation}% 
        E = mc^2 
    \end{equation}%
}% 
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 \begin{equation} \textcolor{red}{ E = mc^2 } \end{equation}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
3

How can this indentation be removed?

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

\begin{equation}
\color{red}
    E = mc^2 
\end{equation}

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

  • 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
1

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!
\begin{equation}
E = mc^2 
\end{equation}
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}
\begin{equation}
E = mc^2 
\end{equation}
\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.

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.