5

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 00: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 02: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 03:25
  • 1
    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
  • @Chad: The spacing is certainly more consistent that with your \hrule. You can further improve it by using partopsep=0pt in your list definition. It could also be sensible to add a \strut to you sample text. – Ulrike Fischer Feb 13 '12 at 15:05
  • @Ulrike, the partopsep option does fix those problems. (Why a top space length fixes the bottom spacing, I have no idea). And the addition of \par fixed section 6. Taken together, that makes a big difference. I'll see if these suggestions still fix things in a real-world document, and report back. Thanks so much! – Chad Parry Feb 13 '12 at 16:32
  • My document is looking very nice. @UlrikeFischer, if you want to write your comments in an answer, I can accept it. I am still curious about the parboxes in sections 4 and 5 though. The rule hangs 1pt too low compared to the other sections, (or it hovers 0.5pt too high if the \strut is removed from the sample text). Is there an explanation or a workaround for this last inconsistency? – Chad Parry Feb 14 '12 at 07:09
  • @ChadParry I think you have to look a bit closer at the document. Some rules are too near to the preceding text and this causes some descenders running into the rule. It gives a rushed feel to the CV. If this is an exercise in designing your own CV style, then I think you should spend a bit more time on it. Otherwise, you can grab an existing CV package, such as moderncv or others. Even if you don't want to use the other packages, then looking at them may be worth your while because it may give you inspiration for your own style. –  Feb 14 '12 at 07:57
  • Thanks, @MarcvanDongen. My real CV has much more breathing room. For this question, I reduced the spacing by exactly \baselineskip so that minute imperfections would be easier to spot and then correct. Now that the vertical spaces are fixed, I can add back in a consistent \vspace amount before each rule. – Chad Parry Feb 14 '12 at 14:38
  • @ChadParry It still doesn't look that great. (Perhaps this isn't your real CV.) BTW, if you really want consistent spacing, I suggest you read the grid manual and the paper by Bazargan and Radhakrishnan. –  Feb 14 '12 at 15:07
  • I appreciate it, @MarcvanDongen. Most of the ugliness you see is due to me reducing the spacing problem to a MWE. My actual résumé may not be perfect, but at least it will not make your eyes bleed like this MWE. :) (At least for now, you can see Chad Parry Resume or pdf). The grid article looks interesting, and it will help me with a separate 2-column document with lots of accents and inconsistent line heights. – Chad Parry Feb 14 '12 at 16:45

1 Answers1

4

As requested here my comments as answer:

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.

Ulrike Fischer
  • 327,261