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.
Ole J. Forsberg
Your timing could not be more perfect. I spent much of Friday afternoon trying to do these things. Thank you.
tom
Great to hear, thanks! Tom.
Paavo
Very helpful, thank you!
Addition: to prevent the indentation of text after an equation, add only ONE line feed between them. (This may be trivial, not for me.)
Follow-up question: is there an easy way to achieve the same effect after figures (which may be placed by LaTeX virtually anywhere)?
tom
Hi Paavo,
The same applies for figures and other floats. Do not leave any blank line, just continue your paragraph on the next line, right after
\end{figure}
and it will be place within the paragraph.Here is a MWE:
Youssef Cherem
Hello, this is the best and most complete explanation on LaTeX paragraph and line spacing I’ve ever seen. You could also mention there is the “leading” package that makes it much easier to change line spacing.
tom
Thanks, I wasn’t aware of this package. Here is a pointer to the package documentation.
Raffaele Mancuso
The link for the gentle introduction does not work anymore. Here is a possible alternative:
http://texdoc.net/texmf-dist/doc/plain/gentle/gentle.pdf
tom
Thanks for pointing this out. It’s fixed now. Best, Tom.
Alberto Takase
Hello, this is a nice article. To provide criticism, I believe mentioning lineskip alongside baselineskip would improve the article. Cheers.