我使用以下命令为一些浮点数声明了自定义目录:
\documentclass{scrartcl}
\DeclareNewTOC[%
type=questiona,%
name=table,%
float,%
listname={Question Overview},%
tocentrydynnumwidth% <- added
]{qua}
\usepackage{blindtext}
\begin{document}
\blindtext
\listoftoc{qua}
\pagenumbering{roman}
\setcounter{page}{223}
\captionof{questiona}{First Caption with very long text that keeps moving and moving and there is still no end to see}
\setcounter{questiona}{49}
\captionof{questiona}{Foo}
\setcounter{questiona}{999}
\captionof{questiona}{Bar}
\end{document}
我的目录中有很多条目(>50)。条目页码是罗马数字,因此页码宽度可能非常宽。我遇到的问题是目录页码现在与文本宽度重叠,我找不到任何开关来适当地更改它。
有没有办法可以自动计算正确的数字宽度或手动调整值以达到我的目的?
答案1
更新(因为问题已经改变)
你可以重新定义 和\@pnumwidth
和\@tocrmargin
。例如:
\makeatletter
\renewcommand*\@pnumwidth{3em}% default: 1.55em
\renewcommand*\@tocrmarg{4em}% default: 2.55em
\makeatother
要将此更改限制在“问题概述”中使用
\makeatletter
\AfterTOCHead[qua]{%
\renewcommand*\@pnumwidth{3em}% default: 1.55em
\renewcommand*\@tocrmarg{4em}% default: 2.55em
}
\makeatother
例子:
\documentclass{scrartcl}
\DeclareNewTOC[%
type=questiona,%
name=table,%
float,%
listname={Question Overview},%
tocentrydynnumwidth%
]{qua}
\makeatletter
\AfterTOCHead[qua]{%
\renewcommand*\@pnumwidth{3em}% default: 1.55em
\renewcommand*\@tocrmarg{4em}% default: 2.55em
}
\makeatother
\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\section{A section}
\subsection{A subsection}
\blindtext
\listoftoc{qua}
\cleardoublepage
\pagenumbering{roman}
\captionof{questiona}{A caption}
\cleardoublepage
\setcounter{page}{223}
\captionof{questiona}{First Caption with very long text that keeps moving and moving and there is still no end to see}
\setcounter{questiona}{49}
\captionof{questiona}{Foo}
\setcounter{questiona}{999}
\captionof{questiona}{Bar}
\end{document}
结果:
补充说明:KOMA-Script 3.27 版预发布提供新的选项
tocentrypagenumberwidth
和tocentryrightmargin
新声明的 TOC:
\documentclass{scrartcl}
\DeclareNewTOC[%
type=questiona,%
name=table,%
float,%
listname={Question Overview},%
tocentrydynnumwidth,
tocentrypagenumberbox=\mbox
]{qua}
\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\section{A section}
\subsection{A subsection}
\blindtext
\listoftoc{qua}
\cleardoublepage
\pagenumbering{roman}
\captionof{questiona}{A caption}
\cleardoublepage
\setcounter{page}{223}
\captionof{questiona}{First Caption with very long text that keeps moving and moving and there is still no end to see}
\setcounter{questiona}{49}
\captionof{questiona}{Foo}
\setcounter{questiona}{999}
\captionof{questiona}{Bar}
\end{document}
结果和上面一样。
原始答案:
您可以使用选项tocentrynumwidth=<length>
来调整数字的空间。但使用选项tocentrydynnumwidth
会自动计算所需的宽度。
例子:
\documentclass{scrartcl}
\DeclareNewTOC[%
type=questiona,%
name=table,%
float,%
listname={Question Overview},%
tocentrydynnumwidth% <- added
]{qua}
\begin{document}
\listoftoc{qua}
\captionof{questiona}{First Caption}
\setcounter{questiona}{49}
\captionof{questiona}{Foo}
\setcounter{questiona}{999}
\captionof{questiona}{Bar}
\end{document}
补充说明:仅当计算值大于 的值tocentrynumwidth
(默认为 2.3em)时才使用。因此,如果tocentrydynnumwidth
设置了选项, 的值tocentrynumwidth
就是数字的最小宽度。
% example needs prerelease of KOMA-Script 3.27 (see KOMA-Script website)
\documentclass{scrartcl}
\DeclareNewTOC[%
type=questiona,%
name=table,%
float,%
listname={Question Overview},%
tocentrydynnumwidth,
tocentrypagenumberwidth=10em,% default 1.55em
tocentryrightindent=4em,% default 2.55em
]{qua}
\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\section{A section}
\subsection{A subsection}
\blindtext
\listoftoc{qua}
\cleardoublepage
\pagenumbering{roman}
\captionof{questiona}{A caption}
\cleardoublepage
\setcounter{page}{223}
\captionof{questiona}{First Caption with very long text that keeps moving and moving and there is still no end to see}
\setcounter{questiona}{49}
\captionof{questiona}{Foo}
\setcounter{questiona}{999}
\captionof{questiona}{Bar}
\end{document}