3

I have been wrecking my brain to figure out why some elements are too high above the horizontal line/rule and some are arguably well placed.

I found out it is because of the \color-command.

Why does that happen?

How can I have the parts without the \color-command behave the same way as it were there?

Screenshot of MWE

enter image description here

MWE

\documentclass[
11pt,
a4paper,
]
{scrartcl}

\usepackage{ lmodern, multicol, }

\usepackage[svgnames]{xcolor}

\usepackage[T1]{fontenc} \usepackage[utf8]{inputenc}

\listfiles

\begin{document} \begin{center}\huge Title stuff \end{center}

\begin{multicols*}{2} \section{Word}

\begin{center} \sffamily \fbox{ \begin{minipage}[t]{0.9\columnwidth} \centering\begin{minipage}[t]{0.95\columnwidth}\raggedright% \color{DarkBlue}\textbf{Stuff:} aaaaaaaa [asdf: 1111] \end{minipage}\par\addvspace{0.4ex}% \color{black}\rule{0.9\columnwidth}{0.1pt}\par\addvspace{0.4ex}% \begin{minipage}[t]{0.95\columnwidth}\small Words.

Sentence words and aaaa asdf lorem. Ipsum. Words words more. \end{minipage} \end{minipage}} \end{center}

\begin{center} \sffamily \fbox{ \begin{minipage}[t]{0.9\columnwidth} \centering\begin{minipage}[t]{0.95\columnwidth}\raggedright% \textbf{Stuff:} aaaaaaaa [asdf: 1111] \end{minipage}\par\addvspace{0.4ex}% \color{black}\rule{0.9\columnwidth}{0.1pt}\par\addvspace{0.4ex}% \begin{minipage}[t]{0.95\columnwidth}\small Words.

Sentence words and aaaa asdf lorem. Ipsum. Words words more. \end{minipage} \end{minipage}} \end{center}

\end{multicols*}

\end{document}

henry
  • 6,594

1 Answers1

2

Unlike a font change, \color adds a node into the document and it is hard in all cases to avoid that node affecting spacing. (There is a footnote on page 6 of grfguide which can be summarised as "it's not my fault").

It is usually easier to get understandable behaviour if the colour whatsit is inserted in horizontal rather than vertical mode. \textcolor uses \leavevmode at the start (like all latex box commands) to ensure this. Uising \textcolor in your example you get the same spacing in each case.

\documentclass[
11pt,
a4paper,
]
{scrartcl}

\usepackage{ lmodern, multicol, }

\usepackage[svgnames]{xcolor}

\usepackage[T1]{fontenc} \usepackage[utf8]{inputenc}

\listfiles

\begin{document} \begin{center}\huge Title stuff \end{center}

\begin{multicols*}{2} \section{Word}

\begin{center} \sffamily \fbox{%%%%% \begin{minipage}[t]{0.9\columnwidth} \centering\begin{minipage}[t]{0.95\columnwidth}\raggedright \textcolor{DarkBlue}{\textbf{Stuff:} aaaaaaaa [asdf: 1111]}% \end{minipage}\par\addvspace{0.4ex}% \textcolor{black}{\rule{0.9\columnwidth}{0.1pt}}\par\addvspace{0.4ex}% \begin{minipage}[t]{0.95\columnwidth}\small Words.

Sentence words and aaaa asdf lorem. Ipsum. Words words more. \end{minipage} \end{minipage}} \end{center}

\begin{center} \sffamily \fbox{%%%% \begin{minipage}[t]{0.9\columnwidth} \centering\begin{minipage}[t]{0.95\columnwidth}\raggedright% \textbf{Stuff:} aaaaaaaa [asdf: 1111] \end{minipage}\par\addvspace{0.4ex}% \textcolor{black}{\rule{0.9\columnwidth}{0.1pt}}\par\addvspace{0.4ex}% \begin{minipage}[t]{0.95\columnwidth}\small Words.

Sentence words and aaaa asdf lorem. Ipsum. Words words more. \end{minipage} \end{minipage}} \end{center}

\end{multicols*}

\end{document}

David Carlisle
  • 757,742
  • Thank you, David. Would you have a hint for my second question, i.e. which command I would have to use to yield the decrease in vertical spacing anyway? Note: If you prefer a new question, a note would suffice and I will make one for this. – henry Mar 26 '21 at 23:07
  • 1
    @henry above the rule? You are adding space there, just add less eg change .4ex to \addvspace{-1ex}% ? – David Carlisle Mar 26 '21 at 23:12
  • Well it's a manual solution based on incremental checks... but it works. Thanks. :) – henry Mar 26 '21 at 23:24