
我對 LaTeX 還很陌生。我正在寫一篇論文,我正在嘗試編輯我的目錄。我使用羅馬數字對零件進行編號。
不幸的是,在目錄中,羅馬數字 IV 之後的句號之前的間距太大(“IV”和“.”之後的間距比“I”和“.”之後的間距大)。有誰知道如何使其變小而不使其在其他羅馬數字(I、II 和 III)之前也變小?
\documentclass[11pt]{book}
\usepackage[]{titletoc}
\usepackage[newparttoc]{titlesec}
\titleformat{\part}[display]{}{\partname\nobreakspace\thepart}{0mm}{}
\titlecontents{part}
[0cm]
{}
{\hfil\normalfont\large\bfseries
\thecontentslabel\mdseries .\bfseries ~\hfil
\normalfont\large\bfseries}
{}
{\normalsize\dotfill\scriptsize\bfseries\thecontentspage}
[]
\begin{document}
\tableofcontents
\part{Part}
\part{Part}
\part{Part}
\part{Part}
\end{document}
答案1
問題是\thecontentslabel
和之間的字體發生變化,.
這意味著不會應用字距調整。
您可以做一些事情,測量包含 和 的框的寬度\bfseries\thecontentslabel.
,\bfseries\thecontentslabel\kern0pt.
並使用寬度的差異來手動調整零件號和句點之間的字距。
答案2
我找到了解決方案。它不漂亮,但很有效。
\documentclass[11pt]{book}
\usepackage[]{titletoc}
\usepackage[newparttoc]{titlesec}
\titleformat{\part}[display]{}{\partname\nobreakspace\thepart}{0mm}{}
\titlecontents{part}
[0cm]
{}
{\hfil\normalfont\large\bfseries
\thecontentslabel\mdseries .\bfseries ~\hfil
\normalfont\large\bfseries}
{}
{\normalsize\dotfill\scriptsize\bfseries\thecontentspage}
[]
\begin{document}
\tableofcontents
\part{Part}
\part{Part}
\part{Part}
\titlecontents{part}
[0cm]
{}
{\hfil\normalfont\large\bfseries
\thecontentslabel\mdseries $\!$.\bfseries ~\hfil
\normalfont\large\bfseries}
{}
{\normalsize\dotfill\scriptsize\bfseries\thecontentspage}
[]
\part{Part}
\part{Part}
\titlecontents{part}
[0cm]
{}
{\hfil\normalfont\large\bfseries
\thecontentslabel\mdseries .\bfseries ~\hfil
\normalfont\large\bfseries}
{}
{\normalsize\dotfill\scriptsize\bfseries\thecontentspage}
[]
\part{Part}
\end{document}