Line breaks and blank spaces
Breaking the document flow in LaTeX is not recommended unless you are creating a macro. Anyway, sometimes is necessary to have more control over the layout of the document; and for this reason in this article is explained how to insert line breaks, page breaks and arbitrary blank spaces.
Introduction
Line breaks are straightforward, a double backslash does the trick
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
Something in this document. This paragraph contains no information
and its purposes is to provide an example on how to insert white
spaces and lines breaks.\\
When a line break is inserted, the text is not indented, there are
a couple of extra commands do line breaks.
\end{document}
This is not the only command to insert line breaks, in the next section two more will be presented.
Line breaks
As mentioned before, there's more than one way to insert line breaks.
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
Something in this document. This paragraph contains no information
and its purposes is to provide an example on how to insert white
spaces and lines breaks.\\
When a line break is inserted, the text is not indented, there
are a couple of extra commands do line breaks. \newline
This paragraph provides no information whatsoever. We are exploring
line breaks. \hfill \break
And combining two commands
\end{document}
There are three commands here that work the same in the example:
\\
(two backslashes)\newline
\hfill \break
For more line-breaking commands see the reference guide.
Page breaks
There are two commands to insert page breaks, clearpage
and newpage
. Below is an example using clearpage
.
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
Something in this document. This paragraph contains no information and
its purposes is to provide an example on how to insert white spaces
and lines breaks.\\
When a line break is inserted, the text is not indented, there are a
couple of extra commands do line breaks. \newline
This paragraph provides no information whatsoever. We are exploring
line breaks. \hfill \break
And combining two commands
\begin{figure}
\centering
\includegraphics[width=4cm]{lion-logo}
\caption{Overleaf logo}
\end{figure}
Hello, here is some text without a meaning...
\clearpage
If the command \clearpage
is used, and there are stacked floating elements, such as tables or figures, they will be flushed out before starting the new page. In the example above the same image is inserted three times. Since the page break is inserted before all the figures are displayed, remaining images are inserted in an empty page before continuing with the text below the brake point.
If this is not what you need, you can use \newpage
instead.
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
Something in this document. This paragraph contains no information and
its purposes is to provide an example on how to insert white spaces
and lines breaks.\\
When a line break is inserted, the text is not indented, there are a
couple of extra commands do line breaks. \newline
This paragraph provides no information whatsoever. We are exploring
line breaks. \hfill \break
And combining two commands
\begin{figure}
\centering
\includegraphics[width=4cm]{lion-logo}
\caption{Overleaf logo}
\end{figure}
Hello, here is some text without a meaning...
\newpage
In this case the images are placed in the new page trying to fit the text flow.
Horizontal blank spaces
Horizontal spaces of arbitrary length may be inserted with \hspace
.
Horizontal \hspace{1cm} spaces can be inserted manually. Useful
to control the fine-tuning in the layout of pictures.
Left Side \hfill Right Side
There are two commands that insert horizontal blank spaces in this example:
\hspace{1cm}
- Inserts a horizontal space whose length is 1cm. Other LaTeX units can be used with this command.
\hfill
- Inserts a blank space that will stretch accordingly to fill the space available.
The commands \hrulefill
and \dotfill
do the same as \hfill
but instead of blank spaces they insert a horizontal ruler and a string of dots, respectively.
Vertical blank spaces
Vertical blank spaces have the same syntax as horizontal ones.
Text at the top of the page. Text at the top of the page.
Text at the top of the page. Text at the top of the page.
Text at the top of the page. Text at the top of the page.
Text at the top of the page.
\vspace{5mm} %5mm vertical space
This text still at the top, 5mm below the first paragraph.
\vfill
Text at the bottom of the page.
Let's see the two commands that insert vertical blank spaces.
\vspace{5mm}
- Inserts a vertical spaces whose length is 5mm. Other LaTeX units can be used with this command.
\vfill
- Inserts a blank space that will stretch accordingly to fill the vertical space available. That's why the line "Text at the bottom of the page." is moved to the bottom, and the rest of the space is filled in.
There are other three commands commonly used to insert vertical blank spaces
\smallskip
- Adds a 3pt space plus or minus 1pt depending on other factors (document type, available space, etc)
\medskip
- Adds a 6pt space plus or minus 2pt depending on other factors (document type, available space, etc)
\bigskip
- Adds a 12pt space plus or minus 4pt depending on other factors (document type, available space, etc)
Reference guide
Additional line-breaking commands
- (two backslashes and an asterisk)
\\*
breaks the line at the point of the command and additionally prohibits a page break after the forced line break.
\break
breaks the line without filling the current line. This will result in very bad formatting if you do not fill the line yourself. To fill the line, we can use it as given below.
\hfill\break
This will produce the same result as \newline and \\.
Additionally, LaTeX provides the following advanced option for line break.
\linebreak[number]
It breaks the line at the point of the command. The number provided as an argument represents the priority of the command in a range of 0 to 4. (0 means it will be easily ignored and 4 means do it anyway). When this line break option is used, LaTeX will try to produce the best line breaks possible.
Further reading
For more information see:
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- 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
- Debugging Compilation timeout errors
- How-to guides
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
- 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
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 in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia 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 and equations
- 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
- Typing 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
- Tips