1

In fact, I want to have a figure containing 3 subfigures where each figure has to be in a separate line here is the code that I have used but it illustrates them in one line.

\begin{figure*}[t!]
    \centering
    \begin{subfigure}{0.3\linewidth}
    \centering
    \includegraphics[scale=0.360]{fig1}
    \caption{Lorem ipsum}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\linewidth}
    \centering
    \includegraphics[scale=0.360]{fig2}
    \caption{Lorem ipsum}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\linewidth}
    \centering
    \includegraphics[scale=0.360]{fig3}
    \caption{Lorem ipsum}
\end{subfigure}
\caption{Caption place holder}
\end{figure*}
  • 2
    You can replace \hfill by an empty line. – leandriis Jun 26 '18 at 14:27
1

You can achiveve this only using \centering also inside the subfigures. There are some slight differences in terms of vertical spacing compared to StefanH's answer.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[t]
  \centering
    \begin{subfigure}{0.35\linewidth}
    \centering
      \includegraphics[width=\linewidth]{example-image-a}
      \caption{Lorem ipsum}
    \end{subfigure}\\
    \begin{subfigure}{0.35\linewidth}
        \centering
      \includegraphics[width=\linewidth]{example-image-b}
      \caption{Lorem ipsum}
    \end{subfigure}\\
    \begin{subfigure}{0.35\linewidth}
        \centering
      \includegraphics[width=\linewidth]{example-image-c}
      \caption{Lorem ipsum}
    \end{subfigure}    
  \caption{Caption place holder}
\end{figure}
\end{document}

enter image description here

  • \centering inside subfigure hasn't any function: images has size of subfigure environment ... – Zarko Sep 24 '18 at 18:21
  • That is true, I actually did not pay attention, I merely reused the code from the previous answer. However, it still centers for other sizes. – BambOo Sep 24 '18 at 20:30
0

I would put them in a table. (I removed the star from figure since it now becomes a high figure environment instead of a wide).

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[t]
  \centering
  \begin{tabular}{c}
    \begin{subfigure}{0.35\linewidth}
      \includegraphics[width=\linewidth]{example-image-a}
      \caption{Lorem ipsum}
    \end{subfigure}\\
    \begin{subfigure}{0.35\linewidth}
      \includegraphics[width=\linewidth]{example-image-b}
      \caption{Lorem ipsum}
    \end{subfigure}\\
    \begin{subfigure}{0.35\linewidth}
      \includegraphics[width=\linewidth]{example-image-c}
      \caption{Lorem ipsum}
    \end{subfigure}    
  \end{tabular}
  \caption{Caption place holder}
\end{figure}
\end{document}

enter image description here

  • 1
    Could you explain the benefits of using a tabular as compared to aranging the subfigures without a tabular? – leandriis Jun 26 '18 at 14:43
  • @leandriis There are many ways to do this, so I think it is a matter of taste. I find it often easy to get things side-by-side or on top of each other with help of tables. – StefanH Jun 26 '18 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.