×
Klik hier om ShareLaTeX te gebruiken in het Engels

[edit] ShareLaTeX guides

[edit] LaTeX Basics

[edit] Mathematics

[edit] Figures and tables

[edit] References and Citations

[edit] Languages

[edit] Document structure

[edit] Formatting

[edit] Fonts

[edit] Presentations

[edit] Commands

[edit] Field specific

[edit] Class files

If you need to insert cross-references to numbered elements in the document, (like equations, sections and figures) there are commands to automate it in LaTeX. This article explains how.

Contents

[edit] Introduction

Below you can see a simple example of images cross referenced:

\section{Introduction} \label{introduction}
This is an introductory paragraph with some dummy text. This section 
will be later referenced.
 
\begin{figure}[h]
\centering
\includegraphics[width=0.3\linewidth]{lion-logo.png}
\caption{This image will be referenced below}
\label{fig:lion}
\end{figure}
 
You can reference images, for instance, the image \ref{fig:lion} shows 
the logo of \textit{ShareLaTeX learn}

CrossReferencesEx1.png

The command \label{ } is used to set an identifier that is later used in the command \ref{ } to set the reference.

  Open an example in ShareLaTeX

[edit] Referencing sections and chapters

Below an example on how to reference a section

\section{Introduction} \label{introduction}
This is an introductory paragraph with some dummy text. This section 
will be later referenced.
 
\begin{figure}[h]
\centering
\includegraphics[width=0.3\linewidth]{lion-logo.png}
\caption{This image will be referenced below}
\label{fig:lion}
\end{figure}
 
You can reference images, for instance, the image \ref{fig:lion} shows 
the logo of \textit{ShareLaTeX learn}...
 
\section{Math references} \label{mathrefs}
As mentioned in section \ref{introduction}, different elements can be 
referenced within a document

CrossReferencesEx3.png

Again, the commands \label and \ref are used for references. The label can be set either right before or after the \section statement. This also works on chapters, subsections and subsubsections. See Sections and chapters.

  Open an example in ShareLaTeX

[edit] Referencing equations, figures and tables

At the introduction an example of a image referenced was shown, below cross referencing equations is presented.

\section{Math references} \label{mathrefs}
As mentioned in section \ref{introduction}, different elements can 
be referenced within a document
 
\subsection{powers series} \label{subsection}
 
\begin{equation} \label{eq:1}
\sum_{i=0}^{\infty} a_i x^i
\end{equation}
 
The equation \ref{eq:1} is a typical power series.

CrossReferencesEx2.png

For further and more flexible examples with labels and references see

  Open an example in ShareLaTeX

[edit] Referencing the page of an element

Elements usually are referenced by a number assigned to them, but if you need to, you can insert the page where they appear.

\section{Math references} \label{mathrefs}
As mentioned in section \ref{introduction}, different elements can 
be referenced within a document
 
\subsection{powers series} \label{subsection}
 
\begin{equation} \label{eq:1}
\sum_{i=0}^{\infty} a_i x^i
\end{equation}
 
The equation \ref{eq:1} is a typical power series.
 
\section{Last section}
In the subsection \ref{subsection} at the page \pageref{eq:1} an 
example of a power series was presented.

CrossReferencesEx4.png

The command \pageref will insert the page where the element whose label is used appears. In the example above the equation 1. This command can be used with all other numbered elements mentioned in this article.

  Open an example in ShareLaTeX

[edit] Compiling documents with cross references

In Share LaTeX cross references work immediately, but for cross references to work properly in your local LaTeX distribution you must compile your document twice. There's also a command that can automatically do the job for all the references to work. For instance, if your document is saved as main.tex

latexmk -pdf main.tex

generates the file main.pdf with all cross-references working. To change the output format use -dvi or -ps.

  Open an example in ShareLaTeX

[edit] Further reading

For more information see: