删除命令中包含的方程式后的缩进

删除命令中包含的方程式后的缩进

我发现如果将命令包装在方程式中,例如

Text here!
\textcolor{red}{%
    \begin{equation}% 
        E = mc^2 
    \end{equation}%
}% 
Text here too!

那么这个等式后面的文本将有一个额外的缩进。如何删除这个缩进?

答案1

如何才能去除这个凹痕呢?

答案:不要将equation环境放在“包装器”中\textcolor{red}{...}。相反,写

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

请注意,该语句的范围\color{red}结束于\end{equation}

答案2

我没看到缩进。无论如何,这不是给方程式上色的最佳方法。

\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}

showframe包仅用于查看文本块边距。

在此处输入图片描述

相关内容