在我的文档中,我有几个图,其中一些是由没有标题的子图组成的。如果我想打印一个图片列表(LOF),那么这些“无标题”子图的显示形式如下:
1. Figure 1: <Caption>
* a.
* b.
* c.
现在,这毫无意义。但是,我仍然想将子图包含在 LoF 中,因为其中许多都有适当的标题。
为了从 LoF 中删除“无标题”子图条目,我尝试过这个解决方案建议来自@Hertbert并且它似乎部分起作用了。也就是说,所需的条目确实从 LoF 中删除了,但是此解决方案似乎在两个图形条目之间添加了一些额外的垂直间距,如下图所示:
我的问题是如何消除两个 LoF 条目之间的额外垂直空间而不影响包含子图的其他条目?
这是我的最小工作示例(MWE):
\documentclass[a4paper,oneside]{report}
\usepackage[demo]{graphicx} %% To get demo figures
\usepackage{showframe} %% Shows the actual page layout
\usepackage[list=true]{subcaption} %% alternative for subfigure
%% To get subfloats listed in list of figures, you
%% must load the subcaption package with [list=true]
%% option!
%%\usepackage{subfigure} %% deprecated package!
\usepackage[subfigure]{tocloft} %% A trick for tocloft+subcaption combo.
%% This option is required if, and only if,
%% the tocloft and subfigure packages are being used
%% together. The two packages can be specifed in any
%% order. - From the tocloft package documentation
%% (dated 2013/05/02)
\newcounter{lofdepth} %% Declare new LoF depth counter
\newcounter{lotdepth} %% Declare new LoT depth counter
\setcounter{lofdepth}{2} %% Set new LoF depth counter to include subfigures
%%\setcounter{lofdepth}{1} %% If subfigures are't needed in LoF
%% Adding horizontal space between LoF numbers and entry text
\renewcommand{\cftfignumwidth}{1in} %% Exaggerated width!
\renewcommand{\cftsubfignumwidth}{1in} %% Exaggerated width!
%% Indentation for LoF entry numbers
\renewcommand{\cftfigindent}{0em}
\renewcommand{\cftsubfigindent}{2.25em}
%% Vertical skips for LoF entries
\renewcommand{\cftbeforefigskip}{12pt}
\renewcommand{\cftbeforesubfigskip}{8pt}
%% Customisation of subfig numbers in the LoF entries
\renewcommand{\cftsubfigpresnum}{[\hspace*{0.5mm}}
\renewcommand{\cftsubfigaftersnum}{{}.\hspace*{0.5mm}]}
%% Figure LoF entries in bold
\renewcommand{\cftfigfont}{\bfseries}
\renewcommand{\cftfigpagefont}{\bfseries}
\renewcommand{\cftfigleader}{\bfseries\cftdotfill{\cftfigdotsep}}
%% To switch-off page numbers of subfigure LoF entries
\cftpagenumbersoff{subfigure}
\begin{document}
\tableofcontents
\cleardoublepage
\listoffigures
\cleardoublepage
\listoftables
\cleardoublepage
\chapter{CHAPTER 1}
\begin{figure}[!ht]
\vspace*{-20pt}
\centering
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{First SUB-FLOAT}
%\label{fig:demo1}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{Second SUB-FLOAT}
%\label{fig:demo2}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{Third SUB-FLOAT}
%\label{fig:demo3}
\end{subfigure}
\caption{Demo Figure 1}
\end{figure}
\cleardoublepage
\section{Section 1}
\begin{table}[h]
\begin{center}
\vspace*{1.5in}
\scalebox{1.25}{
\begin{tabular}{|c|c|}
\hline
Mineral & Color \\
\hline
\hline
Ruby & red \\
\hline
\hline
Sapphire & blue \\
\hline
\end{tabular}
}
\end{center}
\caption{Demo Table 1}
\vspace*{50pt}
\end{table}
\subsection{Subsection 1}
\begin{figure}[!ht]
\vspace*{-20pt}
\centering
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption[]{} %% captionless subfigure
%\label{fig:demo1}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption[]{} %% captionless subfigure
%\label{fig:demo2}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption[]{} %% captionless subfigure
%\label{fig:demo3}
\end{subfigure}
\caption{Demo Figure 2}
\end{figure}
\cleardoublepage
\chapter{CHAPTER 2}
\begin{figure}[!ht]
\vspace*{-20pt}
\centering
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{First SUB-FLOAT}
%\label{fig:demo1}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{Second SUB-FLOAT}
%\label{fig:demo2}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{Third SUB-FLOAT}
%\label{fig:demo3}
\end{subfigure}
\caption{Demo Figure 3}
\end{figure}
\cleardoublepage
\section{Section 2}
\begin{table}[h]
\begin{center}
\vspace*{1.5in}
\scalebox{1.25}{
\begin{tabular}{|c|c|}
\hline
Fruit & Color \\
\hline
\hline
Apple & red \\
\hline
\hline
Banana & Yellow \\
\hline
\end{tabular}
}
\end{center}
\caption{Demo Table 2}
\vspace*{50pt}
\end{table}
\subsection{Subsection 2}
\cleardoublepage
\end{document}
从前导码中删除tocloft
添加的垂直跳过(见下文)不会改变此代码的观察到的行为!
%% Vertical skips for LoF entries
\renewcommand{\cftbeforefigskip}{12pt}
\renewcommand{\cftbeforesubfigskip}{8pt}
笔记: 这可能看起来像一个重复的问题,但类似问题的解决方案在这种情况下并不真正有用。建议的解决方案 这里 经过 @barbara-beeton 是基于
ams
文档类也是错误的,在问题关闭后没有找到解决方案;而给出的解决方案 这里 经过 @steven-b-segletes 基于删除所有appendix
相关的图表,因此不适用于本案。
任何帮助都将不胜感激。谢谢!
更新:这只是供您参考,我找到了另一种方法,可以排除某个图/子图/表格,无论出于何种原因,而不会影响其他条目。\captionsetup[<float-type>]{list=no} %% <float-type> = figure/subfigure/table
在您想要排除的图之前添加,然后在该图之后将其恢复,然后\captionsetup[<float-type>]{list=yes}
,瞧!它就从列表中消失了!(来源:从图表列表/表格列表中排除项目)
答案1
report
和的标准行为book
是在图表列表中用垂直空间分隔属于不同章节的项目,这就是您看到的空间。
如果您想要一个没有这种分离的紧密的数字列表,那么很容易进行修补\chapter
:
\usepackage{etoolbox}
%% remove the \addvspace{10\p@} in LOF and LOT
\makeatletter
\patchcmd{\@chapter}
{\addtocontents{lof}{\protect\addvspace{10\p@}}}% tokens to search
{}% tokens to replace
{}{}
\patchcmd{\@chapter}
{\addtocontents{lot}{\protect\addvspace{10\p@}}}% tokens to search
{}% tokens to replace
{}{}
\makeatother
完整代码
\documentclass[a4paper,oneside]{report}
\usepackage{etoolbox} %% for patching commands
\usepackage[demo]{graphicx} %% To get demo figures
\usepackage{showframe} %% Shows the actual page layout
\usepackage[list=true]{subcaption} %% alternative for subfigure
%% To get subfloats listed in list of figures, you
%% must load the subcaption package with [list=true]
%% option!
%%\usepackage{subfigure} %% deprecated package!
\usepackage[subfigure]{tocloft} %% A trick for tocloft+subcaption combo.
%% This option is required if, and only if,
%% the tocloft and subfigure packages are being used
%% together. The two packages can be specifed in any
%% order. - From the tocloft package documentation
%% (dated 2013/05/02)
\newcounter{lofdepth} %% Declare new LoF depth counter
\newcounter{lotdepth} %% Declare new LoT depth counter
\setcounter{lofdepth}{2} %% Set new LoF depth counter to include subfigures
%%\setcounter{lofdepth}{1} %% If subfigures are't needed in LoF
%% Adding horizontal space between LoF numbers and entry text
\renewcommand{\cftfignumwidth}{1in} %% Exaggerated width!
\renewcommand{\cftsubfignumwidth}{1in} %% Exaggerated width!
%% Indentation for LoF entry numbers
\renewcommand{\cftfigindent}{0em}
\renewcommand{\cftsubfigindent}{2.25em}
%% Vertical skips for LoF entries
\renewcommand{\cftbeforefigskip}{12pt}
\renewcommand{\cftbeforesubfigskip}{8pt}
%% Customisation of subfig numbers in the LoF entries
\renewcommand{\cftsubfigpresnum}{[\hspace*{0.5mm}}
\renewcommand{\cftsubfigaftersnum}{{}.\hspace*{0.5mm}]}
%% Figure LoF entries in bold
\renewcommand{\cftfigfont}{\bfseries}
\renewcommand{\cftfigpagefont}{\bfseries}
\renewcommand{\cftfigleader}{\bfseries\cftdotfill{\cftfigdotsep}}
%% To switch-off page numbers of subfigure LoF entries
\cftpagenumbersoff{subfigure}
%% remove the \addvspace{10\p@} in LOF and LOT
\makeatletter
\patchcmd{\@chapter}
{\addtocontents{lof}{\protect\addvspace{10\p@}}}% tokens to search
{}% tokens to replace
{}{}
\patchcmd{\@chapter}
{\addtocontents{lot}{\protect\addvspace{10\p@}}}% tokens to search
{}% tokens to replace
{}{}
\makeatother
\begin{document}
\tableofcontents
\cleardoublepage
\listoffigures
\cleardoublepage
\listoftables
\cleardoublepage
\chapter{CHAPTER 1}
\begin{figure}[!ht]
\vspace*{-20pt}
\centering
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{First SUB-FLOAT}
%\label{fig:demo1}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{Second SUB-FLOAT}
%\label{fig:demo2}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{Third SUB-FLOAT}
%\label{fig:demo3}
\end{subfigure}
\caption{Demo Figure 1}
\end{figure}
\cleardoublepage
\section{Section 1}
\begin{table}[h]
\begin{center}
\vspace*{1.5in}
\scalebox{1.25}{
\begin{tabular}{|c|c|}
\hline
Mineral & Color \\
\hline
\hline
Ruby & red \\
\hline
\hline
Sapphire & blue \\
\hline
\end{tabular}
}
\end{center}
\caption{Demo Table 1}
\vspace*{50pt}
\end{table}
\subsection{Subsection 1}
\begin{figure}[!ht]
\vspace*{-20pt}
\centering
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption[]{} %% captionless subfigure
%\label{fig:demo1}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption[]{} %% captionless subfigure
%\label{fig:demo2}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption[]{} %% captionless subfigure
%\label{fig:demo3}
\end{subfigure}
\caption{Demo Figure 2}
\end{figure}
\cleardoublepage
\chapter{CHAPTER 2}
\begin{figure}[!ht]
\vspace*{-20pt}
\centering
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{First SUB-FLOAT}
%\label{fig:demo1}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{Second SUB-FLOAT}
%\label{fig:demo2}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\centering
\caption{Third SUB-FLOAT}
%\label{fig:demo3}
\end{subfigure}
\caption{Demo Figure 3}
\end{figure}
\cleardoublepage
\section{Section 2}
\begin{table}[h]
\begin{center}
\vspace*{1.5in}
\scalebox{1.25}{
\begin{tabular}{|c|c|}
\hline
Fruit & Color \\
\hline
\hline
Apple & red \\
\hline
\hline
Banana & Yellow \\
\hline
\end{tabular}
}
\end{center}
\caption{Demo Table 2}
\vspace*{50pt}
\end{table}
\subsection{Subsection 2}
\cleardoublepage
\end{document}