# Suboptimal LaTeX #2: spacing

Written on February 24, 2014

In the first post of the series I gave some high level suggestions on writing a paper with LaTeX. Instead, from now on I will focus on specific typographical areas. The first I want to explore is spacing, which often goes unnoticed (because, well, you cannot see spaces) but is nonetheless one of the most important aspects in ensuring that a paper flows correctly.

All LaTeX fragments I used to produce the figures are collected in this writeLaTeX page

### Vertical spacing between paragraphs

In LaTeX, leaving a blank line is the way of ending a paragraph, which means starting a new line and applying the necessary indent. But not all paragraph breaks are equal: if a paragraph also ends a logic part of the section, leave more space by ending it with two backslashes (to go to a new line) and a blank line (to start a new paragraph). I think I never had the need to go to a new line without creating a new paragraph, writing \\ without the blank line right after.

The figure above showcases the correct and wrong patterns: the first two breaks are proper ways of ending a paragraph, whereas the last one is wrong: it is visually equivalent to ending a paragraph and using \noindent, another instruction you should avoid.

At typesetting time, you may need to tweak the vertical spacing between paragraphs, even though it is usually avoidable. If you cannot avoid it, do not use \vfill, \vspace, or multiple \\, but something like \\[2mm]; if you need to add a lot of space, use a multiple of \baselineskip as the argument, for example \\[3\baselineskip].

### Vertical space before an equation

A similar error occurs when you leave a blank line before a mathematical environment: long story short, do not do it. You can see in the figure the difference between the two cases.

The problem is that if you do so, you are starting a new paragraph with the equation. This is never what you want, especially if before you have a colon! Nonetheless, if you use the default style you will not see any difference. To produce the figure above, I had to increase \parskip (the additional vertical space between paragraphs) from the default, zero, to a positive value.

If you are thinking “then if I use the default style, I can ignore this suggestion”, remember that when you write the content you should not care about the style of the paper, since you should make that choice after the content is finalized.

### Vertical spacing sneaking in

Some environments have the not obvious side effect of inserting vertical spacing. The main example here is center. The alternative is \centering, which unlike the environment does not add any vertical spacing. Another alternative is \centerline, which can be used only for very small pieces of text or for figures, because it does not wrap over new lines. See the figure for the differences.

The same problem occurs with the environments flushright and flushleft: to avoid additional vertical spacing, you should use \raggedleft and \raggedright, respectively.

### Horizontal spacing in align

Horizontal spacing is more difficult to get wrong, but there is a common mistake when using the align in mathematical mode. It happens when you put the alignment ampersand after the equality sign instead than before, as in the figure.

Why anybody would want to put the ampersand after the equality sign? Because if the line breaks, they want the second part to be aligned after the equality sign too. But there are better ways:

• one is to use &\phantom\{ {}={} } at the begin of the second line: without the empty groups, LaTeX would think that the equal sign has nothing around, and it would collapse the horizontal spacing;
• another is to use ={}& on all other lines, again to force the binary relation spacing around the equality sign.

Next week, in the third part, we will see how to choose the perfect mathematical environments. Stay tuned!