LaTeX More in figures: Side-by-Side Figures
latexteada
Posted on March 17, 2021
Hello hello, how are you? :)
These days I have been writing about images in LaTeX, this is an important thing because you can just put an image to decorate your file or, for example, if you are working with some investigation you can put images to show the results of the analysis you did.
In this post I teach you how to import a simple image, and in this I teach you how to do more things with your image, like adding a caption. I suggest you read these before you start with this post because I use some commands which I have talked about them there
Today I write about Side-by-Side images
Side-by-Side Images
This is a very useful tool because you can contrast the differences in the images which you are using. Or just because you want to add multiple images.
This task is so easy to do, we just need to add the images in different includegraphics
command inside the figure
environment
Do not forget that you need the
graphicx
package imported in the preamble
Before the example, I want to tell you
- The total width of all the figures must not exceed the page width. Otherwise, the figures will be inserted one below other
- There must not be any line breaks between the
includegraphics
command
Produces
We can use \hfill
to separate the figures by the available horizontal space
Produces
Maybe the difference is not so big, but, you can try with different sizes of images and you will notice the difference
That is how you can put side-by-side images in LaTeX, but did you notice?
There is just one caption for all the images you have put
Sometimes it could be good, but sometimes it is not good because you want to explain each image, and of course, there is a way to do it :)
The minipage
environment
minipage
as its name suggests is like if you have a mini page inside the page, you can configure its width and the content it will have
\begin{minipage}[position]{width}
content
\end{minipage}
Where position
could be
-
c
center -
t
at the top -
b
at the bottom
And width
can be
- An explicit measure, for example, 3cm, 8cm
- A portion of the width of the page, we can do it with
X\linewidth
where X is the percentage of the page, 0<X<1, for example, `0.5\linewidth* is the 50% of the page's width
An example
Produces
Images and minipage
If you want to add multiple images with a different caption, you need to put those in the minipage
environment
Remember that you need to have the
graphicx
package imported
- You can add a general caption, just before the
\end{figure}
command
Thanks, that was all, do not forget to follow me on Twitter @latexteada
Posted on March 17, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.