由于 \captionof 位置导致的 LoF 问题

由于 \captionof 位置导致的 LoF 问题

我曾经在“OneCol”命令下minipage创建子图tcolorbox,如图所示。一切正常,盒子是可破坏的,我能够在盒子中放置文本和图片,没有任何问题,只是 LoF 不正确。如您所见,当我在\captionof{}图片底部(问题 0.2)时,图 0.2 的子图被移动到图列表中的图 0.1。当我将其放在\captionof{}图片顶部(问题 0.3)时,图 0.3 的列表顺序正确。我个人更喜欢将其放在\captionof图片下方而不是图片顶部。

  1. 如何解决这个问题?

提前致谢。

\documentclass[twoside]{scrbook}
\usepackage{showframe}
\usepackage{adjmulticol}
\usepackage{xcolor,graphicx,kantlipsum,multicol}
\usepackage[papersize={21cm,23cm},top=1.8cm, bottom=2cm, outer=7cm, inner=2cm, heightrounded, marginparwidth=5.0cm, marginparsep=0.5cm]{geometry}
\usepackage[most]{tcolorbox}
\usepackage{caption}
\usepackage{subcaption}
\definecolor{LightOcean}{RGB}{81, 147, 229 }
\definecolor{DeepOcean}{RGB}{51, 131, 229}

%CREATE NEW COMMAND for one columns
\newenvironment{OneCol}{\normalsize
    \begin{adjmulticols}{1}{0cm}{-5.5cm}}{\end{adjmulticols}}

