Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Inserting a figure in LaTeX

📅 2012-Jun-29 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

Inserting a figure or any image in LaTeX requires the graphicx package. The figure can be given a caption and a label. The label can be used to refer to the figure anywhere in the document and LaTeX will replace that reference with the figure number when it creates the output document.

% At the beginning of the document
\usepackage{graphicx}

% At the place you want a figure
\begin{figure}[h]
\centering
\includegraphics[scale=0.3]{pics/foobar.png}
\caption{This is a caption for the figure.}
\label{foobar-figure}
\end{figure}

% Refer to the figure when you want to
As shown in Figure \ref{foobar-figure}, the Foobar is a good choice.

Tried with: MikTeX 2.9 on Windows 7 64-bit