6

I want to change the appearance of my listoffigures, listoftables, and listofschemes with KOMA script commands.

I use the scheme environment from the chemmacros package.

Here is my 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}  

While

\DeclareTOCStyleEntry[indent=0em,numwidth=2.3em]{dottedtocline}{figure}

works nice for figures and tables (not shown), trying to do the same for the scheme environment results in the following error:

! 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.

According to the chemmacros documentation, the scheme environment should be compatible with KOMA script, so I wonder what causes the error in the .log file.

The output is also not consistent, as the listoffigures is formatted according to the commands, while the listofschemes is still starting with an indent, see pictures below: enter image description here enter image description here

Any ideas how to solve this formatting issue?

3

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:

enter image description here

  • Thanks @esdd, seems like the solution was already in the code and I just didn't saw the analogy... Now it works like a charm, so thx for that! – Manuel Aug 30 '19 at 14:17
2

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:

resulting scheme list

Please see: That is only a workaround, the maintainer should be asked to correct the package!

  • Package chemmacros does not have a problem with a tocbasic version. – esdd Aug 29 '19 at 21:50
  • Additionally a new list defined by \DeclareNewTOC gets owner=float by default. So it uses the same settings as LOF and LOT (listof=... or chapteratlist) automatically. – esdd Aug 29 '19 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.