obster-y / XJTU-thesis

西安交通大学学位论文模板(LaTeX)(适用硕士、博士学位)An official LaTeX template for Xi'an Jiaotong University degree thesis (Chinese and English)
LaTeX Project Public License v1.3c
236 stars 52 forks source link

[BUG] [TeX] 大于10的章节在目录中显示间距不正确 #109

Open ZhangSongyi opened 1 year ago

ZhangSongyi commented 1 year ago

软件信息

Bug 说明

最小代码示例 参见这里,在原模板基础上,在正文前额外垫几个章节(让总章节数量超过10),之后正常编译即可看到目录中出现了挤在一起的问题。

\thesisbodybegin
\xchapter{BUG测试用1}{BUG TEST1}
\xchapter{BUG测试用2}{BUG TEST2}
\xchapter{BUG测试用3}{BUG TEST3}
\xchapter{BUG测试用4}{BUG TEST4}
\xchapter{BUG测试用5}{BUG TEST5}
\include{Main_Spine/c1}
\include{Main_Spine/c2}
\include{Main_Spine/c3}
\include{Main_Spine/c4}
\include{Main_Spine/c5}
\include{Main_Spine/c6}
\thesisbodyend

错误截图 中文目录编译效果 image 英文目录编译效果 image

其他说明 应该不会有人真的把论文写到10章以上,所以这个bug修复的优先级不高;但姑且先记录一下。

ZhangSongyi commented 1 year ago

补充:xsection和xsubsection在生成目录的时候也会有相同的问题 image

ZhangSongyi commented 1 year ago

看起来是TeX目录生成的一个普遍问题

参见 https://tex.stackexchange.com/questions/7415/roman-numerals-become-too-wide-in-table-of-contents https://tex.stackexchange.com/questions/13690/extra-space-for-numbered-titles-in-table-of-contents https://stackoverflow.com/questions/33093493/adding-space-after-section-numbers-in-toc

ZhangSongyi commented 1 year ago

一个使用tocbasic避免重叠的例子,不过这样会把所有的文本都对齐地右移 实现不了word里的那种数字和章节标题固定距离的效果

\documentclass{report}
\usepackage{tocbasic}
\DeclareTOCStyleEntries[dynnumwidth=true]{tocline}{chapter,section,subsection,subsubsection}
\begin{document}
\tableofcontents
\chapter{One}
\setcounter{chapter}{9}
\chapter{Ten}
\setcounter{chapter}{99}
\chapter{One hundred}
\setcounter{chapter}{999}
\chapter{One thousand}
\section{One thousand-one}
\section{One thousand-two}
\setcounter{chapter}{999999}
\chapter{One million}
\section{One million-one}
\section{One million-two}
\end{document}

image