我正在使用两个迷你页面。如果我使用颜色,顶行不会对齐。这是为什么?这是 MWE:
\documentclass{article}
\usepackage{color}
\begin{document}
\begin{minipage}[t]{0.45\textwidth}
{Without colors, the second column aligns nicely with the top row of the first.
}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.45\textwidth}
{
Nice alignment.
}
\end{minipage}
\vspace*{1cm}
\begin{minipage}[t]{0.45\textwidth}
{With colors, however, the second column does not align with the top row of the first.
}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.45\textwidth}
{
{\color{green}Problem...}
}
\end{minipage}
\end{document}
答案1
这是因为颜色什么东西在垂直模式下添加颜色有点困难。插入什么东西在任何情况下都不透明:
\documentclass{article}
\begin{document}
\begin{minipage}[t]{0.45\textwidth}
{Without colors, the second column aligns nicely with the top row of the first.}%
\end{minipage}%
\hfill
\begin{minipage}[t]{0.45\textwidth}
{\special{}Nice alignment.}%
\end{minipage}
\end{document}
您可以在水平模式下添加以\leavevmode
更改\color
颜色:
\documentclass{article}
\usepackage{color}
\begin{document}
\begin{minipage}[t]{0.45\textwidth}
{Without colors, the second column aligns nicely with the top row of the first.}%
\end{minipage}%
\hfill
\begin{minipage}[t]{0.45\textwidth}
{Nice alignment.}%
\end{minipage}
\vspace*{1cm}
\begin{minipage}[t]{0.45\textwidth}
{With colors, however, the second column does not align with the top row of the first.}%
\end{minipage}%
\hfill
\begin{minipage}[t]{0.45\textwidth}
{{\leavevmode\color{green}Problem...}}%
\end{minipage}
\end{document}