Multiple subfigures in a row in a LaTeX document - latex

I am trying to insert four figures in a LaTeX document but if I use subfigure command, two of my figures stay in first row and the other two go to the second line. Like this :
The other solution I tried was using minipage command, but the problem with minipage is that the subfigures get normal figure caption (like Figure 1) while I would like subfigure captions like (a). See the following figure:
What I prefer is to have something like second picture but with the captions like first picture.

Your figures are too wide to fit side-by-side in one line. If multiple subfigures do not fit in one line, latex does an auto linebreak. You have to specify the width of each included graphic per subfigure such, that it will sum up to be smaller than the \textwidth parameter, i.e:
\begin{figure}
\centering
\subfigure[]{\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure[]{\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure[]{\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure[]{\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\caption{(a) blah (b) blah (c) blah (d) blah}
\label{fig:foobar}
\end{figure}
leads to
While if you set the width too high, e.g. width=0.5\textwidth leads to what I believe is your problem

Although it's been a long time since the question was asked but the solution #gehbiszumeis offered didn't work for me and I still got the normal figure caption for each subfigure. So in case anyone has still the same problem as mine here is what I did (according to this):
\begin{figure}
\centering
\begin{subfigure}{.24\textwidth}
\centering
\includegraphics[width=.95\linewidth]{FIRST IMAGE}
\caption{}
\label{SUBFIGURE LABEL 1}
\end{subfigure}
\begin{subfigure}{.24\textwidth}
\centering
\includegraphics[width=.95\linewidth]{SECOND IMAGE}
\caption{}
\label{SUBFIGURE LABEL 2}
\end{subfigure}
\begin{subfigure}{.24\textwidth}
\centering
\includegraphics[width=.95\linewidth]{THIRD IMAGE}
\caption{}
\label{SUBFIGURE LABEL 3}
\end{subfigure}
\begin{subfigure}{.24\textwidth}
\centering
\includegraphics[width=.95\linewidth]{FOURTH IMAGE}
\caption{}
\label{SUBFIGURE LABEL 4}
\end{subfigure}
\caption{FIGURE CAPTION}
\label{FIGURE LABEL}
\end{figure}

If some cannot get the subfigure's caption, like (a) (b) (c) and (d), me neither.
One solution is to replace the "[]" in "\subfigure[]" with "(a)",
just like:
\begin{figure}
\centering
\subfigure(a){\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure(b){\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure(c){\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure(d){\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\caption{(a) blah (b) blah (c) blah (d) blah}
\label{fig:foobar}
\end{figure}

Related

latex subfigure not centered

My code is as following but my figures are not centre aligned with captions. How can I fix it?
code result
\begin{figure}[H]
\centering
\begin{subfigure}{0.7\textwidth}
\includegraphics[width=4cm,height=6cm]{outwithsel.PNG}
\caption{Outliner}
\label{fig:h1}
\end{subfigure}
\begin{subfigure}{\textwidth}
\includegraphics[width=0.8\linewidth]{moveBtns.PNG}
\caption{Buttons that move selected object in 4 different directions}
\label{fig:h2}
\end{subfigure}
\caption{Kitchen is selected and can be moved to where desired}
Here somaia, that's what happens when I tried what you said. fix from comment 1
Your images have the widths 4cm and .8\textwidth, respectively. This means they are smaller than the subfigure around them. To get them centred inside the bigger subfigure, you need to repeat \centering inside the subfigure.
In addition there are missing % at the end of some of your lines. These unprotected line breaks will act like a space, and thus decentre your subfigure by a small amount (probably not noticeable, but when we are already at it...).
Unrelated to your problem: don't specify both the width and the height of the image, this will distort it. At least add keepaspectratio if you really must give both dimensions.
\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{float}
\begin{document}
\begin{figure}[H]
\centering
\begin{subfigure}{\textwidth}
\centering
\includegraphics[width=4cm,height=6cm]{example-image-duck}
\caption{Outliner}
\label{fig:h1}
\end{subfigure}%
\begin{subfigure}{\textwidth}
\centering
\includegraphics[width=.8\textwidth]{example-image-duck}
\caption{Buttons that move selected object in 4 different directions}
\label{fig:h2}
\end{subfigure}%
\caption{Kitchen is selected and can be moved to where desired}
\end{figure}
\end{document}
I think you have a problem in \texwidth, you have to choose the 0.5 textwidth for each subfigure
This will solve your problem:
\begin{figure}[H]
\centering
\includegraphics[width=.7\textwidth]{Bloch sphere.PNG}
\caption{Outliner}
\label{fig:h1}
\includegraphics[width=0.7\textwidth]{Bloch sphere.PNG}
\caption{Buttons that move selected object in 4 different directions}
\label{fig:h2}
\caption{Kitchen is selected and can be moved to where desired}
\end{figure}

How to align the note with the left side of the figure?

I am trying to put notes in the pictures of my work but the notes are getting aligned with the border of the text and not the figure. How to align the note (Fonte: Elaborated by the author (2021)) of the table with the left side of the figure?
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.35]{image.jpg}
\caption{Text tex text.}
\label{fig_intbus}
\end{center}
\fonte{Elaborated by the author (2021)..}
\end{figure}
I would like something similar to the threeparttable environment for tables but that can be used in figures. I thought about the minipage environment but I don't want to specify the width for each figure manually.
Here is an example of how to do it, defining a new caption.
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\newcommand{\fonte}[1]{\captionsetup{skip=0.5ex,position=b}\caption*{\textit{Fonte:} {#1}}}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{example-image-a}
\caption{Example image.}
\label{fig-img-a}
\fonte{Teste.}
\end{figure}
\end{document}
And the result is:

Refering with type and not only number

when I want to refer to for example an equation, I do the following:
\begin{align}
R= \frac{c * \Delta T}{2}
\label{eqn:Range}
\end{align}
Now I want to refer to \ref{eqn:Range}.
Then the output is the following:
Now I want to refer to 3.4.
I would like that the output is already:
Now I want to refer to equation 3.4.
Without me having to write equation manually.
The same goes also for tables and figures.
Especially for figures, I would like to know if there are more possibilities to display the reference.
For example with the following:
\begin{figure}[t]
\centering
\includegraphics[width=0.7\textwidth]{Example}
\caption{Example caption}
\label{fig:ExampleRef}
\end{figure}{}
I would like to be able to get also the caption displayed: Figure 1.1: Example caption.
Thank you for your help.
This sounds like a job for the cleveref package:
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[noabbrev]{cleveref}
\begin{document}
\begin{align}
R= \frac{c * \Delta T}{2}
\label{eqn:Range}
\end{align}
Now I want to refer to \cref{eqn:Range}.
\begin{figure}[t]
\centering
\includegraphics[width=0.7\textwidth]{example-image-duck}
\caption{Example caption}
\label{fig:ExampleRef}
\end{figure}
\cref{fig:ExampleRef}
\end{document}

Latex List of Figures

So i'm trying to hide the label in my cover image.
>\begin{figure}
>\center
>\includegraphics[scale=0.5]{universidade}
>\caption* {Mycaption}
>\end {figure}
This way it's not labeling the figure but its not showing on the list of figures
Help please ;D
You can give the caption package the option labelformat=empty to suppress the Figure 1 etc. labelling:
\usepackage[labelformat=empty]{caption}
You can use square brackets to specify the description for the figure list, and curly brackets for the actual figure caption. So I think you should be able to do the following to supress the caption but still have an entry in the figure list:
\begin{figure}
\center
\includegraphics[scale=0.5]{universidade}
\caption[Mycaption]{}
\end {figure}
There are a couple of options, depending on what yo're after exactly:
\documentclass{article}
\usepackage{graphicx}
\setcounter{topnumber}{3}% Just for this example
\begin{document}
\listoffigures
\begin{figure}
\addcontentsline{lof}{figure}{Example image A}%
\centering
\includegraphics[height=4\baselineskip]{example-image-a}
Example image A
\end{figure}
\begin{figure}
\addcontentsline{lof}{figure}{\protect\numberline{}Example image B}%
\centering
\includegraphics[height=4\baselineskip]{example-image-b}
Example image B
\end{figure}
\begin{figure}
\centering
\includegraphics[height=4\baselineskip]{example-image-c}
\caption{Example image C}
\end{figure}
\end{document}
The figure caption is added using \addcontentsline{lof}{figure}{<caption>}, where <caption> can either contain a blank \numberline{}, or just the regular caption. The above example shows the usage of either.
It would also be possible to have no label shows in the image, but have a numbered entry in the LoF using caption. But it would seem strange to have a numbered entry in the LoF and an unnumbered figure.

LATEX skips numbers in numbering when putting several figures in the same figure environment

Here are the package I am using:
\documentclass[twocolumn,showpacs,preprintnumbers,amsmath,amssymb,superscriptaddress]{revtex4}
\usepackage{graphicx}
\usepackage{bm}
\usepackage{subcaption}
\usepackage{SIunits}
\captionsetup{justification=raggedright, singlelinecheck=false}
\bibliographystyle{approve}
In order to put two figures next to each other, using the full width of the page even with the twocolumn option, I use this syntax:
\begin{figure*}
\centering
\begin{subfigure}[b]{0.5\textwidth}
\includegraphics[width=\textwidth]{mfploglog_A.eps}
\end{subfigure}%
\begin{subfigure}[b]{0.5\textwidth}
\includegraphics[width=\textwidth]{mfploglog.eps}
\end{subfigure}
\caption{XXX}\protect\label{Eloglog}
\end{figure*}
The probleme is that using this the numbering is incorrect. For each figure, a number is skipped as if the subfigure environment was counting as one figure. For example if I put just this figure in my code, it is going to be labeled as figure number 2.
Does someone already encountered this kind of problem ?
Don't use the caption package (or subcaption) with revtex4-1. You'll note in the .log that there are compatibility issues between the package and the class. Instead, place the two images side-by-side in the same figure* without using a subfigure environment:
\documentclass[twocolumn,showpacs,preprintnumbers]{revtex4-1}
\usepackage{graphicx}
\begin{document}
\begin{figure*}
\centering
\includegraphics[width=.3333\linewidth]{example-image-a} \qquad
\includegraphics[width=.3333\linewidth]{example-image-b}
\caption{XXX}
\end{figure*}
\end{document}
If you wish to add captions to the sub-figures, set the construction inside a tabular and enumerate them manually:
\documentclass[twocolumn,showpacs,preprintnumbers]{revtex4-1}
\usepackage{graphicx}
\begin{document}
\begin{figure*}
\centering
\begin{tabular}{c #{\qquad} c }
\includegraphics[width=.3333\linewidth]{example-image-a} &
\includegraphics[width=.3333\linewidth]{example-image-b} \\
\small (a) Left & \small (b) Right
\end{tabular}
\caption{XXX}
\end{figure*}
\end{document}

Resources