3.5 Paragraphing

Getting the line spacing right is usually one of the defining features of a great LaTex document. The line spacing is tied to the underlying text font size and the baseline skip (vertical separation between the baselines of two lines). The default text font size option is 10pt, and the vertical separation (spacing or skip) between the base lines of two successive lines of type) is 12pt (multiplication factor of 1.2)

The linespacing can be modified in several ways.

3.51 \setspace{}
The least complicated—in my personal opinion--is to invoke \usepackage{setspace} in the preamble, followed by options \singlespacing, \onehalfspacing, and \doublespacing, as appropriate. This sets the overall spacing for the document. The setspace package scales the baseline spacing appropriately in relation to font size. Spacing set to 1.5 (one-and-a-half pacing) will scale baseline to 18pt for a 12pt font); for a double-spacing specification, the spacing is twice the font size in pt (to 24pt for a 12pt font size).

The code snippet below illustrates the use of setspace with \onehalfspacing specified.

1. \usepackage{setspace}
2. \onehalfspacing % options:\singlespacing and \doublespacing
3. \begin{document}
4. Text comes here.
5. \end{document}


1. \documentclass[12pt]{article}
2. \usepackage{setspace, lipsum}
3. \pagestyle{empty}
4. \usepackage[margin=1in]{geometry}
5. \begin{document}
6. \section*{Single spacing}
7. \singlespacing
8. \lipsum[2]\\
9. \section*{One-and-a-half spacing}
10. \onehalfspacing
11. \lipsum[3]\\
12. \section*{Double spacing}
13. \doublespacing
14. \lipsum[4]\\
15. \end{document}

Figure 3.51 setspace options



3.52 \linespread{}
The default spacing between two consecutive baselines is 12pt for a 10pt font; for a 11pt font, the baseline skip is 22 pt, and for a 12 pt font, it is 24 pt. Formally: linespread = baselineskip * baselinestretch.

Therefore, to get one-and-one-half spacing for a 12pt font text, call the command

\linespread{1.25}.

Why 1.25? because 1.25 * 1.2=1.5.

Double spacing can be called by \linespread (1.666}. Figure 3.52 below summarises:



Figure 3.52 \linespread factors



3.53 \setstretch
\setstretch, within the setspace package comes in handy for custom spacing. First import setspace, and then use \setstretch {baselinestretch} in the preamble. The default spacing with this style option is single spacing. \setstretch{1}, \setstretch{1.5} and \setstretch{2} outputs single, one-and-one-half, and double spacing.

Stefan Kottwitz, author of LaTex Beginners Guide, points out that \setstretch applies to a paragraph environment and not beyond. To switch between two environments, e.g., \setstretch {1.5} and \setstretch {1}, you will have to break the environment (paragraph) either by inserting a blank line or a paragraph marker (\par).

3.54 Paragraph indentation
The margins of a paragraph can be modified, making it visually distinct from the text above or below. It is called by loading the package \usepackage{parskip} in the preamble.

LaTex’s default behaviour is to insert an indent of 5 em in the first line of each paragraph. That is the amount of white space equivalent to five spaces, as in a typewriter strokes or five ‘m’ letters. However, when the first line follows a \chapter or \section heading, the indentation is suppressed. Typographical pundits argue that text following a section heading is obviously a new paragraph and therefore does not require emphasis with an indent. Tom Kelly weighs in:

