Paragraphs and new lines
Introduction
This article introduces basic LaTeX paragraph formatting, including how to change text alignment. More detailed information, and further examples, can be found in the articles Text alignment and Paragraph formatting.
A first example
Let's start with an example which typesets two centred paragraphs by writing them inside a center
environment. Note how a new paragraph is started by inserting a blank line between them—although that's a commonly-used method, it's not the only way to start a new paragraph.
\begin{center}
Example 1: The following paragraph (given in quotes) is an
example of centred alignment using the center environment.
``La\TeX{} is a document preparation system and document markup
language. \LaTeX{} uses the \TeX{} typesetting program for formatting
its output, and is itself written in the \TeX{} macro language.
\LaTeX{} is not the name of a particular (executable) typesetting program, but
refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents."
\end{center}
This example produces the following output:
Starting a new paragraph
As noted above, one way to start a new paragraph is by inserting a blank line but the following code snippet shows an alternative solution which uses the \par
command:
This is text contained in the first paragraph.
This is text contained in the first paragraph.
This is text contained in the first paragraph.\par
This is text contained in the second paragraph.
This is text contained in the second paragraph.
This is text contained in the second paragraph.
This example produces the following output:
Paragraph alignment
By default paragraphs in LaTeX are fully justified, i.e. flush with both the left and right margins. If you would like to typeset an unjustified paragraph you can use the flushleft
or flushright
environments.
flushleft
and flushright
environments
The next example demonstrates typesetting a paragraph within the flushleft
and flushright
environments—for an example of the center
environment see the section A first example.
\section*{A paragraph typeset flush left}
\begin{flushleft}
La\TeX{} is a document preparation system and document markup
language. \LaTeX{} uses the \TeX{} typesetting program for formatting
its output, and is itself written in the \TeX{} macro language.
\LaTeX{} is not the name of a particular (executable) typesetting program, but
refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\end{flushleft}
\section*{A paragraph typeset flush right}
\begin{flushright}
La\TeX{} is a document preparation system and document markup
language. \LaTeX{} uses the \TeX{} typesetting program for formatting
its output, and is itself written in the \TeX{} macro language.
\LaTeX{} is not the name of a particular (executable) typesetting program, but
refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\end{flushright}
This example produces the following output:
\raggedright
and \raggedleft
An alternative to using environments such as flushleft
, flushright
or center
are the so-called "switch" commands:
\raggedright
, an alternative to using theflushleft
environment\raggedleft
, an alternative to using theflushright
environment\centering
, an alternative to using thecenter
environment
These switch commands change text alignment from the point they are inserted down to the end of the document—unless their effect(s) are restricted to a group or changed by another switch command.
In the following example, the effects of \raggedright
, \raggedleft
and \centering
are localized because they are used within the group created by \begingroup ... \endgroup
. In addition, note that in each case the paragraph text is followed by a blank line, before the \endgroup
command, which triggers LaTeX to typeset the paragraph whilst the settings applied by \raggedright
, \raggedleft
and \centering
are still active.
\section*{A fully justified typeset paragraph}
\LaTeX{} is not the name of a particular (executable) typesetting program, but refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\section*{A paragraph typeset using \texttt{\string\raggedright}}
\begingroup
\raggedright
\LaTeX{} is not the name of a particular (executable) typesetting program, but refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\endgroup
\section*{A paragraph typeset using \texttt{\string\raggedleft}}
\begingroup
\raggedleft
\LaTeX{} is not the name of a particular (executable) typesetting program, but refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\endgroup
\section*{A paragraph typeset using \texttt{\string\centering}}
\begingroup
\centering
\LaTeX{} is not the name of a particular (executable) typesetting program, but refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\endgroup
This example produces the following output:
For more detailed information and examples of text alignment see the Overleaf article on text alignment which also discusses using the ragged2e LaTeX package to typeset ragged text and configure hyphenation.
Paragraph indentation
By default new paragraphs are usually indented by an amount controlled by a parameter called \parindent
whose value can be set using the command \setlength
; for example:
\setlength{\parindent}{20pt}
sets \parindent
to 20pt. You can avoid indentation by setting \parindent
to 0pt (or 0mm, 0cm etc) or using the command \noindent
at the beginning of the paragraph. By default LaTeX does not indent the first paragraph contained in a document section as demonstrated in the following example:
\setlength{\parindent}{20pt}
\section*{This is a section}
\textbf{First paragraph} of a section which, as you can see, is not indented. This is more text in the paragraph. This is more text in the paragraph.
\textbf{Second paragraph}. As you can see it is indented. This is more text in the paragraph. This is more text in the paragraph.
\noindent\textbf{Third paragraph}. This too is not indented due to use of \texttt{\string\noindent}. This is more text in the paragraph. This is more text in the paragraph. The current value of \verb|\parindent| is \the\parindent. This is more text in the paragraph.
This example produces the following output:
Paragraph indentation is controlled or influenced by three commands:
\parindent
: a parameter which stores the current size of the paragraph indent\indent
: the effect of this command depends where it is used:- in a horizontal mode (inside a paragraph or an
\hbox
) or math mode it inserts a space (an empty box) of width\parindent
- in a vertical mode (between paragraphs or in a
\vbox
) it triggers the start a new indented paragraph
- in a horizontal mode (inside a paragraph or an
\noindent
: the effect of this command also depends where it is used:- in a vertical mode (between paragraphs or in a
\vbox
) it also triggers a new non-indented paragraph - in a horizontal mode (inside a paragraph or an
\hbox
) or math mode it has no effect: it is ignored
- in a vertical mode (between paragraphs or in a
The following example demonstrates \indent
:
\documentclass{article}
% Using the geometry package with a small
% page size to create the article graphic
\usepackage[paperheight=6in,
paperwidth=5in,
top=10mm,
bottom=20mm,
left=10mm,
right=10mm]{geometry}
\begin{document}
\noindent A new paragraph with some text, then an \verb|\indent|\indent command. Next, some inline math which also has an indent $y\indent x$. \verb|\indent| also works when used in an \verb|\hbox| such as \verb|\hbox{A\indent B}| which produces \hbox{A\indent B}.
\end{document}
This example produces the following output:
Further Reading
For more information check
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class