如§3.20. 表格和图形的浮动环境第 128 页KOMA-Script 文档,可以添加listof=withchapterentry
选项
标记章节从浮动环境列表开始,通过将其条目复制到目录中。
即在属于本章的图形上方添加章节标题:
List of Figure
Chapter 1
1.1 My first figure.......................13
1.2 My second figure......................17
Chapter 42
42.1 My last figure.......................210
问题:当我使用该类时scrbook
,我想做的是模拟相同的行为,但使用部分标题而不是章节标题。即创建选项listof=withpartentry
。
(我只需要显示部分标题,而不是章节标题)
我怎样才能做到这一点?
有些问题已经处理了这个问题(例如,LoF 和 LoT 里面的章节?,是否在带有 titletoc 的图表列表中包含章节?)。但是,它们是为标准类设计的(book
)。我认为可以避免使用“肮脏”的解决方法,scrbook
因为该功能已在章节中实现。
答案1
您可以进行修补\addparttocentry
以获取 LOF 和 LOT 中每个部分的条目:
\documentclass{scrbook}
\unsettoc{lof}{chapteratlist}% remove the chapter gap in LOF
\unsettoc{lot}{chapteratlist}% % remove the chapter gap in LOT
\usepackage{xpatch}
\xapptocmd\addparttocentry{%
\addxcontentsline{lof}{part}[{#1}]{#2}% copy the part entry to LOF
\addxcontentsline{lot}{part}[{#1}]{#2}% copy the part entry to LOT
}{}{\PatchFailed}
\begin{document}
\listoffigures
\part{Part One}
\chapter{Chapter One}
\captionof{figure}{My first figure}
\captionof{figure}{My second figure}
\chapter{Chapter Two}
\captionof{figure}{A figure in Chapter Two}
\part{Part Two}
\chapter{Chapter Three}
\captionof{figure}{My next figure}
\chapter{Chapter Four}
\addpart{Unnumbered Part}
\chapter{Chapter Five}
\captionof{figure}{My last figure}
\end{document}
或者在由包控制的所有列表中tocbasic
:
\documentclass[listof=ignorechapter]{scrbook}
\usepackage{xpatch}
\makeatletter
\xapptocmd\addparttocentry{%
\doforeachtocfile{%
\ifstr{\@currext}{toc}{}{%
\addxcontentsline{\@currext}{part}[{#1}]{#2}%
}%
}%
}{}{\PatchFailed}
\makeatother
\begin{document}
\listoffigures
\part{Part One}
\chapter{Chapter One}
\captionof{figure}{My first figure}
\captionof{figure}{My second figure}
\chapter{Chapter Two}
\captionof{figure}{A figure in Chapter Two}
\part{Part Two}
\chapter{Chapter Three}
\captionof{figure}{My next figure}
\chapter{Chapter Four}
\addpart{Unnumbered Part}
\chapter{Chapter Five}
\captionof{figure}{My last figure}
\end{document}
结果:
还可以为列表中的部分条目声明一种新样式。示例:没有部分条目的页码:
\documentclass[listof=ignorechapter]{scrbook}
\usepackage{xpatch}
\makeatletter
\xapptocmd\addparttocentry{%
\doforeachtocfile{%
\ifstr{\@currext}{toc}{}{%
\addxcontentsline{\@currext}{partatlists}[{#1}]{#2}%
}%
}%
}{}{\PatchFailed}
\DeclareTOCStyleEntry[
pagenumberbox=\@gobble,
level=-1,
indent=0pt,
numwidth=0pt,
dynnumwidth
]{part}{partatlists}
\makeatother
\begin{document}
\listoffigures
\part{Part One}
\chapter{Chapter One}
\captionof{figure}{My first figure}
\captionof{figure}{My second figure}
\chapter{Chapter Two}
\captionof{figure}{A figure in Chapter Two}
\part{Part Two}
\chapter{Chapter Three}
\captionof{figure}{My next figure}
\chapter{Chapter Four}
\addpart{Unnumbered Part}
\chapter{Chapter Five}
\captionof{figure}{My last figure}
\end{document}