> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/formatting/05-line-breaks-and-blank-spaces.md).

# Line breaks and blank spaces

Breaking the document flow in LaTeX is not recommended unless you are [creating a macro](/latex/class-files/03-writing-your-own-package.md). 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

The most standard way how to break lines is to create a new paragraph. This is done by leaving an empty line in the code.

```latex
\documentclass{article}
\begin{document}
This paragraph contains no information
and its purpose is to provide an example on how to start a new paragraph.
As you can see,
single line
break in the code
acts as a space in text.

However, leaving an empty line starts a new paragraph.
\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=New+paragraph\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0AThis+paragraph+contains+no+information%0Aand+its+purpose+is+to+provide+an+example+on+how+to+start+a+new+paragraph.%0AAs+you+can+see%2C%0Asingle+line%0Abreak+in+the+code%0Aacts+as+a+space+in+text.%0A%0AHowever%2C+leaving+an+empty+line+starts+a+new+paragraph.%0A%5Cend%7Bdocument%7D)

![LineBreaksEx1aupdated.png](/files/gCUPerZQX5oWCGgcJhy9)

This is not the only command to insert line breaks, in the [next section](#line-breaks) two more will be presented.

## Line breaks

As mentioned before, there's more than one way to insert line breaks.

```latex
\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}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+line+break+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Butf8%5D%7Binputenc%7D%0A%0A%5Cbegin%7Bdocument%7D%0ASomething+in+this+document.+This+paragraph+contains+no+information+%0Aand+its+purposes+is+to+provide+an+example+on+how+to+insert+white+%0Aspaces+and+lines+breaks.%5C%5C%0AWhen+a+line+break+is+inserted%2C+the+text+is+not+indented%2C+there+%0Aare+a+couple+of+extra+commands+do+line+breaks.+%5Cnewline%0AThis+paragraph+provides+no+information+whatsoever.+We+are+exploring+%0Aline+breaks.+%5Chfill+%5Cbreak%0AAnd+combining+two+commands%0A%5Cend%7Bdocument%7D)

![LineBreaksEx2new.png](/files/3nOHo9g8UNx6lzJ2EaYA)

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](#reference-guide).

## Page breaks

There are two commands to insert page breaks, `clearpage` and `newpage`. Below is an example using `clearpage`.

```latex
\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=3cm]{overleaf-logo}
\caption{Overleaf logo}
\end{figure}

Hello,  here  is  some  text  without  a  meaning...
\clearpage
```

![LineBreaksEx3OverleafNew.png](/files/QDAP1bIXMHpGUw6SQDnb)

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 break point.

If this is not what you need, you can use `\newpage` instead.

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
\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=3cm]{overleaf-logo}
\caption{Overleaf logo}
\end{figure}

Hello,  here  is  some  text  without  a  meaning...
\newpage
```

![LineBreaksEx4Overleaf.png](/files/sdESc9vQ1edpdwX5WyRq)

In this case the images are placed in the new page trying to fit the text flow.

[Open in Overleaf](https://www.overleaf.com/project/new/template/19338?id=65200057\&templateName=\&latexEngine=\&texImage=texlive-full%3A2020.1\&mainFile=)

## Horizontal blank spaces

Horizontal spaces of arbitrary length may be inserted with `\hspace`.

```latex
Horizontal \hspace{1cm} spaces can be inserted manually. Useful
to control the fine-tuning in the layout of pictures.

Left Side \hfill Right Side
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=\&snip_name=Horizontal+spaces\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%0AHorizontal+%5Chspace%7B1cm%7D+spaces+can+be+inserted+manually.+Useful+%0Ato+control+the+fine-tuning+in+the+layout+of+pictures.%0A%0ALeft+Side+%5Chfill+Right+Side%0A%0A%5Cend%7Bdocument%7D)

![LineBreaksEx5.png](/files/yc40GMwzlWBqgxVhcMNJ)

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.

```latex
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.
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=\&snip_name=Vertical+blank+spaces\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%0AText+at+the+top+of+the+page.+Text+at+the+top+of+the+page.+%0AText+at+the+top+of+the+page.+Text+at+the+top+of+the+page.+%0AText+at+the+top+of+the+page.+Text+at+the+top+of+the+page.+%0AText+at+the+top+of+the+page.%0A%0A%5Cvspace%7B5mm%7D+%255mm+vertical+space%0A%0AThis+text+still+at+the+top%2C+5mm+below+the+first+paragraph.%0A%0A%5Cvfill%0A%0AText+at+the+bottom+of+the+page.%0A%0A%5Cend%7Bdocument%7D)

![LineBreaksEx6.png](/files/afQdTkOKJN8atoToiDDk)

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**

* ```latex
   \\*
  ```

  (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.

* ```latex
   \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.

* ```latex
   \hfill\break
  ```

This will produce the same result as *\newline* and *\\\\*.

Additionally, LaTeX provides the following advanced option for line break.

* ```latex
   \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:

* [Lengths in LaTeX](/latex/formatting/01-lengths-in-latex.md)
* [Paragraphs and new lines](/latex/latex-basics/02-paragraphs-and-new-lines.md)
* [Paragraph formatting](/latex/formatting/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [Text alignment](/latex/formatting/06-text-alignment.md)
* [Bold, italics and underlining](/latex/latex-basics/03-bold-italics-and-underlining.md)
* [Lists](/latex/latex-basics/04-lists.md)
* [Single sided and double sided documents](/latex/formatting/08-single-sided-and-double-sided-documents.md)
* [Multiple columns](/latex/formatting/09-multiple-columns.md)
* [The not so short introduction to LaTeX2ε](http://www.ctan.org/tex-archive/info/lshort/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/formatting/05-line-breaks-and-blank-spaces.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
