texblog

On paragraphs in TeX/LaTeX

When writing documents in TeX/LaTeX, it is important to understand how the TeX engine “thinks”. A paragraph is the basic text unit in a document and many TeX/LaTeX commands, when used properly, affect the current paragraph only. TeX provides a set of basic commands controlling the way a paragraphs are typeset. The following article explains the most commonly used commands and illustrates them with examples.

Any piece of text in TeX/LaTeX is a paragraph and follows predefined specifications. Single line-breaks will be ignored by the engine. To end a paragraph, leave a blank line between the end of the current and the beginning of the new paragraph.

...end of the current paragraph.

Beginning of a new paragraph...

The second, indented line marks the beginning of a new paragraph.

Alternatively, \par might be used to end a paragraph.

\documentclass{article}
\usepackage{blindtext}
\begin{document}
\blindtext\par\blindtext
\end{document}

 

Paragraph width

In plain TeX, \hsize controls the paragraph width, set to 6.5in by default. The example below shows how to change the paragraph width for a single paragraph.

\documentclass{article}
\usepackage{blindtext}
\begin{document}
\blindtext

\hsize 4in
\blindtext
\end{document}

The \leftskip and \rightskip commands provide a alternative, reducing the paragraph size from left and right respectively.

\documentclass{article}
\usepackage{blindtext}
\begin{document}
\blindtext

\leftskip=1.5in
\blindtext

\leftskip=0in \rightskip=1.5in
\blindtext
\end{document}

 
LaTeX knows at least two macros to control the paragraph width, the minipage environment and the \parbox command.

%Parbox macro
\parbox{4in}{...}

%Minipage environment
\begin{minipage}{4in}
...
\end{minipage}

 
Within a paragraph, the width is changed through the \hangindent and \hangafter commands. \hangindent controls the amount of indentation from left (positive value) or right (negative value). \hangafter, on the other hand, controls the number of full-width lines before changing the indent (\hangindent). A positive number produces full-width lines at the beginning, whereas a negative number produces them at the end.

Here is an example reducing the paragraph width by 2in from the right after the fifth line.

\documentclass[11pt]{article}
\usepackage{blindtext}
\begin{document}
\hangindent=-2in
\hangafter=5
\blindtext

\blindtext
\end{document}

 

Paragraph indentation

By default, TeX indents the first line of each paragraphs by 20pt. The \parindent command controls the indentation of paragraphs. To change the indentation document-wide, set \parindent in the document preamble to the desired value. To disable the indentation for a single paragraph, use \noindent at the beginning of the paragraph.

\documentclass{article}
\usepackage{blindtext}
\parindent=0pt % disables indentation
\begin{document}
\blindtext

\blindtext
\end{document}

 

Vertical space between paragraphs

TeX leaves no vertical space between paragraphs by default (\parskip=0pt). Similar to \parindent, setting \parskip in the document preamble controls the vertical space between paragraphs document-wide.

\documentclass{article}
\usepackage{blindtext}
\parskip=12pt % adds vertical space between paragraphs
\begin{document}
\blindtext

\blindtext
\end{document}

 

Vertical space between lines

While using the default font size (10pt), the line distance is 12pt. A ratio of 1.2 (line height to font size) leaves enough space between lines for a good reading experience and gives a harmonious look. The line height can be changed through \baselineskip.

More on font size in LaTeX.

\documentclass{article}
\usepackage{blindtext}
\begin{document}
\blindtext

\baselineskip=20pt
\blindtext
\end{document}

 

Further readings

A gentle introduction to TeX, a relatively short, but well written introduction to TeX by Michael Doob.

Exit mobile version