(toc)dynnumwidth 在 KOMA 腳本中無法可靠運作

(toc)dynnumwidth 在 KOMA 腳本中無法可靠運作

根據KOMA 腳本文檔, -styledynnumwidth中的選項(這是目錄中 KOMA-Script 的分段指令所使用的樣式的範本)執行以下操作:tocbasictoclines

dynnumwidth=switch:如果開關以 style 激活tocline,則屬性numwidth將被忽略。取而代之的是,使用上次 LaTeX 運行時檢測到的最大數字寬度,增加了 的值numsep

然而,最大數字寬度的檢測似乎並不可靠。考慮以下兩個 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}

輸出:

第一個 MWE:<code>dynnumwidth</code> 損壞

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}

輸出:

第二個 MWE:<code>dynnumwidth</code> 工作

因此,如果我有三個或更多數字寬度較短的條目,dynnumwidth則不會偵測較長的條目並選擇numwidth太小的值(MWE 1)。另一方面,透過兩個短數字寬度條目和兩個長數字寬度條目,numwidth可以確定正確性(MWE 2)。這是一個錯誤還是我使用dynnumwidth不當?

我正在使用 TeX Live 2016/KOMA-Script v3.21。

答案1

我向 KOMA-Script 作者 Markus Kohm 提交了一份錯誤報告,他已確認這沒有按預期工作。

正如所提到的靜電放電,該錯誤已修復預發布 v3.22.2559。從變更日誌:

r2559 2016-12-02 09:03:11 +0100 歐姆:

  • scrkernel-tocstyle.dtx:缺少 \relax 添加來修復 dynnumwidth
    功能

因此它將在 KOMA-Script v3.22 版本中消失。

相關內容