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}


\leavevmodebefore changing the color. https://tex.stackexchange.com/a/589156/114496If anyone can elaborate, I'd still appreciate it.
– Zach Gaslowitz Mar 27 '21 at 04:34\textcolor{red}{text!}which will take care of the\leavevmodefor you. – Don Hosek Mar 27 '21 at 06:11