1

I am adding multiple figures in a single row with following code

\begin{figure}
  \centering
  \begin{tabular}[b]{c}
    \includegraphics[width=0.20\linewidth]{image here} \\
    \small (a) Figure 1
  \end{tabular} \qquad
  \begin{tabular}[b]{c}
    \includegraphics[width=0.20\linewidth]{image here} \\
    \small (b) Figure 2
  \end{tabular} \qquad
 
  \begin{tabular}[b]{c}
    \includegraphics[width=0.20\linewidth]{image here} \\
    \small (c) Figure 3
  \end{tabular} \qquad
  \begin{tabular}[b]{c}
    \includegraphics[width=0.20\linewidth]{image here} \\
    \small (a) Figure 4
  \end{tabular} \qquad

The code works fine to add two figures per line, can some one help to add 3, 4 figures in the same. Unfortunately, I cannot use sub figure, it has some clashes with the journal paper template

2
  • 2
    Don’t leave a blank line after the second tabular environment. (All-blank lines trigger paragraph breaks.) oh, and do omit \qquad after the fourth tabular.
    – Mico
    Feb 16, 2022 at 17:47
  • Did you try the floatrow package?
    – Bernard
    Feb 16, 2022 at 18:36

3 Answers 3

1

This uses tabular's less familiar cousin, tabular*, and his little friend \extracolsep.

\documentclass{article}
\usepackage{graphicx}
\usepackage{showframe}% alignment tool
\begin{document}

\begin{figure}
  \tabcolsep=0pt
  \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}cccc}
    \includegraphics[width=0.20\textwidth]{example-image-a} &
    \includegraphics[width=0.20\linewidth]{example-image-b} &
    \includegraphics[width=0.20\linewidth]{example-image-c} &
    \includegraphics[width=0.20\linewidth]{example-image} \\
    \small (a) Figure 1 &
    \small (b) Figure 2 &
    \small (c) Figure 3 &
    \small (a) Figure 4
  \end{tabular*}
\end{figure}

\end{document}

Frankly, it is easier simply to compute the \tabcolsep needed to add up to \linewidth (2 per column).

\documentclass{article}
\usepackage{graphicx}
\usepackage{showframe}% alignment tool
\begin{document}

\begin{figure}
  \tabcolsep=0.2\linewidth
  \divide\tabcolsep by 8
  \begin{tabular}{cccc}
    \includegraphics[width=0.20\linewidth]{example-image-a} &
    \includegraphics[width=0.20\linewidth]{example-image-b} &
    \includegraphics[width=0.20\linewidth]{example-image-c} &
    \includegraphics[width=0.20\linewidth]{example-image} \\
    \small (a) Figure 1 &
    \small (b) Figure 2 &
    \small (c) Figure 3 &
    \small (d) Figure 4
  \end{tabular}
\end{figure}

\end{document}
2
  • This approach, which employs the c column type for all four columns, does not actually guarantee that the width of each column won't exceed 0.2\linewidth. Why? It's because the widths of the "captions" are not constrained to be less than 0.2\linewidth. You may want to point this out explicitly.
    – Mico
    Feb 17, 2022 at 10:36
  • 1
    Of course a real \caption has to go inside a p{} column anyway (or a \parbox). Feb 17, 2022 at 12:50
2
  • My main suggestion is that you omit the blank line after the 2nd of 4 images. Remember that blank lines are interpreted (in many, but not all text-mode situations) as paragraph break initiators. Hence the suggestion to omit the blank line.

  • A further suggestion: omit the \centering instruction, omit the final \qquad directive, and replace the other 3 instances of \qquad with \hfill.

  • Finally, if you have quite a few figures of this kind, it's probably worth creating a bespoke macro -- called \myfig in the code below -- to help streamline the creation of the subfigures.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{array}
\usepackage[demo]{graphicx} % remove 'demo' option in real document
\newcommand\myfig[2]{%
   \begin{tabular}[b]{>{\centering\arraybackslash}p{0.2\textwidth}} 
      \includegraphics[width=\linewidth]{#1} \\ \small #2 \end{tabular}}
\begin{document}
\begin{figure}
  \myfig{image1}{(a) Figure 1}\hfill
  \myfig{image2}{(b) Figure 2}\hfill
  \myfig{image3}{(c) Figure 3}\hfill
  \myfig{image4}{(d) Figure 4}%
\end{figure}
\end{document}
2

Without tabular (or similar table) environment, by use of subloat environment (as defined in subcaption package version 1.3) and keys Gin you will get the shortest and simplest possible code for your problem:

\documentclass{article} 
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}
    \begin{figure}[htb]
\setkeys{Gin}{width=0.24\linewidth}
%
\subfloat[Figure 1]{\includegraphics{example-image-duck}}\hfill
\subfloat[Figure 2]{\includegraphics{example-image-duck}}\hfill
\subfloat[Figure 3]{\includegraphics{example-image-duck}}\hfill
\subfloat[Figure 4]{\includegraphics{example-image-duck}}
    \end{figure}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .