我想将所有目录条目的字体更改为\sffamily
。对于常规目录,我通过使用以下方法实现了此目的:
\setkomafont{disposition}{\sffamily\bfseries}
\DeclareTOCStyleEntries[%
entryformat=\sffamily,
pagenumberformat=\sffamily
]{section}{section,subsection}
然而,算法列表(\listofalgorithms
)中的条目并没有因此而改变。
我正在使用scrbook
和algorithm2e
。
完整示例:
\documentclass{scrbook}
\title{A Sample Thesis}
\author{A.N. Other}
\usepackage{algorithm2e}
\setkomafont{disposition}{\sffamily\bfseries}
\DeclareTOCStyleEntries[%
entryformat=\sffamily,
pagenumberformat=\sffamily
]{section}{section,subsection}
\begin{document}
\maketitle
\frontmatter
\tableofcontents
\listofalgorithms
\chapter{Abstract}
This is the abstract
\mainmatter
\section{This is a section}
\begin{algorithm}[H]
Algorithm
\end{algorithm}
\end{document}
算法列表没有留下深刻印象:
答案1
您必须将其声明algocf
为 KOMA-Script »TOC Style Entry«:
\documentclass{scrbook}
\title{A Sample Thesis}
\author{A.N. Other}
\usepackage{algorithm2e}
\setkomafont{disposition}{\sffamily\bfseries}
\DeclareTOCStyleEntry[
level=1,
indent=1.5em,
numwidth=2.3em
]{default}{algocf}
\DeclareTOCStyleEntries[
entryformat=\sffamily,
pagenumberformat=\sffamily
]{default}{section,subsection,algocf}
\begin{document}
\maketitle
\frontmatter
\tableofcontents
\listofalgorithms
\chapter{Abstract}
This is the abstract
\mainmatter
\section{This is a section}
\begin{algorithm}[H]
\caption{An Algorithm}
Algorithm
\end{algorithm}
\end{document}
结果:
关于下面评论中的问题:
包listings
使用入门级lstlisting
。如果lstlisting
应该获得与使用相同的格式algocf
:
\DeclareTOCStyleEntries[% ...Entry replaced by ...Entries
level=1,
indent=1.5em,
numwidth=2.3em
]{default}{algocf,lstlisting}% <- lstlisting added
\DeclareTOCStyleEntries[
entryformat=\sffamily,
pagenumberformat=\sffamily
]{default}{section,subsection,algocf,lstlisting}% lstlisting added
例子:
\documentclass{scrbook}
\title{A Sample Thesis}
\author{A.N. Other}
\usepackage{algorithm2e}
\usepackage{listings}
\usepackage{scrhack}
\setkomafont{disposition}{\sffamily\bfseries}
\DeclareTOCStyleEntries[
level=1,
indent=1.5em,
numwidth=2.3em
]{default}{algocf,lstlisting}
\DeclareTOCStyleEntries[
entryformat=\sffamily,
pagenumberformat=\sffamily
]{default}{section,subsection,algocf,lstlisting}
\begin{document}
\maketitle
\frontmatter
\tableofcontents
\listofalgorithms
\lstlistoflistings
\chapter{Abstract}
This is the abstract
\mainmatter
\section{This is a section}
\begin{algorithm}[H]
\caption{An Algorithm}
Algorithm
\end{algorithm}
\chapter{Code}
\begin{lstlisting}[caption={A code example}]
Code
\end{lstlisting}
\end{document}
结果: