Class scr… Warning: Usage of package `minitoc' … not recommended
When loading package minitoc, the KOMA-Script classes issue the warning:
Class scr… Warning: Usage of package `minitoc' together
(scr…) with a KOMA-Script class is not recommended.
(scr…) Nevertheless, using requested
(scr…) package `minitoc' on input line 10.
The reason for this warning is primarily that the package actually damages various options of KOMA-Script. To prevent this, KOMA-Script must in turn at least "reverse" the internal macro \stc@sect
of minitoc
. In addition, the definition of minitoc
(there as a redefinition of \@sect
) contains some bugs, for example a missing \expandafter
before \ifx\csname #1\endcsname\starsection
. Of course, the KOMA-Script author pointed out this error over 10 years ago.
Since it cannot be guaranteed that the internal definition in minitoc
will not change at some point, the changes to it within KOMA-Script are only executed if the definition from minitoc
v62 is found. Otherwise KOMA-Script will fail with its rescue attempt. The use of minitoc
with KOMA-Script classes is therefore always risky.
The minitoc
warning W0024:
Package minitoc(hints) Warning: W0049
(minitoc(hints)) You have attempted to insert
(minitoc(hints)) empty secttocs.
for example when using KOMA-Script option listof=totoc
is no reason for the above warning of the KOMA-Script classes. To eliminate it, the \minitoc
manual recommend the use of \mtcaddchapter
or \mtcaddsection
after \listoffigures
, \listoftables
etc. With KOMA-Script, however, this can also be solved in the document preamble:
\documentclass[listof=totoc]{scrartcl}
\AfterStartingTOC{%
\Iftocfeature{\csname @currext\endcsname}{totoc}
{\csname mtcaddsection\endcsname}% bei scrbook/scrreprt stattdessen mtcaddchapter
{}%
}
\usepackage{minitoc}
\begin{document}
\dosecttoc
\tableofcontents
\listoftables
\listoffigures
\section{Section}
\secttoc
\subsection{Subsection}
\end{document}
Here, \mtcaddsection
is automatically executed using \AfterStartingTOC
after reading in each TOC file for which the totoc
feature is set. \csname mtcaddsection\endcsname
is used in the code instead of \mtcaddsection
so that the code does not produce an error if someone throws out minitoc
.
Since the totoc
feature is explicitly tested, this also works if this feature is not set via the listof=totoc
option, but only for individual TOC files or for none at all. In the latter case, \mtcaddsection
is no longer executed.
The example does not include the leveldown
feature, which could of course also be tested for using \Iftocfeature
. For example, you could use the following code for scrbook
or scrreprt
:
\AfterStartingTOC{%
\Iftocfeature{\csname @currext\endcsname}{totoc}
{%
\Iftocfeature{\csname @currext\endcsname}{leveldown}
{\csname mtcaddsection\endcsname}{\csname mtcaddchapter\endcsname}%
}{}%
}
The reason why KOMA-Script does not automatically execute \mtcaddsection
or \mtcaddchapter
is because all documents that adhere to the minitoc
user manual would then be incorrect.
When using bibliography=totoc
or index=totoc
, a \mtcaddsection
or \mtcaddchapter
may also be necessary.