Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple subfigures in a row in a LaTeX document

Tags:

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 : enter image description here

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: enter image description here

What I prefer is to have something like second picture but with the captions like first picture.

like image 348
amiref Avatar asked Oct 03 '18 13:10

amiref


2 Answers

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

enter image description here

While if you set the width too high, e.g. width=0.5\textwidth leads to what I believe is your problem

enter image description here

like image 125
gehbiszumeis Avatar answered Sep 20 '22 18:09

gehbiszumeis


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}
like image 41
Behzad Avatar answered Sep 20 '22 18:09

Behzad