0

I have a latex document in which I have included two images side by side within an enumerate function. The caption for those individual figures is aligned to the figure itself, but the overall Figure title is not aligned with the enumerate function instead it is aligned with the rest of the document

\begin{enumerate}
\item Consider the two figures given below,
\begin{figure}[h]
        \centering
    \begin{minipage}{0.4\linewidth}
        \centering
        \subfloat[\centering Figure 1 title.]
        {
            {
                \includegraphics[width=1\linewidth]{Figures/Figure_1.png}
            }
            \label{Figure_1}
        }
    \end{minipage}
    \begin{minipage}{0.4\linewidth}
        \centering
        \subfloat[\centering Figure 2 title.]
        {
            {
                \includegraphics[width=1\linewidth]{Figures/Figure_.png}
            }
            \label{fig:Figure_2}
        }
    \end{minipage}
    \caption{Common title for figure 1 and figure.}%
    \label{fig:fig:power_response}
\end{figure}

\end{enumerate}

  • 1
    Welcome to TSE. Please post a Minimal Working Example, instead of a code snippet. – José Carlos Santos Jun 30 '22 at 06:33
  • 1
    This is by design. The only function of the figure environment is to mark the content as not part of the document flow but an insert that can float and be inserted elsewhere so figure normalises margins, fonts, and some other settings to ensure they are not inherited from the position in the source. – David Carlisle Jun 30 '22 at 07:14

2 Answers2

0

I would probably use or nest the \subcaption package, inside the enumerate function, to align subfloats within a single float.

I am trying to figure out the output of your example, meanwhile you can have a look at the following thread in TSE: How to Use Figure Inside a Minipage

or: Floats, Figures and Captions

I'm following. Have a nice day.

MCM
  • 61
0
  • Your question is not clear at all... :
    • how should enumerate influence on figure,
    • are you aware that float figure can move out of enumerate or at least to some other item? Is this your problem?
    • which package you use for \subfloat,
    • why \subfloat should in inside of \minipages,
    • what result you expected,
    • etc.

A simple example how can be written your code fragment is (without bothering with eventual problems with inserting figures into enumerate environment):

\documentclass{article}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%

\usepackage[demo]{graphicx} \usepackage{subcaption}

\begin{document} \begin{enumerate} \item Consider the two figures given below, \begin{figure}[!h] \centering \setkeys{Gin}{width=\linewidth} \begin{subfigure}{0.4\linewidth} \includegraphics{Figures/Figure_1.png} \caption{Figure 1 title.}
\label{Figure_1} \end{subfigure} \hfil \begin{subfigure}{0.4\linewidth} \includegraphics{Figures/Figure_1.png} \caption{Figure 2 title.} \label{Figure_2} \end{subfigure} \caption{Common title for figure \ref{Figure_1} and figure \ref{Figure_2}.}% \label{fig:fig:power_response} \end{figure} \end{enumerate} \end{document}

where instead of minipage is used subfigure environment defined in the subcaption package. This MWE (Minimal Working Example) produce:

enter image description here

(red lines indicate part of page layout)

If you prefer to use of subfloat environment, you still can use subcaption package, but it should be of version 1.3 or newest. In this case the MWE body is:

\begin{document}
\begin{enumerate}
\item Consider the two figures given below,
    \begin{figure}[!h]
    \centering
    \setkeys{Gin}{width=0.4\linewidth}
\subfloat[Figure 1 title.   \protect\label{Figure_1}]%
    {\includegraphics{Figures/Figure_1.png}}
    \hfil
\subfloat[Figure 2 title.   \protect\label{Figure_2}]%
    {\includegraphics{Figures/Figure_2.png}}

\caption{Common title for figure \ref{Figure_1} and figure \ref{Figure_2}.}% \label{fig:fig:power_response} \end{figure} \end{enumerate} \end{document}

Result of compilation is the same as before.

However, Use of minipages has sense when you like to have two parallel figures in one figure environment. In such cases, the MWE body can be

\begin{document}
\begin{enumerate}
\item Consider the two figures given below,
    \begin{figure}[!h]
    \centering
    \setkeys{Gin}{width=\linewidth}
\begin{minipage}{0.4\linewidth}
    \includegraphics{Figures/Figure_1.png}
    \caption{Figure 1 title.}    
    \label{Figure_1}
\end{minipage}
    \hfil
\begin{minipage}{0.4\linewidth}
    \includegraphics{Figures/Figure_1.png}
    \caption{Figure 2 title.}
    \label{Figure_2}
\end{minipage}
    \end{figure}
\end{enumerate}
\end{document}

Here you should be aware, the common caption for both figures now has no sense, so it is here drop out. Compilation result is:

enter image description here

So, still remains the main problem: what you after? Let us know!

Zarko
  • 296,517