Page breaks become very important from time to time for proper document structure and formatting.
In this tutorial, we will explore three primary methods to insert page breaks in LaTeX: \newpage
, \clearpage
, and \pagebreak
. We will also discuss best practices for using these commands effectively.
Use newpage Command
Simplest and most commonly used method to create a page break in LaTeX is use \newpage
command. This command forces LaTeX to end the current page and start a new one immediately.
It is straightforward to use, you just need to insert this command at the desired location in your LaTeX document.
\documentclass{article}
\usepackage{graphicx} % For insert image in document
\usepackage[margin=1.5cm]{geometry} % for margin
\usepackage{lipsum} % For placeholder text, remove in your actual document
\begin{document}
\title{Use of newpage command}
\author{Physics Raed}
\date{\today}
\maketitle
\section{Introduction}
\lipsum[1]
\vspace{1cm}
\lipsum[2]
\begin{figure}[htbp]
\centering
\includegraphics[width=1\textwidth]{example-image}
\caption{Sample Image}
\label{fig:sample_image}
\end{figure}
\newpage
\section{Methodology}
\lipsum[2]
\subsection{Data Collection}
\lipsum[3]
\subsection{Data Preprocessing}
\lipsum[4]
\vspace{1cm}
\begin{figure}[htbp]
\centering
\includegraphics[width=.5\textwidth]{example-image}
\caption{Sample Image}
\label{fig:sample_image}
\end{figure}
\newpage
\section{Results}
\lipsum[5]
\subsection{Table}
Here is an example of a table:
\begin{table}[htbp]
\centering
\caption{Sample Table}
\begin{tabular}{|c|c|c|}
\hline
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\
\hline
1 & A & \$100 \\
2 & B & \$200 \\
3 & C & \$300 \\
\hline
\end{tabular}
\end{table}
\subsection{Image}
Here is an example of an image:
\newpage
\section{Discussion}
\lipsum[6]
\subsection{Analysis}
\lipsum[7]
\subsection{Conclusion}
\lipsum[8]
\end{document}
Output :
In this example, the content following \newpage
command will start on a new page. You can use this command multiple times to insert multiple page breaks wherever necessary.
But not all cases will work the same. Let’s say you create a two-column document, which is most commonly used.
In this case, when you use \newpage
command, Next elements of this command will move to next column instead of going to the new page.
\documentclass[twocolumn]{article}
\usepackage{lipsum} % For placeholder text, remove in your actual document
\usepackage[left=1cm,top=1cm,right=1cm]{geometry} % for page margin
\begin{document}
\section{Introduction}
\lipsum[1]
\section{Methodology}
\lipsum[3]
\vspace{1cm}
\lipsum[5]
\newpage
\section{Results}
\lipsum[7-8]
\subsection{Analysis}
\lipsum[9]
\subsection{Conclusion}
\lipsum[10]
\newpage
\section{Discussion}
\lipsum[11-12]
\section{References}
\lipsum[13]
\end{document}
Output:
Use \pageclear Command
Before exploring the second method, it’s important to understand LaTeX’s float elements.
Floats are elements, such as figures and tables, that don’t have a fixed position in the text. Instead, LaTeX automatically adjusts their placement to avoid large gaps or empty spaces.
The \clearpage
command functions like \newpage
by creating a page break. However, it also ensures that all pending floats are processed and placed before starting the next page.
This is particularly useful when you need to display all figures and tables before moving on to a new section.
\documentclass{article}
\usepackage{lipsum,graphicx} % For generating dummy text
\usepackage[margin=1.5cm]{geometry}
\begin{document}
\section{Introduction}
\lipsum[1]
\vspace{1cm}
\lipsum[3]
\vspace{1cm}
\lipsum[6-7]
\begin{figure}[h]
\centering
\includegraphics[width=1\textwidth]{example-image-a}
\caption{Example Figure A}
\end{figure}
\lipsum[4]
\begin{table}[h]
\centering
\caption{A 6,5 Table Example}
\vspace{10px}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Column 1 & Column 2 & Column 3 & Column 4 & Column 5 & Column 6 \\
\hline
Item 1 & 100 & 200 & 300 & 400 & 500 \\
\hline
Item 2 & 101 & 201 & 301 & 401 & 501 \\
\hline
Item 3 & 102 & 202 & 302 & 402 & 502 \\
\hline
Item 4 & 103 & 203 & 303 & 403 & 503 \\
\hline
Item 5 & 104 & 204 & 304 & 404 & 504 \\
\hline
Item 6 & 105 & 205 & 305 & 405 & 505 \\
\hline
\end{tabular}
\end{table}
\lipsum[3]
\clearpage
\section{Methods}
\lipsum[5]
\end{document}
Output:
Use \pagebreak Command
By default, \pagebreak command doesn’t take any arguments and behaves similarly to \newpage
, inserting a page break without clearing any pending floats. For example,
\documentclass{article}
\usepackage[margin=1.5cm]{geometry} % for page margin
\usepackage{lipsum} % For generating dummy text
\begin{document}
\section*{Section 1: 1st Page}
\lipsum[1] % Generates 1` paragraphs of dummy text
\vspace{1cm}
\lipsum[2-3]
\vspace{1cm}
\lipsum[4]
\pagebreak
\section*{Section 2 : Start New page}
\lipsum[4-6] % Generates 3 more paragraphs of dummy text
\end{document}
The \pagebreak
command provides finer control over page breaks compared to \newpage
and \clearpage
. It accepts an optional argument that specifies the priority of a page break at a given location, ranging from 0
(least desirable) to 4
(most desirable).
Here’s the syntax for using optional argument.
\pagebreak[]
[0]
(Default): Suggests a page break but does not force it. LaTeX will determine the best break point based on content and float positioning.
[1-3]
: Indicates increasing levels of priority for a page break. A higher value makes a break more likely but does not guarantee it.
[4]
: Forces a page break, overriding other considerations. LaTeX will break the page at this point.
\documentclass{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{lipsum} %
\begin{document}
\section*{Section 1}
\lipsum[1-3]
\pagebreak[3]
\section*{Section 2}
\lipsum[4-6]
\pagebreak[1]
\section*{Section 3}
\lipsum[7-9]
\pagebreak[4]
\section*{Section 4}
\lipsum[10-12]
\end{document}
Output:
In this example, we use different priority values with \pagebreak before each section.
Before Section 1
: Since Priority is 3
, there is a relatively strong suggestion to break page here, but LaTeX may still consider other factors.
Before Section 2
: Priority is 1
, so LaTeX may or may not break page at this point, depending on other factors.
Before Section 3
: With priority 4
, Page break here becomes almost an absolute demand, and LaTeX will likely honor it.
Before Section 4
: No priority is specified here, so it behaves like \newpage
, and LaTeX will break page if necessary.