0

Changing the font color at the beginning of a minipage seems to cause an extra \parskip of vertical space. This doesn't happen if I instead make the text (for example) italic, nor if anything precedes the color change, as seen below. Can anyone explain why this is happening?

Here's a demonstration:

\documentclass[margin=5mm]{standalone}

\usepackage{xcolor}

\begin{document}

\fbox{\begin{minipage}{.5in}% \setlength{\parskip}{1cm}% \itshape text!% \end{minipage}}% \fbox{\begin{minipage}{.5in}% \setlength{\parskip}{1cm}% \color{red}text!% \end{minipage}}% \fbox{\begin{minipage}{.5in}% \setlength{\parskip}{1cm}% t\color{red}ext!% \end{minipage}}% \fbox{\begin{minipage}{.5in}% \setlength{\parskip}{1cm}% \vskip -\parskip% \color{red}text!% \end{minipage}}% \fbox{\begin{minipage}{.5in}% \setlength{\parskip}{1cm}% \hspace{0pt}% \color{red}text!% \end{minipage}}

\end{document}

Demonstration

  • 1
    Upon further inspection, it seems like this answer is relevant, and that a less hack-y solution to my problem is to leave vertical mode with \leavevmode before changing the color. https://tex.stackexchange.com/a/589156/114496

    If anyone can elaborate, I'd still appreciate it.

    – Zach Gaslowitz Mar 27 '21 at 04:34
  • You might want to consider writing, e.g., \textcolor{red}{text!} which will take care of the \leavevmode for you. – Don Hosek Mar 27 '21 at 06:11

1 Answers1

-1

You seem to have missed one command.

\vskip -\parskip %

See the below MWE:

\documentclass[margin=5mm]{standalone}
\usepackage{xcolor}
\begin{document}
\fbox{\begin{minipage}{.5in}%
    \setlength{\parskip}{1cm}%
    \itshape text!%
 \end{minipage}}%
\fbox{\begin{minipage}{.5in}%
    \setlength{\parskip}{1cm}%
    \vskip -\parskip%
    \color{red} text!%
\end{minipage}}%
\fbox{\begin{minipage}{.5in}%
    \setlength{\parskip}{1cm}%
    \vskip -\parskip%
    \color{red}text!%
\end{minipage}}%
\fbox{\begin{minipage}{.5in}%
    \setlength{\parskip}{1cm}%
    \vskip -\parskip%
    \color{red}text!%
\end{minipage}}%
\fbox{\begin{minipage}{.5in}%
    \setlength{\parskip}{1cm}%
    \hspace{0pt}%
    \color{red}text!%
\end{minipage}}
\end{document}

I added the \vskip -\parskip% at the 13th and 18th line. Hope this is helpful. enter image description here