我想使用 KOMA 脚本命令改变我的 listoffigures、listoftables 和 listofschemes 的外观。
我使用 chemmacros 包中的方案环境。
这是我的 MWE:
\documentclass[fontsize=10pt,
twoside,
paper=b5,
pagesize=auto,
numbers=noenddot, % Removes ending point after heading- and caption numbers.
toc=bibliography, % Includes bibliography into ToC but without numbering it.
listof=totoc, % Includes all lists (figures, etc.) into ToC but without numbering.
open=right, % Start new chapters on a right page (doublepage layout).
singlespacing=true, % KOMA-script. p 450ff. setspace only in textbody.
chapterprefix=true,
appendixprefix=true
]{scrreprt}
%
\usepackage{scrhack} % Patches for KOMA-script.
\usepackage[american]{babel}
\usepackage{amsmath}
\usepackage[final,tracking=true]{microtype}
\usepackage{fontspec}
\defaultfontfeatures{
Ligatures = TeX ,
RawFeature={+calt} ,
SmallCapsFeatures={Letters=SmallCaps}
}
\usepackage[math-style=ISO,
bold-style=ISO]{unicode-math}
\usepackage{libertinus}
%
\usepackage{blindtext}
%
%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{float}
\usepackage{chemmacros}
\usechemmodule{mechanisms,%
redox,%
spectroscopy,%
units,%
scheme}
\AtBeginDocument{\renewcommand{\thescheme}{\arabic{chapter}.\arabic{scheme}}}
%%%%%%%%%%%%%%%%%%%%%%%%
%
\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{dottedtocline}{figure}
\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{dottedtocline}{scheme}
%
%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%
\blindtext
%
\begin{figure}[H]
\caption{blabla}
\label{fig:1}
\end{figure}
\begin{figure}[H]
\caption{blabla}
\label{fig:2}
\end{figure}
\begin{figure}[H]
\caption{blabla}
\label{fig:3}
\end{figure}
\begin{figure}[H]
\caption{blabla}
\label{fig:4}
\end{figure}
%
\blindtext
%
\begin{scheme}[H]
\caption{blabla}
\label{scheme:1}
\end{scheme}
\begin{scheme}[H]
\caption{blabla}
\label{scheme:2}
\end{scheme}
\begin{scheme}[H]
\caption{blabla}
\label{scheme:3}
\end{scheme}
\begin{scheme}[H]
\caption{blabla}
\label{scheme:4}
\end{scheme}
%
\blindtext
%
\listoffigures
\listofschemes
%
\end{document}
尽管
\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{dottedtocline}{figure}
对于图形和表格(未显示)来说效果很好,尝试对方案环境执行相同操作会导致以下错误:
! Package tocbasic Error: toc style `dottedtocline' needs toc entry level.
See the tocbasic package documentation for explanation.
Type H <return> for immediate help.
...
l.42 ...t=0em,numwidth=2.3em]{dottedtocline}{scheme}
Usually the toc entry level is defined using option `level'.
In some cases it may be set defining command `\schemetocdepth'.
If you'll continue, I'll ignore the command. This could result in
further error messages.
根据 chemmacros 文档,方案环境应该与 KOMA 脚本兼容,所以我想知道是什么导致了 .log 文件中的错误。
输出也不一致,因为 listoffigures 是根据命令格式化的,而 listofschemes 仍然以缩进开始,见下图:
有什么想法可以解决这个格式问题吗?
答案1
包chemmacros
在文档开始时检查是否使用了 KOMA-Script 类或是否手动加载了包(使用另一个类)。然后它为using tocbasic
定义新列表。因此,您也必须推迟对 TOC 条目using 的和的更改。schemes
\DeclareNewTOC
indent
numwidth
scheme
\AtBeginDocument
使用
\AtBeginDocument{\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{default}{scheme}}
确保在更改其和时scheme
已由定义。请注意,对的重新定义也执行相同操作。chemmacros
indent
numwidth
\thescheme
例子:
\documentclass[fontsize=10pt,
twoside,
paper=b5,
pagesize=auto,
numbers=noenddot,
toc=bibliography,
listof=totoc,
open=right,
%singlespacing=true,% not used in the example
chapterprefix=true,
appendixprefix=true
]{scrreprt}
%
\usepackage{scrhack}% Patches for KOMA-script.
\usepackage[american]{babel}
%
\usepackage{blindtext}% only for dummy text
%
%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{float}
\usepackage{chemmacros}
\usechemmodule{mechanisms,%
redox,%
spectroscopy,%
units,%
scheme}
\AtBeginDocument{%
\renewcommand{\thescheme}{\arabic{chapter}.\arabic{scheme}}%
\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{default}{scheme}% <- moved
}
%
\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{default}{figure}
%
\begin{document}
\chapter{A chapter}
\blindtext
\begin{figure}[H]
\caption{blabla}
\label{fig:1}
\end{figure}
\begin{figure}[H]
\caption{blabla}
\label{fig:2}
\end{figure}
\begin{figure}[H]
\caption{blabla}
\label{fig:3}
\end{figure}
\begin{figure}[H]
\caption{blabla}
\label{fig:4}
\end{figure}
\blindtext
\begin{scheme}[H]
\caption{blabla}
\label{scheme:1}
\end{scheme}
\chapter{Another chapter}
\begin{scheme}[H]
\caption{blabla}
\label{scheme:2}
\end{scheme}
\begin{scheme}[H]
\caption{blabla}
\label{scheme:3}
\end{scheme}
\begin{scheme}[H]
\caption{blabla}
\label{scheme:4}
\end{scheme}
%
\blindtext
\listoffigures
\listofschemes
\end{document}
结果:
答案2
嗯,看来chemmacros
(2017) 是基于tocbasic
KOMA-Script 的现有版本。
您应该联系维护者chemmacros
并写一份错误报告(如果您愿意,您可以使用这个问题/答案作为示例)。
一个快速的解决方法是简单地在序言中添加以下几行(请参阅标有 的重要代码更改<=========
):
\DeclareNewTOC[% <======================================================
type=scheme,%
types=schemes,%
float,% Gleitumgebungen sollen definiert werden.
floattype=4,%
name=Scheme,%
listname={List of schemes}%
]{scheme}
\setuptoc{scheme}{chapteratlist} % <====================================
因此,有了完整的 MWE
\documentclass[%
fontsize=10pt,
twoside,
paper=b5,
pagesize=auto,
numbers=noenddot, % Removes ending point after heading- and caption numbers.
toc=bibliography, % Includes bibliography into ToC but without numbering it.
listof=totoc, % Includes all lists (figures, etc.) into ToC but without numbering.
open=right, % Start new chapters on a right page (doublepage layout).
singlespacing=true, % KOMA-script. p 450ff. setspace only in textbody.
chapterprefix=true,
appendixprefix=true
]{scrreprt}
%
\usepackage{scrhack} % Patches for KOMA-script.
\usepackage[american]{babel}
\usepackage{amsmath}
%\usepackage[final,tracking=true]{microtype} % <================================
\usepackage{fontspec}
\defaultfontfeatures{
Ligatures = TeX ,
RawFeature={+calt} ,
SmallCapsFeatures={Letters=SmallCaps}
}
\usepackage[math-style=ISO,
bold-style=ISO]{unicode-math}
\usepackage{libertinus}
%
\usepackage{blindtext}
%
%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{float}
\usepackage[compatibility=newest]{chemmacros} % <=======================
\usechemmodule{%
mechanisms,%
redox,%
spectroscopy,%
units,%
scheme
}
\AtBeginDocument{\renewcommand{\thescheme}{\arabic{chapter}.\arabic{scheme}}}
%%%%%%%%%%%%%%%%%%%%%%%%
%
\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{dottedtocline}{figure}
\DeclareNewTOC[% <======================================================
type=scheme,%
types=schemes,%
float,% Gleitumgebungen sollen definiert werden.
floattype=4,%
name=Scheme,%
listname={List of schemes}%
]{scheme}
\setuptoc{scheme}{chapteratlist} % <====================================
\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{dottedtocline}{scheme}
%
%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%
\blindtext
%
\begin{figure}[H]
\caption{blabla}
\label{fig:1}
\end{figure}
\begin{figure}[H]
\caption{blabla}
\label{fig:2}
\end{figure}
\begin{figure}[H]
\caption{blabla}
\label{fig:3}
\end{figure}
\begin{figure}[H]
\caption{blabla}
\label{fig:4}
\end{figure}
%
\blindtext
%
\begin{scheme}[H]
\caption{blabla}
\label{scheme:1}
\end{scheme}
\begin{scheme}[H]
\caption{blabla}
\label{scheme:2}
\end{scheme}
\begin{scheme}[H]
\caption{blabla}
\label{scheme:3}
\end{scheme}
\begin{scheme}[H]
\caption{blabla}
\label{scheme:4}
\end{scheme}
%
\blindtext
%
\listoffigures
\listofschemes
%
\end{document}
我得到以下结果方案列表:
请参见:这只是一个解决办法, 应该要求维护者修正该软件包!