3

I use the following header files.

\usepackage[caption = false]{subfig}
\usepackage{subcaption}
\usepackage{graphicx} % subcaption for subfigure environment
\usepackage{caption}

I want to print subfigures and I used the following code.

\begin{figure}
    \centering
    \subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/53.jpg}}
    \subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/54.jpg}} 
    \subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/55.jpg}} 
    \subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/51.jpg}} 
    \subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/52.jpg}} 
    \caption{(a) Release cost (b) WIP-holding cost (c) Production cost (d) FGI-holding cost (e) FGI-backorder cost}
    \label{fig:costbar}
\end{figure}

Can someone assist with the subfigures with individual figure names and why I get errors?

3
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Jun 9, 2022 at 4:55
  • Welcome to SE. Please provide a single block of code containing a Minimal Working (=compilable) Example. Also, remember that subfig is a very old, very obsolete package that should no longer be used. And which errors are you getting?
    – Miyase
    Commented Jun 9, 2022 at 4:57
  • Also, subfig is incompatible with subcaption. OTOH, subcaption supports \subfloat. Simply replace \subfigure with \subfloat and everything should work the same. Commented Jun 9, 2022 at 17:03

2 Answers 2

2

Here's a possible example:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{font=small, labelfont=bf}
\captionsetup[sub]{labelsep=period, subrefformat=brace}

\begin{document}

\begin{figure}
\centering
    \begin{subfigure}[b]{0.16\textwidth}
    \centering
    \includegraphics[width=1.8cm]{example-image-a}
    \caption{\label{fig:image1}}
    \end{subfigure}
\quad
    \begin{subfigure}[b]{0.16\textwidth}
    \centering
    \includegraphics[width=1.8cm]{example-image-b}
    \caption{\label{fig:image2}}
    \end{subfigure}
\quad
    \begin{subfigure}[b]{0.16\textwidth}
    \centering
    \includegraphics[width=1.8cm]{example-image-c}
    \caption{\label{fig:image3}}
    \end{subfigure}
\quad
    \begin{subfigure}[b]{0.16\textwidth}
    \centering
    \includegraphics[width=1.8cm]{example-image-a}
    \caption{\label{fig:image4}}
    \end{subfigure}
\quad
    \begin{subfigure}[b]{0.16\textwidth}
    \centering
    \includegraphics[width=1.8cm]{example-image-b}
    \caption{\label{fig:image5}}
    \end{subfigure}
\caption{\subref{fig:image1} Picture 1, \subref{fig:image2} picture 2, \subref{fig:image3} picture 3, \subref{fig:image4} picture 4, \subref{fig:image5} picture 5.}
\end{figure}

\end{document}

I put pictures side-by-side, so they're small, but by adjusting 0.16\textwidth (available width) and width (actual width) for each image, you can tweak it to taste.

Also, \quad is used to add some space between each image, you can replace with anything you want, including \\ if you want pictures on different lines.

Result: Result

Edit: added the two \captionsetup lines to tweak the appearence of the captions.

0
0

You can use grahicx and subcaption. Each subfigure can be referenced and captioned

\documentclass{article}

\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

    \begin{figure}[htb]
        \centering
        \begin{subfigure}[t]{0.2\textwidth}
            \centering
            \includegraphics[width=\linewidth,height=50mm, keepaspectratio]{example-image-a}
            \caption{This is a very long caption for such a little figure, will the captions overlap?}
            \label{fig:fig-a}
        \end{subfigure}
        \hfill
        \begin{subfigure}[t]{0.2\textwidth}
            \centering
            \includegraphics[width=\linewidth,height=40mm, keepaspectratio]{example-image-b}
            \caption{This is a very long caption for such a little figure, will the captions overlap?}
            \label{fig:fig-b}
        \end{subfigure}
        \hfill
        \begin{subfigure}[t]{0.2\textwidth}
            \centering
            \includegraphics[width=\linewidth,height=50mm, keepaspectratio]{example-image-a}
            \caption{This is a very long caption for such a little figure, will the captions overlap?}
            \label{fig:fig-c}
        \end{subfigure}
        \hfill
        \begin{subfigure}[t]{0.2\textwidth}
            \centering
            \includegraphics[width=\linewidth,height=40mm, keepaspectratio]{example-image-b}
            \caption{This is a very long caption for such a little figure, will the captions overlap?}
            \label{fig:fig-d}
        \end{subfigure}
        \caption{A lot of subfigures inside one figure}
        \label{fig:my-fig}
    \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 .