5 请问这种目录怎么做出来?

发布于 2022-12-10 18:57:06

目录.png
请问这种目录如何制作?对目录不太熟悉, 请大佬教教!

查看更多

关注者
0
被浏览
1.1k
雾月
雾月 2022-12-11
这家伙很懒,什么也没写!

image.png

使用 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}
2 个回答
Swit
Swit 2022-12-11
LaTeX nubility!

条目格式搞定了,如下:

\documentclass{ctexrep}
\usepackage{tocloft}
\usepackage{fmtcount}
\renewcommand{\cftdot}{}
\renewcommand{\thesection}{第\chinese{section}节}
\setlength{\cftchapnumwidth}{4em}
\setlength{\cftsecindent}{\cftchapnumwidth}
\renewcommand{\cftsecnumwidth}{4em}
\renewcommand{\cftchappagefont}{\itshape}
\renewcommand{\cftsecpagefont}{\itshape}
\makeatletter
\renewcommand{\cftchapfillnum}[1]{%
  {\cftchapleader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cftchappagefont \padzeroes[3]{\decimalnum{#1}}}\cftchapafterpnum\par
}
\renewcommand{\cftsecfillnum}[1]{%
 {\cftsecleader}\nobreak
 \makebox[\@pnumwidth][\cftpnumalign]{\cftsecpagefont \padzeroes[3]{\decimalnum{#1}}}\cftsecafterpnum\par
}
\makeatother
\usepackage{zhlipsum}
\begin{document}

\tableofcontents

\chapter{双相及精准医学障碍}

\section{双相障碍概念}
\zhlipsum[1-2]
\section{精准医学概念}
\zhlipsum[3-4]


\chapter{双相障碍的临床表现}

\section{临床表现及分型}
\zhlipsum[5-6]

\section{抑郁发作}
\zhlipsum[7-8]
\section{躁狂/轻躁狂发作}
\zhlipsum[9]


\end{document}

1.png

但是那个分割线我没有思路,看看别人有没有办法吧。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览