
如指定§3.20。表格和圖形的浮動環境第 128 頁KOMA 腳本文檔,可以新增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 中的章節?,在帶有標題的圖表列表中包含章節?)。但是,它們適用於標準類別 ( 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}