DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

latexteada
latexteada

Posted on

LaTeX and Figures: Sub-Figures

Hello hello. How are you? :)

As we have seen during the posterior post we are talking about images

  • You can check how to import an image here
  • You can learn about the figure environment here
  • You can check how to put side-by-side images here

Today we are going to learn how to create sub-figures

Why should I learn about sub-figures?

Well, sometimes there are some images, that are related and you want to put them together, not on different sections. Here I show you how to do it

Sub-Figures

Remember that you need to have the graphicx package imported

To create a sub-figure environment we need to import the subfigure package. Once we have done that the next step is to put our image in the subfigure command

\subfigure[caption]{\includegraphics[options]{nameOfFile.ext}}
Enter fullscreen mode Exit fullscreen mode

Where

  • caption is the caption of the image, not the general caption
  • options are height, width, angle
  • nameOfFile is the name of the file

The complete instruction would be

\begin{figure}[position]
    \alignment
    \subfigure[caption1]{\includegraphics[options]{nameOfFile1.ext}}
    ...
    \subfigure[captionN]{\includegraphics[options]{nameOfFileN.ext}}
\end{figure}

Enter fullscreen mode Exit fullscreen mode

If you do not remember the figure environment you can remember it here

An example is

code

Produces

Screenshot from 2021-03-23 11-01-35

As you can notice, if the total width of the images exceed the page margins LaTeX is going to reorganize them to create a suitable place for those images

This is all for today, do not forget to follow me on Twitter @latexteada

I also publish some stuff there on Fridays. See you :)

Top comments (0)

DEV

Thank you.

Β 
Thanks for visiting DEV, we’ve worked really hard to cultivate this great community and would love to have you join us. If you’d like to create an account, you can sign up here.