`”The role of the indentation is to guide the eye an make it easier to see where the paragraphs break, without taking as much space as leaving an entire line between them. This is not necessary with the first line of a section since it is obvious where it begins.’’

Strawberryfieldsforever writes “Indentation starts out at a non-zero value, set to zero when a section heading is inserted, and will be reset to the non-zero value again when a paragraph is ended.’’

Indentation can be removed throughout the document with a global command in the preamble, before \begin{document} \setlength{\parindent}{0}. Similarly, \setlength{\parindent}{value} in the preamble sets the indent for the whole document.

Indentation in a paragraph following an indented paragraph can be removed by adding a \noindent before the paragraph.

The default behaviour of no indent in the first line after a section/subsection can be modified by calling \usepackage{indentfirst}package in the preamble.

The code snippet and output below illustrate use of parskip to manipulate indentation.

1. \documentclass[12pt]{article}
2. \usepackage[margin=1in]{geometry}
3. \usepackage{listings}
4. \usepackage[indent]{parskip}
5. \pagestyle{empty}
6. \begin{document}
7. \textbf{This is the default output. The first line of each para is indented 1 5 em, which is approx. five spaces on the left.}\\
8. In the early universe, the gas between stars and galaxies was opaque – energetic starlight could not penetrate it. But 1 billion years after the big bang, the gas had become completely transparent. Why?\\
9. New data from NASA’s James Webb Space Telescope has pinpointed the reason: The galaxies’ stars emitted enough light to heat and ionize the gas around them, clearing our collective view over hundreds of millions of years.
10. \subsection*{Default output when text follows a section or sub-section heading.} \textbf{Please note the first line is not indented}. The results, from a research team led by Simon Lilly of ETH Zürich in Switzerland, are the newest insights about a time period known as the Era of Reionization, when the universe underwent dramatic changes.\\
11. After the big bang, gas in the universe was incredibly hot and dense. Over hundreds of millions of years, the gas cooled. Then, the universe hit “repeat.” The gas again became hot and ionized – likely due to the formation of early stars in galaxies, and over millions of years, became transparent.
12. \subsection*{Remove indentation }
13. To suppress indentation throughout document, use \lstinline + \noindent + in the preamble; \lstinline + \setlength{\parindent}{0pt} + removes indentation in subsequent paras. To restore indentation, reset with \lstinline + \setlength{\parindent}{15em} +.
14. \setlength{\parindent}{0em}
15. Researchers have long sought definitive evidence to explain these transformations. The new results effectively pull back the curtain at the end of this reionization period. \\
16. \subsection*{Indentation modified to 0.5 in }
17. To modify indentation in the whole document, use \lstinline + \usepackage[indent=1cm]{parskip} +\\
18. \lstinline + \setlength{\parindent}{0.5in}+ modifies the indentation in specific paras; restore with \lstinline + \setlength{\parindent}{15em}+
19.
20. \setlength{\parindent}{0.5in}
21.
22. ``Not only does Webb clearly show that these transparent regions are found around galaxies, we’ve also measured how large they are,'' explained Daichi Kashino of Nagoya University in Japan, the lead author of the team’s first paper. ``With Webb’s data, we are seeing galaxies reionize the gas around them.''\\
23. These regions of transparent gas are gigantic compared to the galaxies – imagine a hot air balloon with a pea suspended inside. Webb’s data shows that these relatively tiny galaxies drove reionization, clearing massive regions of space around them.
24. Over the next hundred million years, these transparent ``bubbles'' continued to grow larger and larger, eventually merging and causing the entire universe to become transparent.
25. \end{document}

Figure 3.54 \parskip for text indentation



An alternative approach to modifying indentation locally is to call \begin{indentation}, after declaring \usepackage{parskip} in the preamble.

\begin{indentation}{0.5in}{0pt},for instance, will indent the target paragraph 0.5 inches to the left and none to the right. The generalized form is \begin{indentation}{left margin}{right margin}. \begin{indentation}{}{} is closed with a \end{indentation}.

3.55 Paragraph vertical spacing
The vertical spacing (white space) between the last line of a paragraph and the first line of the following paragraph is set by \setlength{parskip}{factor}. This is largely a matter of personal choice; there are no hard and fast rules about the parskip factor.

The illustration 3.55 is produced by a bare bones code like so:

1. \documentclass[12pt]{article}
2. \usepackage[margin=1in]{geometry}
3. \usepackage{listings, parskip}
4. \setlength{\parindent}{1em}
5. \pagestyle{empty}
6. \begin{document}
7. \section*{Para spacing at 0pt}
8. Use \lstinline + \setlength{\parskip}{0pt}+
9. \setlength{\parskip}{0pt}
10. Researchers have discovered the most distant active supermassive black hole to date with the James Webb Space Telescope. The galaxy, CEERS 1019, existed just over 570 million years after the big bang, and its black hole is less massive than any other yet identified in the early universe. \\
11. Not only that, they’ve easily ``shaken out'' two more black holes that are also on the smaller side, and existed 1 and 1.1 billion years after the big bang. Webb also identified eleven galaxies that existed when the universe was 470 to 675 million years old.
12. \section*{Para spacing at 8pt}
13. \lstinline + \setlength{\parskip}{8pt}+ modifies the vertical spacing between paragraphs to 8pt.
14. \setlength{\parskip}{8pt}
15. CEERS 1019 is not only notable for how long ago it existed, but also how relatively little its black hole weighs. This black hole clocks in at about 9 million solar masses, far less than other black holes that also existed in the early universe and were detected by other telescopes. \\
16. Those behemoths typically contain more than 1 billion times the mass of the Sun – and they are easier to detect because they are much brighter. (They are actively “eating” matter, which lights up as it swirls toward the black hole.) The black hole within CEERS 1019 is more similar to the black hole at the center of our Milky Way galaxy, which is 4.6 million times the mass of the Sun.
17. \end{document}

Figure 3.55 \setlength{parskip} usage