# Unpredictable Vertical Spaces

I'm writing up a résumé, and I am very particular about making sure that each section is separated by the exact-right-looking amount of spacing. My sections are divided with an \hrule (although in my real document I use the titlesec package to define their format). The rule makes it easy to notice when one section's spacing is different from another's.

The following example shows several of the elements that I need in my document. I have placed the rules very close to the text, to make the difference even more obvious. Depending on whether a section contains text or a list or columns, the subsequent section gets spaced an irregular amount below it. Edit: I've used \myrule instead of \hrule and followed other suggestions already given by @Ulrike.

\documentclass[10pt]{article}

\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{enumitem}
\usepackage{multicol}

\newcommand{\sampletext}{Here is some sample text\strut}

\newcommand{\myrule}{\par\vspace{-1\baselineskip}\noindent\strut\rule{\textwidth}{0.4pt}}

\newenvironment{compactlist}%
{\begin{itemize}[topsep=0pt,itemsep=0pt,parsep=0pt,labelindent=0em,partopsep=0pt,leftmargin=*]}
{\end{itemize}}

\begin{document}

\section{Plain}
\sampletext
\myrule

\section{Itemized}
\begin{compactlist}
\item \sampletext
\item \sampletext
\end{compactlist}
\myrule

\section{Itemized With Text}
\noindent\sampletext
\begin{compactlist}
\item \sampletext
\item \sampletext
\end{compactlist}
\myrule

\section{Parbox Itemized}
\hbox{
\parbox[t]{7in}{
\begin{compactlist}
\item \sampletext
\item \sampletext
\end{compactlist}
}
}
\myrule

\section{Parbox Itemized With Text}
\parbox[t]{6.5in}{
\sampletext
\begin{compactlist}
\item \sampletext
\item \sampletext
\end{compactlist}
}
\myrule

\section{Multicols}
\setlength{\multicolsep}{0pt}
\begin{multicols}{3}
\begin{compactlist}
\item \sampletext
\item \sampletext
\item \sampletext
\item \sampletext
\item \sampletext
\item \sampletext
\end{compactlist}
\end{multicols}
\myrule

\end{document}


Is there any way to enforce consistent vertical spacing?

• They are not really unpredictable. However they depend on many factors, mainly on the implementation of \section, itemize and multicols that do various things with spacing. – egreg Feb 13 '12 at 0:00
• In my attempts to reduce the space beneath the multi-column block, I've tried reading other stackexchange articles, using the \multicolsep command, diving into the multicol source to see what spacing is explicitly added, redefining commands like \addvspace so I can log other stray space sources, setting lengths like \parskip and \parsep, and finally just adding an arbitrary \vspace hack. I've come to the conclusion that LaTeX is not the best tool for precision typesetting. Hopefully someone can take up this challenge and show me how to gain control of the vertical spacing. – Chad Parry Feb 13 '12 at 2:49
• Yowza—that extra space is really pronounced in section 4 there. Are these things not using collapsable vertical space? Is it the \parbox that confuses it? – Todd Lehman Feb 13 '12 at 3:25
• I wouldn't use the primitive \hrule but a \myrule defined e.g. like this: \newcommand\myrule{\par\noindent\strut\rule{\textwidth}{0.4pt}} – Ulrike Fischer Feb 13 '12 at 10:24
• @Ulrike, that technique just increases the amount of space below each section, but it doesn't make the spacing any more consistent. You can see it if you use the command \newcommand\myrule{\par\vspace{-1\baselineskip}\noindent\strut\rule{\textwidth}{0.4pt}}. – Chad Parry Feb 13 '12 at 14:48

I wouldn't use the primitive \hrule but a \myrule defined e.g. like this: \newcommand\myrule{\par\noindent\strut\rule{\textwidth}{0.4pt}}.
The spacing is then more consistent that with \hrule. You can further improve it by using partopsep=0pt in your list definition. It could also be sensible to add a \strut to the sample text.
The 1pt below the \parbox is the line skip. The parbox is to the eyes of TeX like a character with a very large descender. So TeX inserts \lineskip (default 1pt) to avoid that it touches the next line. You can get rid of it with \lineskip=0pt (unless your \parbox contains some unusual objects with large descender in the last line). You shouldn't remove the \strut.
• The \lineskip did the trick for fixing the parbox. Thanks again. – Chad Parry Feb 14 '12 at 16:23