Where does this space come from?

Using colored text inside a minipage results in less vertical space being appended after the text compared to normal text. Strangely, this only occurs when the minipage is top-aligned. In the other cases, the space is consistent.

Also, in both cases there is more space compared to text that isn't inside a minipage.

\documentclass[a4paper]{article}
\usepackage{xcolor}

\renewcommand{\maketitle}[1]{%
\noindent
\begin{minipage}[t]{\textwidth}%
#1
\end{minipage}
}

\begin{document}
\hrule\relax
\maketitle{\color{blue} Bla.}
\hrule\relax

\vskip\bigskipamount

\hrule\relax
\maketitle{Bla.}
\hrule\relax

\vskip\bigskipamount

\hrule\relax
\noindent {\color{blue} Bla.}
\hrule\relax

\vskip\bigskipamount

\hrule\relax
\noindent Bla.
\hrule\relax
\end{document}


Result:

• Add a % after \end{minipage} in your \maketitle definition. – Steven B. Segletes Mar 16 '15 at 12:13
• You get the space because of the spurious space after \end{minipage} in your definition. You get different spaces as \color doesn't switch to hmode and so your minipages have different baselines (add a dot before the \begin{minipage} to see it. You can avoid this by using \noindent before #1. – Ulrike Fischer Mar 16 '15 at 12:18

It's a case of the missing %, in this case after the \end{minipage} in the \maketitle definition.

In general, when there is a situation of unwanted space being introduced, the first place to look is always the missing %. See What is the use of percent signs (%) at the end of lines?.

I should note that a number of environments automatically remedy this issue by employing \ignorespaces at the end of their definition. So, in your case, the following definition would also work (note the absence of the %):

\renewcommand{\maketitle}[1]{%
\noindent
\begin{minipage}[t]{\textwidth}%
#1
\end{minipage}
\ignorespaces
}


Here is the MWE which instead adds a %.

\documentclass[a4paper]{article}
\usepackage{xcolor}

\renewcommand{\maketitle}[1]{%
\noindent
\begin{minipage}[t]{\textwidth}%
#1
\end{minipage}%
}

\begin{document}
\hrule\relax
\maketitle{\color{blue} Bla.}
\hrule\relax

\vskip\bigskipamount

\hrule\relax
\maketitle{Bla.}
\hrule\relax

\vskip\bigskipamount

\hrule\relax
\noindent {\color{blue} Bla.}
\hrule\relax

\vskip\bigskipamount

\hrule\relax
\noindent Bla.
\hrule\relax
\end{document}


The accepted answer doesn't include the detailed explanation why the vertical space is here and why it is different in the colored and uncolored version and why the removing of horizontal space (using %) influences the visual vertical space. I try to explain this.

So, the \maketitle macro above starts the horizontal mode (see \noindent) and first "letter" of this mode is the \vtop (the minipage in LaTeX terminology). Then two following spaces are in OP's code. First one after \vtop (in macro, it was corrected by Steven using %) and second one after right brace from the souce line where \maketitle macro is used. After such two spaces the \hrule primitive is read. This primitive invokes \par, because it is read in horizontal mode. So we have:

\vtop{Bla.}\space\space\par


The \par primitive does one \unskip, so we have

\vtop{Bla.}\space


and this material is assembled to the paragraph. The first "letter" \vtop has the width equal to \hsize, so this "letter" fills the whole first line. The space is the break point and the second empty line is created (the Underfull hbox is reported in log file). But if only one space exists after \vtop in horizontal mode, then this space is removed by \par and the whole paragraph has only one line with \vtop as a "letter".

Summary: the paragraph has two lines if there are two spaces at its end. If only one (or none) space is here then only one line paragraph is created.

The second question: why colored version generates different vertical space than uncolored. The uncolored version generates

\vtop{Bla}


and the baseline of this \vtop is equal to the baseline of the text Bla. But colored version generates

\vtop{\special{color setting}Bla}


and the baseline of \vtop goes through the \special. The text Bla is below the baseline and it consists the depth of the \vtop "letter". The second empty line from the two-line paragraph is closer to the text Bla, when this text is below the baseline. Schema:

Uncolored version:

Bla
------------------ baseline of the first line of paragraph

------------------ baseline of the second line of paragraph
---------------------------- hrule

Colored version:

----special------- baseline of the first line of paragraph
Bla
------------------ baseline of the second line of paragraph
---------------------------- hrule