Photo by Jakob Owens on Unsplash
LaTeX is great for writing formal reports like a study project report, bachelor thesis, or master thesis. In this article, I will explain how to use regular image files as figures in your LaTeX documents.
Setup
To start off, I found it neat to store all images in directories inside the LaTeX project root. For simplicity's sake, I decided to name the directory "images" in this example.
Once that directory is created, images can be added to that directory and used in your .tex document. To enable this functionality, the following packages have to be included at the beginning of your .tex document.
...
\usepackage{graphicx}
\usepackage[noabbrev, capitalise]{cleveref}
...
The "graphicx" package is used for the images and figures, and the "cleverer" package references the images and figures.
Adding figures
To actually add the figure centered on the page with a nice figure caption that can be referenced in the text, the following could be done:
...
\begin{figure}[htbp]
\centerline{\includegraphics[width=0.9\textwidth]{images/picture_01.jpg}}
\caption{Photo by BoliviaInteligente on Unsplash}\label{fig:test_fig}
\end{figure}
...
To adjust the size of the image or figure, use the width parameter. The image is set to be 90% of the page's text width in the example above.
The resulting PDF will look something like this.
PDF result, with some lorem ipsum, illustrates how the figure is relative to the text width.
Referencing figures
The nice thing about using figure references is that their number will always be correct. That way, you just have to remember to label the figure. To reference the figure, use the \cref{} function and pass in the name of the label you want to reference. Like this:
...
This is a piece of text that references \cref{fig:test_fig} in a way that is nice and organized.
...
The result will look like this.
PDF result, with some lorem ipsum, illustrating how it would look.
Listing figures
To list your figures in a way similar to a table of contents, the following function must be used.
...
\listoffigures
...
The result would look like this.
PDF result.