\listofschemes from chemmacros not working with KOMA script commands
Package chemmacros
checkes at begin document if a KOMA-Script class is used or if package tocbasic
is loaded manually (with another class). Then it defines the new list for the schemes
using \DeclareNewTOC
. So you have to defer the change of indent
and numwidth
for TOC entries scheme
using \AtBeginDocument
, too.
Use
\AtBeginDocument{\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{default}{scheme}}
to ensure that scheme
is already defined by chemmacros
when you change its indent
and numwidth
. Note that you do the same for your redefinition of \thescheme
.
Example:
\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}
Result:
Well, it seems that chemmacros
(2017) is based on an meanwhile changed version of tocbasic
of KOMA-Script.
You should contact the maintainer of chemmacros
and write an bug report (if you want you can use this question/answer as example).
A quick workaround can be to simply add the following lines in your preamble (please see important code changes marked with <=========
):
\DeclareNewTOC[% <======================================================
type=scheme,%
types=schemes,%
float,% Gleitumgebungen sollen definiert werden.
floattype=4,%
name=Scheme,%
listname={List of schemes}%
]{scheme}
\setuptoc{scheme}{chapteratlist} % <====================================
So with the complete 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}
I get the following resulting scheme list:
Please see: That is only a workaround, the maintainer should be asked to correct the package!