Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何调整目录页,数字和文本之间的距离? #170

Closed
DRjy opened this issue Jun 3, 2019 · 8 comments
Closed

如何调整目录页,数字和文本之间的距离? #170

DRjy opened this issue Jun 3, 2019 · 8 comments

Comments

@DRjy
Copy link

DRjy commented Jun 3, 2019

image

现在想缩小这个数字和文字中间的距离,我该如何调整?

@e71828
Copy link

e71828 commented Jun 4, 2019

%- parameters for spacing and length in toc
\def\@dotsep{1.5mu}% separation between dots in mu units
\def\@pnumwidth{2em}% width of a box in which the page number is put
\def\@tocrmarg{2em}% right margin for multiple line entries, \@tocrmarg ≥ \@pnumwidth
\def\@chaptervspace{1ex}% vertical space between chapter titles

\def@dotsep{1.5mu}% 目录点距
\def@pnumwidth{2em}% 页码字符盒子占用宽度
\def@tocrmarg{2em}% 目录过长时的右侧空白宽带
\def@chaptervspace{1ex}% 章级目录的间距

\vskip \@chaptervspace \@plus\p@

章级目录的间距

\vskip \z@ \@plus.2\p@

章以下级目录的间距

@muzimuzhi
Copy link
Contributor

把以下部分加到 Thesis.tex\begin{document} 之前。

\usepackage{xpatch}

\makeatletter
\ExplSyntaxOn
\xpatchcmd\CTEX@chapter@tocline
  {.3em}
  {0em}
  {}{\fail}
\ExplSyntaxOff

%% change the 3rd arg of \@dottedtocline
%% bofore
% \renewcommand*\l@section{\@dottedtocline{1}{1em}{2em}}
%\renewcommand*\l@subsection{\@dottedtocline{2}{2em}{3em}}
%% after
\renewcommand*\l@section{\@dottedtocline{1}{1em}{1.5em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{2em}{2.5em}}
\makeatother

效果
image

涉及的源码

  1. 本项目中的(有其他调整需求,也可以模范着改)
    %- redefine indentation for others
    \renewcommand*\l@section{\@dottedtocline{1}{1em}{2em}}
    \renewcommand*\l@subsection{\@dottedtocline{2}{2em}{3em}}
    \renewcommand*\l@subsubsection{\@dottedtocline{3}{3em}{4em}}
    \renewcommand*\l@paragraph{\@dottedtocline{4}{4em}{5em}}
    \renewcommand*\l@subparagraph{\@dottedtocline{5}{5em}{6em}}
    \renewcommand*\l@figure{\@dottedtocline{1}{1em}{2em}}
    \renewcommand*\l@table{\@dottedtocline{1}{1em}{2em}}
  2. ctex-kit 项目中的
    https://github.com/CTeX-org/ctex-kit/blob/4449ab586987a4a86bc7a6210d84e018b3bd6190/ctex/ctex.dtx#L7866-L7874

@muzimuzhi
Copy link
Contributor

@e71828 你评论里提及的那几个储存长度的宏,和当前 issue 问的「目录项中,数字部分和标题之间的横向空白,如何调整其宽度」都没有直接联系。你贴的注释部分,也能说明问题

\def@dotsep{1.5mu}% 目录点距
\def@pnumwidth{2em}% 页码字符盒子占用宽度
\def@tocrmarg{2em}% 目录过长时的右侧空白宽带
\def@chaptervspace{1ex}% 章级目录的间距

@mohuangrui 根据这个评论里提供的国科大《学位/毕业论文撰写规定》,模板生成的「目录项数字部分和标题之间的间距」确实比规范文件末尾的的例子稍大。是否考虑调整模板?

@DRjy
Copy link
Author

DRjy commented Jun 4, 2019

\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.0em}} \renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{2.0em}} \renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{2.0em}}

我最后是通过这个方法解决的。
% \renewcommand{\l@<typ>}{\@dottedtocline{<level>}% % {<indentation>}% % {<numwidth>}}

@e71828
Copy link

e71828 commented Jun 4, 2019

@muzimuzhi 抱歉啊 我误导人了 一眼看到的vspace啥的就顾名思义了

@muzimuzhi
Copy link
Contributor

\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.0em}} \renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{2.0em}} \renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{2.0em}}

我最后是通过这个方法解决的。
% \renewcommand{\l@<typ>}{\@dottedtocline{<level>}% % {<indentation>}% % {<numwidth>}}

是的,这样可以修改 section 及更低层级的目录项。我提供的 \xpatchcmd\CTEX@chapter@tocline 部分,是用来修改 chapter 目录项的(因为看你的截图里,把 chapter 目录项中的间距也圈出来了)。

@mohuangrui
Copy link
Owner

@muzimuzhi 谢谢建议,这个先标记着,如果需要,将来再改

@mohuangrui
Copy link
Owner

@DRjy 经复审,发现你的截图间距为旧版的间距,因此较大。 @muzimuzhi 测试发现每个减掉 0.5em 有些过多,导致图表列表排列异常。最后调整为减掉 0.2em :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants