
Как указано в§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}