0

This question already has an answer here:

I found this code here since it's exactly what I need to use, but also I need a caption under both of them. There is an example for a subcaption but that's not it. I simply tried to add the caption command but it doesn't work. Can someone tell me how to modify it? Thanks.

 \begin{center}
   \resizebox{1.0\textwidth}{!}{
   \includegraphics[height=3cm]{pic1}
 % \caption{Picture 1}
   \label{fig:pic1}
\quad
   \includegraphics[height=3cm]{pic2}
 % \caption{Picture 2}
   \label{fig:pic2}
 }
\end{center}

marked as duplicate by Dr. Manuel Kuehner, Moriambar, TeXnician, Stefan Pinnow, Mico May 16 '17 at 4:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Instead \begin{center} ... \end{center} see if use package float and positioning option H in begin{figure}[H] ... \end{figure} is what you looking for:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}

\begin{document}
\begin{figure}[H]
    \begin{subfigure}{0.45\linewidth}
\includegraphics[width=\linewidth]{pic1}
   \caption{Picture 1}
\label{fig:pic1}
    \end{subfigure}
\hfil
    \begin{subfigure}{0.45\linewidth}
\includegraphics[width=\linewidth]{pic2}
   \caption{Picture 2}
\label{fig:pic2}
    \end{subfigure}
\caption{caption for both figure}
\label{fig:1-2}
\end{figure}
\end{document}

enter image description here

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