How do you reference an equation in LaTeX?

You can refer to any equation in your document from anywhere in that document. To get this feature in LaTeX, you have to follow these two steps:

  • First of all, you need to set different labels for different equations by \lable command that’s it.
  • Now you can call the label with the \ref command and refer to the equation under that label anywhere in the document.

 

To understand this process more effectively, let’s see an example.

\documentclass{article}
\begin{document}

\begin{equation}
  E=mc^2 \label{eq:mass-energy}
\end{equation}

The famous equation relates mass and energy: Eq.\ref{eq:mass-energy}.
\end{document}

Output:

Refering equation that relates mass and energy.

In the above example, the equation is labeled with the \label command and given the label “eq:mass-energy“. Then referred using the \ref command in the text below the equation.

When you compile the LaTeX code, the \ref command will be replaced by the number of the equation that it references. In this case, the text “Eq. 1” will be displayed, since the equation is the first one in the document.

In order to get the equation number inside the parenthesis (<eq-num>), you have to use the \eqref command instead of \ref. But in this case, you have to include the amsmath package. Take a look.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
  E=mc^2 \label{eq:mass-energy}
\end{equation}

The famous equation relates mass and energy: Eq.\eqref{eq:mass-energy}.
\end{document}

Output:

Refering equation that relates mass and energy with \eqref.

Use symbols instead of equation numbers

If you use other symbols or letters as an equation number, you can use the \tag command to replace the equation number with any symbol or letter in an equation. See how it works.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
  E=mc^2 \label{eq:mass-energy} \tag{$i$}
\end{equation}

\begin{equation}
  X_2=a+b \label{eq:1} \tag{$*$}
\end{equation}

\begin{equation}
  F=ma \label{eq:2} \tag{$\star$}
\end{equation}

The famous equation relates mass and energy: Eq.\eqref{eq:mass-energy}.\\
Referring  Eq.\eqref{eq:1}.\\
Referring  Eq.\eqref{eq:2}.

\end{document}

Output:

Use symbols instead of equation numbers.

Leave a Reply

Your email address will not be published. Required fields are marked *