1

I have this code. In my list of figures "subcaption1" and "subcaption2" appears. I only want "hej" to appear in the list of figures, how can I do that?

\begin{figure}[htbp]
  \begin{minipage}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=\linewidth]{Chapters/xxxx.jpg}
    \caption{subcaption1}
    \label{fig:chapter001_dist_001}
  \end{minipage}
  \hspace{0.5cm}
  \begin{minipage}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=\linewidth]{Chapters/xxxx.png}
    \caption{subcaption2}
    \label{fig:chapter001_reward_001}
  \end{minipage}
  \caption{hej}
\end{figure}
  • 2
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Skillmon Jun 2 '18 at 8:25
2

You can use the subfig package.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\listoffigures
%%
\begin{figure}[htbp]
  \subfloat[][\label{fig:chapter001_dist_001}subcaption1]{%
    \includegraphics[width=0.47\linewidth]{example-image-a}}
  \hspace{0.06\linewidth}
  \subfloat[][\label{fig:chapter001_reward_001}subcaption2]{%
    \includegraphics[width=0.47\linewidth]{example-image-b}}
  \caption{hej}
  \label{fig:chapter001__001}
\end{figure}
In Figure~\ref{fig:chapter001__001} there are two figures, Figure~\ref{fig:chapter001_dist_001} and Figure~\ref{fig:chapter001_reward_001}.
\end{document}

enter image description here

EDIT

As requested in comments here is also a solution using the subcaptionpackage. There the subcaptions are not listed in the list of figures by default.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}% [list=true] to get caption in listoffigures
\begin{document}
\listoffigures
%%
\begin{figure}[htbp]
  \begin{subfigure}[b]{0.47\linewidth}
    \includegraphics[width=\linewidth]{example-image-a}
    \caption{subcaption1}
    \label{fig:chapter001_dist_001}
  \end{subfigure}%
  \hspace{0.06\linewidth}%
  \begin{subfigure}[b]{0.47\linewidth}
    \includegraphics[width=\linewidth]{example-image-b}
    \caption{subcaption2}
    \label{fig:chapter001_reward_001}
  \end{subfigure}%
  \caption{hej}
  \label{fig:chapter001__001}
\end{figure}
In Figure~\ref{fig:chapter001__001} there are two figures, Figure~\ref{fig:chapter001_dist_001} and Figure~\ref{fig:chapter001_reward_001}.
\end{document}
  • 1
    Could you extend you answer adding also an example with subcaption package? – gvgramazio Jun 2 '18 at 9:20
  • @gvgramazio, I have added it. That is probably a better solution. – StefanH Jun 2 '18 at 9:58

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.