Welcome to this tutorial, where multiple methods are used to handle vertical space. Vertical space is very important for large mathematical expressions. Because readability and clarity of the document are more beautiful.
For a single line equation
For single-line equation in the equation
environment, we looked at two methods for adjusting vertical spacing.
The \vspace
command and spacing commands like \smallskip
, \medskip
, and \bigskip
are useful for this purpose. Let’s explore how to use these commands effectively.
Using \vspace command with equation environment
\vspace{length} command allows you to add customizable vertical space before or after an equation.
\documentclass[11pt]{article}
\usepackage{amsmath,lipsum,xcolor}
\usepackage[top=1cm]{geometry} %for margin
\begin{document}
\pagecolor{brown!30}
\begin{equation}
\frac{\partial^2 u}{\partial t^2} = c^2 \nabla^2 u
\end{equation}
\vspace{10pt}
\begin{equation}
\Psi(x, t) = \int_{-\infty}^{\infty} \phi(k) e^{i(kx - \omega t)} \, dk
\end{equation}
\vspace{15pt}
\begin{equation}
\mathbf{F} = m \cdot \mathbf{a} + q \cdot \mathbf{v} \times \mathbf{B}
\end{equation}
\vspace{8pt}
\lipsum[6][3-6]
\begin{equation}
f(x) = \int_{0}^{x} e^{-t^2} \, dt
\end{equation}
\vspace{20px}
\begin{equation}
F(x) = \sum_{n=0}^{\infty} \frac{(-1)^n}{2n + 1}x^{2n+1}
\end{equation}
\vspace{10px}
\lipsum[7][1-10]
\end{document}
Output :
Using \smallskip, \medskip, and \bigskip commands
The \smallskip
, \medskip
, and \bigskip
commands provide predefined amounts of vertical space. These are convenient for quickly adjusting spacing without specifying exact measurements.
\documentclass[12pt]{article}
\usepackage{amsmath,lipsum,xcolor}
\usepackage[margin=1.5cm]{geometry}
\begin{document}
\pagecolor{teal!30}
\section*{Without add vertical space}
\lipsum[3][1-7]
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\begin{equation}
F = ma
\end{equation}
\begin{equation}
\frac{d}{dx} e^x = e^x
\end{equation}
\section*{Add vertical space}
\lipsum[4][1-7]
\medskip
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\smallskip
\begin{equation}
F = ma
\end{equation}
\bigskip
\begin{equation}
\frac{d}{dx} e^x = e^x
\end{equation}
\end{document}
Output :
In this example, each command is used to add different amounts of space around the equations.
Using \\[length] for mult-iline equation environments
Using \\[length]
in multi-line equation environments like align, gather, and others in LaTeX. The length
parameter allows you to specify the exact amount of additional vertical space you want to insert.
\documentclass[11pt]{article}
\usepackage{amsmath,lipsum,xcolor}
\usepackage[margin=1.5cm]{geometry} %for margin
\begin{document}
\pagecolor{green!15}
\begin{align}
e^{i\pi} + 1 &= 0 \quad & \text{(Euler's Identity)} \\[15px]
\frac{d}{dx} e^x &= e^x \quad & \text{(Derivative of } e^x) \\[12px]
\int_{0}^{1} x^2 \, dx &= \frac{1}{3} \quad & \text{(Integral of } x^2) \\[18px]
\sqrt[n]{x^n} &= x \quad & \text{(nth Root Property)} \\[25px]
\sin^2(\theta) + \cos^2(\theta) &= 1 \quad & \text{(Pythagorean Trigonometric Identity)}
\end{align}
\vspace{10px}
\lipsum[3][1-9]
\vspace{8px}
\begin{gather}
a^2 + b^2 = c^2 \quad \text{(Pythagorean Theorem)} \\[10px]
e^{i\theta} = \cos(\theta) + i\sin(\theta) \quad \text{(Euler's Formula)} \\[10px]
\frac{d}{dx}(a^x) = a^x \ln(a) \quad \text{(Derivative of Exponential Function)} \\[10px]
\int e^x \, dx = e^x + C \quad \text{(Integral of } e^x) \\[10px]
\frac{n!}{k!(n-k)!} = \binom{n}{k} \quad \text{(Binomial Coefficient)}
\end{gather}
\vspace{10px}
\lipsum[5][3-6]
\begin{equation}
\begin{split}
f(x) &= x^2 + 3x + 5 \\[15px]
&= \left(x + \frac{3}{2}\right)^2 - \frac{1}{4} + 5 \\[15px]
&= \left(x + \frac{3}{2}\right)^2 + \frac{19}{4} \quad \text{(Completing the square)}
\end{split}
\end{equation}
\end{document}
Output :
Use extra newline with \\
Use of extra \\
and \nonumber \\
within align*
and align
environments in LaTeX can be useful for controlling line spacing and equation numbering.
Adding extra \\ for non-numbered equation
The align*
environment is used for equations that don’t require numbering. To add extra space between lines in this environment, you can simply use additional \\
command. Here’s an example:
\documentclass[12pt]{article}
\usepackage{amsmath,xcolor,lipsum}
\usepackage[margin=1.5cm]{geometry}
\begin{document}
\pagecolor{purple!20}
\begin{align*}
a & = b + c \\
x & = y - z \\
m & = n + o
\end{align*}
\lipsum[5][1-6]
\begin{align*}
a & = b + c \\
\\ % Extra space
x & = y - z \\
\\ % More extra space
m & = n + o
\end{align*}
\lipsum[6][1-6]
\begin{gather*}
a + b = c \\
\\
x^2 + y^2 = z^2 \\
\\
e^{i\pi} + 1 = 0 \\
\\
\int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
\end{gather*}
\end{document}
Output :
Adding Extra \nonumber \\ with number equation
In the align
environment, each line is automatically numbered. If you want to add extra space without adding a number to the blank line, you use \nonumber \\
.
\documentclass[12pt]{article}
\usepackage{amsmath,xcolor,lipsum}
\usepackage[margin=1.5cm]{geometry}
\begin{document}
\pagecolor{green!20}
\section*{Without nonumber command}
In the case of number equations, what will be the result if \verb|\nonumber| command is not used? Observe the following grouping equation.
\begin{align}
a & = b + c \\
\\
x & = y - z \\
\\
m & = n + o
\end{align}
\section*{With nonumber command}
Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique, libero.
Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper elit.
Proin fermentum massa ac quam.
\begin{align}
a & = b + c \\
\nonumber \\ % Extra space, no equation number
x & = y - z \\
\nonumber \\ % More extra space, no equation number
m & = n + o
\end{align}
\lipsum[4][2-7]
\begin{gather}
a + b = c \\
\nonumber \\
x^2 + y^2 = z^2 \\
\nonumber \\
e^{i\pi} + 1 = 0 \\
\nonumber \\
\int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
\end{gather}
\end{document}
Output :
\setlength{\jot}{length} command is used from mathtools package
The \jot
command in LaTeX, particularly when using the mathtools
package, is a length command that specifies an additional vertical space between lines in math environments.
This can be particularly useful for making equations more readable by increasing the spacing between lines. You can use \jot
both locally (within a specific environment) and globally (affecting the entire document).
Using \setlength{\jot}{length} locally
To use \jot
locally, you modify the spacing within a specific math environment. This approach is preferred when you want to increase the spacing for a particular set of equations without affecting the rest of your document.
\documentclass[11pt]{article}
\usepackage{mathtools,lipsum,xcolor}
\usepackage[margin=1.5cm]{geometry} % for margin
\begin{document}
\pagecolor{red!20} % for page color
\lipsum[2][5-9]
{\setlength{\jot}{20px}
\begin{align}
f(x) &= ax^2 + bx + c \\
g(x) &= dx^2 + ex + f \\
h(x) &= gx^2 + hx + i \\
j(x) &= kx^2 + lx + m
\end{align}}
\vspace{5px}
\lipsum[3][3-9]
{\setlength{\jot}{20pt}
\begin{align}
\int x \, dx &= \frac{1}{2}x^2 + C \\
\int x^2 \, dx &= \frac{1}{3}x^3 + C \\
\int x^3 \, dx &= \frac{1}{4}x^4 + C \\
\int x^4 \, dx &= \frac{1}{5}x^5 + C
\end{align}}
\vspace{5px}
\lipsum[4][2-7]
{\setlength{\jot}{25px}
\begin{gather}
\sum_{i=1}^{n} a_i = a_1 + a_2 + \cdots + a_n \\
\sum_{i=1}^{n} a_i b_i = a_1 b_1 + a_2 b_2 + \cdots + a_n b_n \\
\sum_{i=1}^{n} a_i b_i c_i = a_1 b_1 c_1 + a_2 b_2 c_2 + \cdots + a_n b_n c_n
\end{gather}}
\end{document}
Output :
Using \setlength{\jot}{length} globally
If you want to increase the line spacing for all math environments in your document, you can set \jot
length globally in the preamble.
\documentclass[11pt]{article}
\usepackage{mathtools,lipsum,xcolor}
\usepackage[margin=1.5cm]{geometry} % for margin
\setlength{\jot}{25pt} % vertical space 25pt
\begin{document}
\pagecolor{yellow!20} % for page color
\lipsum[1][5-9]
\begin{align}
f(x) &= ax^2 + bx + c \\
g(x) &= dx^2 + ex + f
\end{align}
\lipsum[2][5-10]
\begin{align*}
\int x \, dx &= \frac{1}{2}x^2 + C \\
\int x^2 \, dx &= \frac{1}{3}x^3 + C \\
\int x^3 \, dx &= \frac{1}{4}x^4 + C
\end{align*}
\lipsum[4][2-10]
\begin{gather}
\sum_{i=1}^{n} a_i = a_1 + a_2 + \cdots + a_n \\
\sum_{i=1}^{n} a_i b_i = a_1 b_1 + a_2 b_2 + \cdots + a_n b_n \\
\sum_{i=1}^{n} a_i b_i c_i = a_1 b_1 c_1 + a_2 b_2 c_2 + \cdots + a_n b_n c_n
\end{gather}
\end{document}
Output :
Conclusion
Each method has different advantages. Used depending on the situation. The \setlength{\jot}{length}
command is a best practice that allows you to increase the space between math expressions locally and globally. Also, there are \\[length]
commands that need to be used repeatedly for each line.
So, in this tutorial every method is represented in such a beautiful way that you will not have any problem related to vertical space.