使用 etoc
宏包,虚线见 https://ask.latexstudio.net/ask/question/7397.html 。
\documentclass{ctexrep}
\usepackage{enumitem}
\usepackage{etoc}
%\usepackage[colorlinks]{hyperref}
\setmainfont{TeX Gyre TermesX}
\usepackage{dashrule}
\begin{document}
\ExplSyntaxOn
% https://ask.latexstudio.net/ask/question/7397.html
\NewDocumentCommand \approxhdashrule { O{0pt} m m m }
{
\hbox_to_wd:nn {#2}
{
\int_set:Nn \l_tmpa_int
{
2 * \int_div_round:nn { \int_value:w \tex_dimexpr:D #2 }
{ 2 * \int_value:w \tex_dimexpr:D #4 } + 1
}
\dim_set:Nn \l_tmpa_dim { \dim_eval:n {#2} / \l_tmpa_int }
\hdashrule [#1] {#2} {#3} { \l_tmpa_dim }
\hbox_overlap_left:n { \rule [#1] { \l_tmpa_dim } {#3} }
}
}
\ExplSyntaxOff
\ctexset{section/tocline={\protect\numberline{第\chinese{section}节}#2}}
\makeatletter
\newlist{thetoclist}{itemize}{5}
% chapter
\setlist[thetoclist,1]{nosep,label=\etocnumber,
left=0cm..5\ccwd,labelsep=1\ccwd}
% section
\setlist[thetoclist,2]{nosep,label=\etocnumber,
left=5\ccwd..4\ccwd,labelsep=1\ccwd}
\newcommand{\thetoc@dashed}{\noindent
\approxhdashrule[.6ex]{\linewidth}{.6pt}{4pt}\par}
\let\thetocdashed\relax
\providecommand{\three@digits}[1]{\ifnum#1<10 0\fi
\ifnum#1<100 0\fi \number#1 }
\etocsetstyle{chapter}
{\begin{thetoclist}}
{\etociffirst{}{\thetoc@dashed}%
\rmfamily\bfseries\item}
{\etocname\hfill \slshape\three@digits\etocthepage}
{\end{thetoclist}}
\etocsetstyle{section}
{\begin{thetoclist}}
{\normalfont\item}
{\etocname\hfill \slshape\three@digits\etocthepage}
{\end{thetoclist}}
\localtableofcontents
\makeatother
\cleardoublepage
\pagenumbering{arabic}
\chapter{双相障碍及精准医学}
\section{双相障碍概念}
\section{精准医学概念}
\chapter{双相障碍的临床表现}
\section{临床表现及分型}
\section{抑郁发作}
\setcounter{chapter}{10}
\chapter{双相障碍的病因机制假说}
\section{遗传与环境交互作用假说}
\end{document}
问 请问这种目录怎么做出来?