How to reference equations in LaTeX document?
In this tutorial, you will learn how to reference equations anywhere in a LaTeX document.
Method 1
The simplest method to reference an equation in LaTeX is using \label
and \ref
command. First of all, you have to set the \label{<name>}
inside the equation environment then you can use the \ref{<name>}
to reference that equation anywhere you want.
The \ref{<name>}
will be replaced by the particular equation number.
\documentclass{article} \usepackage{amsmath} \begin{document} \noindent This is the first equation: \begin{equation}\label{eq:first} x + y = z \end{equation} This is the second equation: \begin{equation}\label{eq:secend} \begin{aligned} x &= a + 3^2 + (2 \times 2) \\ &= a + 9 + 4 \\ &= a + 13 \end{aligned} \end{equation} \noindent *Here I am referring to equation (\ref{eq:first}) and equation (\ref{eq:secend}) \end{document}
Output:
Method 2
In the above example, I manually used the parenthesis “()” to get those equation numbers inside the parenthesis. But If you don’t write “()” manually, you can use the \eqref
command instead of \ref
.
\documentclass{article} \usepackage{amsmath} \begin{document} \underline{Reference equations with \texttt{label} and \texttt{eqref} }\\[4pt] This is the first equation: \begin{equation}\label{eq:first} x + y = z \end{equation} This is the second equation: \begin{equation}\label{eq:secend} \begin{aligned} x &= a + 3^2 + (2 \times 2) \\ &= a + 9 + 4 \\ &= a + 13 \end{aligned} \end{equation} \noindent *Here I am referring to equation \eqref{eq:first} and equation \eqref{eq:secend} \end{document}
Output:
Reference multiline equations in LaTeX
When in a multiline equation every expression has its equation number. To reference every expression you have to set \label
for every expression then you can refer to them with \ref
or \eqref
command.
\documentclass{article} \usepackage{amsmath} \begin{document} This is a multi-line equation: \begin{align} a + b &= c \label{eq:first}\\ x + y &= x \label{eq:secend}\\ m + n &= q \label{eq:third} \end{align} \noindent *Here I am referring to equation \eqref{eq:first}, equation \eqref{eq:secend} and \eqref{eq:third} \end{document}
Output:
Leave a Reply