我想自定义我的 ToC,并了解到该软件包tocloft
不适合与 KOMA-Script 结合使用。使用该软件包时,tocstyle
我还收到有关版本冲突的警告。
因为我认为我的调整不太复杂,所以也许没有这样的包也可以做到,但是我不知道该怎么做。
- 我希望目录的格式与章节、节和小节样式相同。因此左边距中的数字和右侧正文中的名称对齐。(参见 MWE 和图片)
有人知道吗?
\documentclass{scrreprt}
\usepackage[
includemp,
showframe,
reversemp,
paperwidth=20.1cm,
paperheight=25.80cm,
top=2.30cm,
bottom=3.4cm,
inner=2.7cm,
outer=2.7cm,
marginparwidth=1.6cm, % Fixed for now
marginparsep=0.4cm
]{geometry}
\usepackage{lipsum}
% \usepackage{tocloft}
\makeatletter % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother
\renewcommand*{\chapterformat}{\makebox[0pt][r]{\chapappifchapterprefix{\
}\thechapter\autodot\hskip\marginparsep}}%
\renewcommand*{\sectionformat}{\makebox[0pt][r]
{\thesection\autodot\hskip\marginparsep}}
\renewcommand*{\subsectionformat}{\makebox[0pt][r]
{\thesubsection\autodot\hskip\marginparsep}}
\renewcommand*{\subsubsectionformat}{\makebox[0pt][r]
{\thesubsubsection\autodot\hskip\marginparsep}}
% remove the vertical skip before the chapter heading
\RedeclareSectionCommand[beforeskip=-1sp plus -1sp minus 1sp]{chapter}
\usepackage[footwidth=textwithmarginpar]{scrlayer-scrpage}
\begin{document}
\clearpairofpagestyles
\automark{chapter}
\ifoot{%
\makebox[0pt][r]{\pagemark\autodot\hskip\marginparsep}%
\ifodd \value{page}%
Quantifying goodness of morphodynamic field predictions
\else
\headmark %
\fi
}
\setkomafont{pageheadfoot}{\normalfont}
\renewcommand\chaptermarkformat{}
\renewcommand*\chapterpagestyle{scrheadings}
\tableofcontents
\chapter{chapter}
\lipsum[2]
\section{section}
\lipsum[2]
\subsection{subsection}
\lipsum[2]
\end{document}
答案1
您可以对目录条目执行与标题几乎相同的操作:
\documentclass{scrreprt}
\usepackage[
includemp,
showframe,
reversemp,
paperwidth=20.1cm,
paperheight=25.80cm,
top=2.30cm,
bottom=3.4cm,
inner=2.7cm,
outer=2.7cm,
marginparwidth=1.6cm, % Fixed for now
marginparsep=0.4cm
]{geometry}
\usepackage{lipsum}
% \usepackage{tocloft}
\makeatletter % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother
\renewcommand*{\chapterformat}{\intoleftmargin{\chapappifchapterprefix{\
}\thechapter\autodot}}%
\renewcommand*{\sectionformat}{\intoleftmargin{\thesection\autodot}}
\renewcommand*{\subsectionformat}{\intoleftmargin{\thesubsection\autodot}}
\renewcommand*{\subsubsectionformat}{\intoleftmargin{\thesubsubsection\autodot}}
% remove the vertical skip before the chapter heading
\RedeclareSectionCommand[beforeskip=-1sp plus -1sp minus 1sp]{chapter}
\RedeclareSectionCommands[tocnumwidth=0pt,tocindent=0pt,tocentrynumberformat=\intoleftmargin]{chapter,section,subsection,subsubsection}
\newcommand*{\intoleftmargin}[1]{\makebox[0pt][r]{#1\hskip\marginparsep}}
\usepackage[footwidth=textwithmarginpar]{scrlayer-scrpage}
\begin{document}
\clearpairofpagestyles
\automark{chapter}
\ifoot{%
\makebox[0pt][r]{\pagemark\autodot\hskip\marginparsep}%
\ifodd \value{page}%
Quantifying goodness of morphodynamic field predictions
\else
\headmark %
\fi
}
\setkomafont{pageheadfoot}{\normalfont}
\renewcommand\chaptermarkformat{}
\renewcommand*\chapterpagestyle{scrheadings}
\tableofcontents
\chapter{chapter}
\lipsum[2]
\section{section}
\lipsum[2]
\subsection{subsection}
\lipsum[2]
\end{document}
有关更多信息\RedeclareSectionCommand
tocnumwidth
以及像、tocindent
和 这样的选项(它们是命令样式的tocentrynumberformat
选项numwidth
、indent
和entrynumberformat
tocline
\DeclareTOCStyleEntry
) 看英文版 KOMA-Script 手册或者德语 KOMA-Script 手册甚至德语 KOMA-Script 书。