Pictures, Figures
Images are essential elements in most of the scientific documents. In this article we explain how to include images in the most common formats, how to customize, and reference them.
Importing an image
Before adding a picture, make sure to include that picture in the same directory as your .tex
file. Below is an example showing how to add a picture into your document:
In this example, we specifically import a package called graphicx
, which manages and include the image in the document. I will introduce to you some new commands:
\graphicspath{{./images/}}
- Tells that images are kept in a folder namedimages
.
\includegraphics{picture.png}
- includes the image in the document.qr.png
in this case is the name of the image.
Customize your pictures
There are multiple settings that allow users to customize the picture:
scale=number
enlarge or minimize the picture
width=5cm
specify the width
height=5cm
specify the height
angle=number
rotate your picture x degrees counter-clockwise. (negative number does the opposite)
Positioning your images
In order to position your picture, you need to wrap it in a container. In this case, we use the figure
environment. The figure
environment is used to display pictures as floating elements within the document. This means you include the picture inside the figure
environment and you don't have to worry about it's placement, will position it in a such way that it fits the flow of the document.
Here is an example:
Wrapping text around figures
It's possible to wrap the text around figures. In order to do that, we need to import the wrapfig
package. This package brings a new environment called wrapfigure
and we can place an \includegraphics
command inside it to create a wrapped figure. Here is the syntax of wrapfigure
.
Explanation:
Position has 4 main values:
r/R: right side of the text
l/L: left side of the text
the uppercase value makes the figure become float. (which means "place exactly here")
width: width of the figure container
Let's look at an example:
And we have:
Captioning
It's easy to create a caption in :
Labelling and cross-referencing
In order to label a figure, as well as make reference to it at somewhere in the document:
Explanation:
\label{fig:mesh1}
- labeling your figure, note that the name inside you can set anything you want, but since this is a figure of a mesh, I will set itfig:mesh1
.
\ref{fig:mesh1}
- print the number assigned to your figure, it also create a hyperlink leading you to the figure's position.\pageref{fig:mesh1}
- print the page number where the figure locates.
Last updated