# (toc)dynnumwidth not working reliably in KOMA-Script

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

\end{document}


Output:

test_2.tex:

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

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

\begin{document}
\tableofcontents

\end{document}


Output:

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.

• 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. Nov 17 '16 at 19:51
• 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