%Define framed box for example problem
\newtcolorbox[auto counter,number within=chapter]{examplebox}[2][]{breakable,colback=LightOcean!10, colframe=DeepOcean,fonttitle=\bfseries, title=\Large{\textbf{Problem.}}~\thetcbcounter \ : #2,#1}

\usepackage[explicit]{titlesec}

\titleformat{\section}[block]
{\Large\bfseries}
{}
{0pt}
{\hspace{-0cm}% Move into margin
    \tikz[overlay] \shade[left color=black!20, right color=white] (0,-1ex) rectangle (\dimexpr\textwidth+5.5cm,1.2em);% Set background shaded rectangle
    \makebox[2em][l]{\thesection}#1}% Set number + title

\begin{document}

\listoffigures

\section{Section 1}
\vspace{0cm}
\begin{OneCol}  
        \begin{examplebox}[label={myautocounter}]{}
        \kant[1]
        \begin{center}
            \includegraphics[scale=0.3]{example-image}
            \captionof{figure}{The caption1}
        \end{center}
    \end{examplebox}    
\end{OneCol}    

\newpage
\section{Section 2}
\begin{OneCol}
\begin{examplebox}[label={myautocounter}]{Reaction}
    \begin{center}%
        \begin{minipage}{0.24\linewidth}
            \includegraphics[width=\linewidth]{example-image-a.jpg}%
            \captionof{subfigure}{A}\label{example-image-a.jpg}%
        \end{minipage}
        \hfill
        \begin{minipage}{.24\linewidth}
            \includegraphics[width=\linewidth]{example-image-b.jpg}%
            \captionof{subfigure}{B}\label{example-image-b.jpg}%
        \end{minipage}
        \hfill
        \begin{minipage}{.24\linewidth}
            \includegraphics[width=\linewidth]{example-image-c.jpg}%
            \captionof{subfigure}{C}\label{example-image-c.jpg}%
        \end{minipage}  
        \vspace{-2mm}
        \captionof{figure}{The first 3 letters of alphabet.}
    \end{center}
\end{examplebox}
\end{OneCol}

\section{Section 3}
\begin{OneCol}
    \begin{examplebox}[label={myautocounter}]{Reaction}
        \begin{center}%
            \captionof{figure}{The first 3 letters of alphabet.}
            \vspace{2mm}
            \begin{minipage}{0.24\linewidth}
                \includegraphics[width=\linewidth]{example-image-a.jpg}%
                \captionof{subfigure}{A}\label{example-image-a.jpg}%
            \end{minipage}
            \hfill
            \begin{minipage}{.24\linewidth}
                \includegraphics[width=\linewidth]{example-image-b.jpg}%
                \captionof{subfigure}{B}\label{example-image-b.jpg}%
            \end{minipage}
            \hfill
            \begin{minipage}{.24\linewidth}
                \includegraphics[width=\linewidth]{example-image-c.jpg}%
                \captionof{subfigure}{C}\label{example-image-c.jpg}%
            \end{minipage}
        \end{center}
    \end{examplebox}
\end{OneCol}

\end{document}

第1页

第2页

答案1

它不适用于\subcaption命令,需要摆弄\ContinuedFloat\captionlistentry。但如果你使用 subfigure环境它就可以工作:

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\captionsetup[subfigure]{list}

\begin{document}

\listoffigures


\begin{figure}[h!]
        \begin{subfigure}{0.24\linewidth}
            \caption{A}
        \end{subfigure}
        \hfill
        \begin{subfigure}{0.24\linewidth}
            \caption{B}
        \end{subfigure}
        \hfill
        \begin{subfigure}{0.24\linewidth}
            \caption{C}
        \end{subfigure}
        \caption{The first 3 letters of alphabet.}
\end{figure}

\noindent\begin{minipage}{\linewidth}
\captionsetup{type=figure}
        \begin{subfigure}{0.24\linewidth}
            \caption{A}
        \end{subfigure}
        \hfill
        \begin{subfigure}{0.24\linewidth}
            \caption{B}
        \end{subfigure}
        \hfill
        \begin{subfigure}{0.24\linewidth}
            \caption{C}
        \end{subfigure}
        \caption{The first 3 letters of alphabet.}
\end{minipage}


\begin{figure}[h!]
\captionlistentry{The first 3 letters of alphabet}%
        \begin{minipage}{0.24\linewidth}
            \subcaption{A}
        \end{minipage}
        \hfill
        \begin{minipage}{.24\linewidth}
            \subcaption{B}
        \end{minipage}
        \hfill
        \begin{minipage}{.24\linewidth}
            \subcaption{C}
        \end{minipage}

        \ContinuedFloat
        \caption[]{The first 3 letters of alphabet.}
\end{figure}


\noindent\begin{minipage}{\linewidth}
\captionsetup{type=figure}%
\captionlistentry{The first 3 letters of alphabet}%
        \begin{minipage}{0.24\linewidth}
            \subcaption{A}
        \end{minipage}
        \hfill
        \begin{minipage}{.24\linewidth}
            \subcaption{B}
        \end{minipage}
        \hfill
        \begin{minipage}{.24\linewidth}
            %\captionof{subfigure}{C}\label{example-image-c2.jpg}% gives error
            \subcaption{C}
        \end{minipage}

        \ContinuedFloat
        \caption[]{The first 3 letters of alphabet.}
\end{minipage}


\end{document}

在此处输入图片描述

对于你的例子,这意味着(缩短一点):

\documentclass[twoside]{scrbook}
\usepackage{showframe}
\usepackage{adjmulticol}
\usepackage{xcolor,graphicx,kantlipsum,multicol}
\usepackage[papersize={21cm,23cm},top=1.8cm, bottom=2cm, outer=7cm, inner=2cm, heightrounded, marginparwidth=5.0cm, marginparsep=0.5cm]{geometry}
\usepackage[most]{tcolorbox}
\usepackage{caption}
\usepackage{subcaption}
\definecolor{LightOcean}{RGB}{81, 147, 229 }
\definecolor{DeepOcean}{RGB}{51, 131, 229}

%CREATE NEW COMMAND for one columns
\newenvironment{OneCol}{\normalsize
    \begin{adjmulticols}{1}{0cm}{-5.5cm}}{\end{adjmulticols}}

%Define framed box for example problem
\newtcolorbox[auto counter,number within=chapter]{examplebox}[2][]{breakable,colback=LightOcean!10, colframe=DeepOcean,fonttitle=\bfseries, title=\Large{\textbf{Problem.}}~\thetcbcounter \ : #2,#1}

\captionsetup[subfigure]{list}

\begin{document}

\listoffigures


\section{Section 2}
\begin{OneCol}
\begin{examplebox}[label={myautocounter}]{Reaction}
    \begin{center}%
    \captionsetup{type=figure}
        \begin{subfigure}{0.24\linewidth}
            \includegraphics[width=\linewidth]{example-image-a.jpg}%
            \subcaption{A}\label{example-image-a.jpg}%
        \end{subfigure}
        \hfill
        \begin{subfigure}{0.24\linewidth}
            \includegraphics[width=\linewidth]{example-image-b.jpg}%
            \subcaption{B}\label{example-image-b.jpg}%
        \end{subfigure}
        \hfill
        \begin{subfigure}{0.24\linewidth}
            \includegraphics[width=\linewidth]{example-image-c.jpg}%
            \subcaption{C}\label{example-image-c.jpg}%
        \end{subfigure}
        \vspace{-2mm}

        \caption{The first 3 letters of alphabet.}
    \end{center}
\end{examplebox}
\end{OneCol}


\end{document}

在此处输入图片描述

相关内容