6

According to the KOMA-Script documentation, the option dynnumwidth in the tocbasic-style toclines (which is the template for the styles used by KOMA-Script’s sectioning commands in the table of contents) does the following:

dynnumwidth=switch: If the switch is active with style tocline, attribute numwidth is ignored. Instead of that the maximum number width detected at the previous LaTeX run increased by the value of numsep is used.

However, detection of the maximum number width does not seem to work reliably. Consider the two following MWE:

test_1.tex:

\documentclass[american]{scrartcl}
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\RedeclareSectionCommands[tocdynnumwidth]{section,subsection,subsubsection}

\begin{document}
    \tableofcontents

    \addsectiontocentry{Nr.~1}{Test1}
    \addsectiontocentry{Nr.~2}{Test2}
    \addsectiontocentry{Nr.~3}{Test3}
    \addsectiontocentry{Number~4}{Test4 (long)}
\end{document}

Output:

First MWE: <code>dynnumwidth</code> broken

test_2.tex:

\documentclass[american]{scrartcl}
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\RedeclareSectionCommands[tocdynnumwidth]{section,subsection,subsubsection}

\begin{document}
    \tableofcontents

    \addsectiontocentry{Nr.~1}{Test1}
    \addsectiontocentry{Nr.~2}{Test2}
    \addsectiontocentry{Number~3}{Test3 (long)}
    \addsectiontocentry{Number~4}{Test4 (long)}
\end{document}

Output:

Second MWE: <code>dynnumwidth</code> working

So if I have three or more entries with short number widths, dynnumwidth does not detect the longer entry and chooses a numwidth value that is too small (MWE 1). On the other hand, with two short and two long number width entries, the correct numwidth is determined (MWE 2). Is this a bug or am I using dynnumwidth incorrectly?

I’m using TeX Live 2016/KOMA-Script v3.21.

3
  • 2
    Looks like a bug to me -- I get the same with three short sections and one large (after \setcounter{section}{9999}). Make a bug report. Nov 16 '16 at 7:57
  • Thanks for the input. Made a bug report, will update when the author gets to this one.
    – Socob
    Nov 17 '16 at 19:51
  • 1
    The bug will be fixed in the next KOMA-Script version 3.22. The bugfix can already be used with prerelease v3.22.2559, which can be installed from komascript.de/node/1801.
    – esdd
    Dec 5 '16 at 8:08
6

I made a bug report to KOMA-Script author Markus Kohm, who has confirmed that this is not working as intended.

As mentioned by esdd, the bug has been fixed in prerelease v3.22.2559. From the changelog:

r2559 2016-12-02 09:03:11 +0100 kohm:

  • scrkernel-tocstyle.dtx: missing \relax added to fix dynnumwidth
    feature

so it will be gone in KOMA-Script release v3.22.

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.