使用编译时,a\color
之前的命令会添加虚假的垂直空间(请参阅 MWE)。文档 ( ) 提到了间距问题。类似的问题可能也适用于环境。\begin{flushleft}
pdflatex
texdoc color
verbatim
是否有可靠的解决方案或解决方法可以安全地用于此问题LaTeX 代码生成器? 或者应该不惜一切代价避免在“环境之间”切换颜色 — — 比如说,通过使用包fancyvrb
?
\documentclass{article}
\usepackage{color}
\pagestyle{empty}
\begin{document}
The spacing between this
\begin{flushleft}
and the following paragraph is good.
\end{flushleft}%
\color{red}%
\begin{flushleft} But here comes trouble. Why is the red block two parskips away?
\end{flushleft}
\color{blue}%
Changing from flushleft to regular doesn't add space even when color is changed.
\begin{flushleft}
\color{green}%
Neither does changing color inside flushleft.
\end{flushleft}
\end{document}
答案1
是的,如果可能的话你应该生成
\begin{flushleft}
\leavevmode\color{red} But here comes trouble. Why is the red block two parskips away?
\end{flushleft}
因此,颜色 whatsit 是在第一行内而不是在段落之前找到的,抱歉,就是这样。