子标题:避免在图片列表中显示子图的标签

子标题:避免在图片列表中显示子图的标签

之前我曾问过避免在图表列表中显示 chapter.section 的数量。代码运行良好,但使用 subcaption 包时不适用于子图。

\documentclass[a4paper,12pt]{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage[list=true]{subcaption}

%Avoid showing the number of chapter.section in the list of figure
\usepackage{tocbasic}   % needs version 3.20 or newer   
\DeclareTOCStyleEntry[
entrynumberformat=\gobble,
numwidth=0pt,
indent=0pt
]{tocline}{figure}
\newcommand\gobble[1]{}

\begin{document}
\listoffigures
\section{TEST}
\lipsum[1]
\begin{figure}
 \centering
 \captionsetup[subfigure]{labelformat=empty}
 \begin{subfigure}[b]{1.0\linewidth}
    \includegraphics[width=1.0\linewidth]{example-image-a}
    \caption{This is figure A.}
\end{subfigure}

\vspace{15pt}
\lipsum[1]  
\vspace{15pt}   

\begin{subfigure}[b]{1.0\linewidth}
    \caption{This is Figure B.}
    \includegraphics[width=1.0\linewidth]{example-image-b}
\end{subfigure}
\end{figure}'

答案1

您可以对条目使用类似的代码subfigure

\documentclass[a4paper,12pt]{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage[list=true]{subcaption}

%Avoid showing the number of chapter.section in the list of figure
\usepackage{tocbasic}   % needs version 3.20 or newer
\DeclareTOCStyleEntry[
  entrynumberformat=\gobble,
  numwidth=0pt,
  indent=0pt
]{tocline}{figure}
\DeclareTOCStyleEntry[
  level=2,
  entrynumberformat=\gobble,
  numwidth=0pt,
  indent=1.5em% <- if subfigures should be indented
]{tocline}{subfigure}
\newcommand\gobble[1]{}

\begin{document}
\listoffigures
\section{TEST}
\lipsum[1]
\begin{figure}
 \centering
 \captionsetup[subfigure]{labelformat=empty}
 \begin{subfigure}[b]{1.0\linewidth}
    \includegraphics[width=1.0\linewidth]{example-image-a}
    \caption{This is figure A.}
\end{subfigure}

\vspace{15pt}
\lipsum[1]  
\vspace{15pt}   

\begin{subfigure}[b]{1.0\linewidth}
    \caption{This is Figure B.}
    \includegraphics[width=1.0\linewidth]{example-image-b}
\end{subfigure}
\caption{Figure with two subfigures.}
\end{figure}
\end{document}

在此处输入图片描述

相关内容