2

I need to add sub caption for the image how can do that?

\begin{figure}[!htb]
\centering

\minipage{0.32\textwidth}
  \includegraphics[width=\linewidth]{im1.PNG}
  
\endminipage\hfill
\minipage{0.29\textwidth}
  \includegraphics[width=\linewidth]{im2.png}
  
\endminipage\hfill
\minipage{0.32\textwidth}%
  \includegraphics[width=\linewidth]{im3.png}
  
\endminipage
 \caption{The device}
 \label{fig: T devices}
\end{figure}

This is the output for the code, I need to add the image name under each image(caption for each image)

enter image description here

4
  • 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
    Sep 20 at 22:19
  • Welcome! Please post a compilable example - that's much more useful than a snippet of code. That said, you may be looking for the subcaption package if I'm guessing correctly that you're already using caption.
    – cfr
    Sep 20 at 22:21
  • If you are using subcaption, subfigure IS a minipage with subcaptions. Also, \caption starts and ends wil a \par. Sep 21 at 13:37
  • I updated my question, any answer please?
    – stella
    Sep 21 at 22:08

1 Answer 1

2

If your subcaption is just a notation underneath each image, consider using a tabular-like setup (using tabularx like below, or otherwise).

enter image description here

\documentclass{article}

\usepackage{tabularx,graphicx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}

\begin{figure}
  \centering
  \begin{tabularx}{\linewidth}{@{} C C C @{}}
    \includegraphics[width=\linewidth]{example-image-a} &
      \includegraphics[width=\linewidth]{example-image-b} &
          \includegraphics[width=\linewidth]{example-image-c} \\
    \small Here is a subcaption &
      &
      \small Another subcaption that spans multiple lines
   \end{tabularx}
 \caption{The device}
\end{figure}

\end{document}

Use a tabular sets the content in a row-like fashion, which allows for separate alignments of your images (if they have differing proportions) and subcaptions (if they are of differing lengths). For example, you can have a baseline or bottom-alignment of the images, and a top-alignment of the subcaptions.

5
  • I got on this error Package tabularx Warning: X Columns too narrow (table too wide) on input line 265. Package array Error: Illegal pream-token (C): `c' used. Overfull \hbox (700.0pt too wide) in alignment at lines 265--265 Extra alignment tab has been changed to \cr.
    – stella
    Sep 22 at 22:18
  • And what about the caption of B image?
    – stella
    Sep 22 at 22:19
  • @stella: Did you add the \newcolymntype{C}{...} segment to your preamble? You can add a caption for the second image, sure!
    – Werner
    Sep 22 at 22:19
  • Ok, now it works. But I need to add caption to the image in the middle, how can I do that? and I need to resize the image, How can I use some thing like this \minipage{0.29\textwidth} ?
    – stella
    Sep 23 at 15:27
  • @stella: See this code for a middle subcaption. In terms of resizing content, you should use the key-value options supplied by graphicx's \includegraphics: \includegraphics[height=2em]{...}, for example.
    – Werner
    Sep 23 at 15:43

You must log in to answer this question.

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