Skip to content

Commit

Permalink
Merge pull request #334 from xueruini/chaptertoc
Browse files Browse the repository at this point in the history
目录中 chapter 的字体
  • Loading branch information
xueruini committed Apr 23, 2018
2 parents 7bdbc3a + 65e8a04 commit 91215e1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 59 deletions.
17 changes: 8 additions & 9 deletions main.tex
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
\documentclass[degree=master]{thuthesis}
% 选项:
% degree=[bachelor|master|doctor|postdoctor], % 必选
% secret, % 可选
% pifootnote, % 可选(建议打开)
% openany|openright, % 可选,基本不用
% arial, % 可选,基本不用
% arialtoc, % 可选,基本不用
% arialtitle % 可选,基本不用
\documentclass[degree=master, tocarialchapter]{thuthesis}
% 选项
% degree=[bachelor|master|doctor|postdoctor], % 必选,学位类型
% secret, % 可选(默认:关闭),是否有密级
% tocarialchapter, % 可选(默认:关闭),章目录中使用黑体(这项表示同时打开下面两项)
% tocarialchapterentry, % 可选(默认:关闭),单独控制章标题在目录中使用黑体
% tocarialchapterpage, % 可选(默认:关闭),单独控制章页码在目录中使用黑体
% pifootnote, % 可选(默认:关闭),页脚编号采用 pifont 字体符号,建议打开

% 所有其它可能用到的包都统一放到这里了,可以根据自己的实际添加或者删除。
\usepackage{thuthesis}
Expand Down
93 changes: 44 additions & 49 deletions thuthesis.dtx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
% Copyright (C) 2005-2017 by Ruini Xue <[email protected]>
% Copyright (C) 2005-2018 by Ruini Xue <[email protected]>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
Expand Down Expand Up @@ -149,6 +149,7 @@
% \changes{v4.8}{2013/03/09}{reset baselinestretch after ctex's change.}
% \changes{v4.8}{2014/11/25}{好几年累积的一些更新,最重要的是切换到 \CTeX。}
% \changes{v5.4.2}{2017/12/16}{删除 \cs{pozhehao}。}
% \changes{v5.4.4}{2018/04/22}{删除 \option{arialtitle},所有论文格式都一样。}
%
% \def\indexname{索引}
% \def\glossaryname{修改记录}
Expand Down Expand Up @@ -441,12 +442,16 @@
% 是 \option{openany}。}。这两个选项不用设置,\thuthesis\ 会根据当前论文类型自动选
% 择。
%
% \DescribeOption{arialtoc}
% 目录项(章目录项除外)中的英文是否用 \emph{Arial} 字体。本选项
% 和 \option{arialtitle} 都不用用户干预,模板根据当前论文类型自动设置
% \DescribeOption{tocarialchapter}
% 章目录项(内容和页码)是否用 \textsf{Arial} 字体。如果想分别控制内容和页码的字体,
% 用下面两个开关
%
% \DescribeOption{arialtitle}
% 章节标题中英文是否用 \emph{Arial} 字体(默认打开)。
% \DescribeOption{tocarialchapterentry}
% 章目录项内容中的英文和数字是否用 \textsf{Arial} 字体。中文强制黑体,为了协调这个选
% 项应该默认打开,不过从目前的反馈来看各学院的标准不一致。
%
% \DescribeOption{tocarialchapterpage}
% 章目录项页码是否用 \textsf{Arial} 字体。
%
% \subsection{引用方式}
% \label{sec:citestyle}
Expand All @@ -467,7 +472,7 @@
% 的 \cs{cite}\marg{key},而 \cs{inlinecite}\marg{key} 则用来生成正文模式。
%
% 关于参考文献模板推荐使用 \BibTeX,关于中文参考文献需要额外增加一个 Entry:
% \texttt{lang},将其设置为 \texttt{zh} 用来指示此参考文献为中文。如:
% \texttt{language},将其设置为 \texttt{chinese} 用来指示此参考文献为中文。如:
% \begin{latex}
% @INPROCEEDINGS{cnproceed,
% author = {王重阳 and 黄药师 and 欧阳峰 and 洪七公 and 段皇帝},
Expand All @@ -476,17 +481,17 @@
% year = 2006,
% address = {西安, 中国},
% month = sep,
% lang = "zh",
% language = "chinese",
% }
%
% @ARTICLE{cnarticle,
% AUTHOR = "贾宝玉 and 林黛玉 and 薛宝钗 and 贾探春",
% TITLE = "论刘姥姥食量大如牛之现实意义",
% JOURNAL = "红楼梦杂谈",
% PAGES = "260--266",
% VOLUME = "224",
% YEAR = "1800",
% LANG = "zh",
% author = "贾宝玉 and 林黛玉 and 薛宝钗 and 贾探春",
% title = "论刘姥姥食量大如牛之现实意义",
% journal = "红楼梦杂谈",
% pages = "260--266",
% volume = "224",
% year = "1800",
% language = "chinese",
% }
% \end{latex}
%
Expand Down Expand Up @@ -1167,14 +1172,11 @@
\DeclareBoolOption{secret}
% \end{macrocode}
%
% 目录中英文是否用 Arial 字体(默认关闭)。
% \begin{macrocode}
\DeclareBoolOption{arialtoc}
% \end{macrocode}
%
% 章节标题中的英文是否用 Arial 字体(默认打开)。
% 章目录中的英文是否用 Arial 字体(默认关闭),可以分别控制内容和页码部分。
% \begin{macrocode}
\DeclareBoolOption{arialtitle}
\DeclareBoolOption{tocarialchapter}
\DeclareBoolOption{tocarialchapterentry}
\DeclareBoolOption{tocarialchapterpage}
% \end{macrocode}
%
% 在 Windows Vista 或之后系统下时,默认使用微软雅黑,这可能会导致审查不合格。
Expand Down Expand Up @@ -1207,8 +1209,7 @@
% 打开默认选项。
% \begin{macrocode}
\kvsetkeys{thu}{%
raggedbottom,
arialtitle}
raggedbottom}
% \end{macrocode}
%
% 解析用户传递过来的选项,并加载 \pkg{ctexbook}。
Expand Down Expand Up @@ -1903,13 +1904,6 @@
%</cfg>
% \end{macrocode}
%
% 如果章节题目中的英文要使用 arial,那么就加上 \cs{sffamily}
% \begin{macrocode}
%<*cls>
\def\thu@title@font{%
\ifthu@arialtitle\sffamily\else\heiti\fi}
% \end{macrocode}
%
% \pkg{fancyhdr} 定义页眉页脚很方便,但是有一个非常隐蔽的坑。通过 \pkg{fancyhdr}
% 定义的样式在第一次被调用时会修改 \cs{chaptermark},这会导致页眉信息错误(多余
% 章号并且英文大写)。这是因为在原始的 \file{book.cls} 中定义如下(大意):
Expand All @@ -1934,6 +1928,7 @@
% 而覆盖我们的 \cs{chaptermark} 定义(后续样式再激活不会重复覆盖)。所以我们采用如下
% 方法解决:
% \begin{macrocode}
%<*cls>
\AtBeginDocument{%
\pagestyle{thu@empty}
\renewcommand{\chaptermark}[1]{\@mkboth{\CTEXthechapter\hskip\ccwd#1}{}}}
Expand Down Expand Up @@ -1984,7 +1979,7 @@
beforeskip={\ifthu@bachelor 15bp\else 9bp\fi},
aftername=\hskip\ccwd,
afterskip={\ifthu@bachelor 20bp\else 24bp\fi},
format={\centering\thu@title@font\ifthu@bachelor\xiaosan[1.333]\else\sanhao[1]\fi},
format={\centering\sffamily\ifthu@bachelor\xiaosan[1.333]\else\sanhao[1]\fi},
nameformat=\relax,
numberformat=\relax,
titleformat=\thu@chapter@titleformat,
Expand All @@ -1995,20 +1990,20 @@
afterindent=true,
beforeskip={\ifthu@bachelor 25bp\else 24bp\fi\@plus 1ex \@minus .2ex},
afterskip={\ifthu@bachelor 12bp\else 6bp\fi \@plus .2ex},
format={\thu@title@font\ifthu@bachelor\sihao[1.286]\else\sihao[1.429]\fi},
format={\sffamily\ifthu@bachelor\sihao[1.286]\else\sihao[1.429]\fi},
},
subsection={
afterindent=true,
beforeskip={\ifthu@bachelor 12bp\else 16bp\fi\@plus 1ex \@minus .2ex},
afterskip={6bp \@plus .2ex},
format={\thu@title@font\ifthu@bachelor\xiaosi[1.25]\else\banxiaosi[1.538]\fi},
numberformat={\thu@title@font\ifthu@bachelor\banxiaosi[1.154]\else\banxiaosi[1.538]\fi},
format={\sffamily\ifthu@bachelor\xiaosi[1.25]\else\banxiaosi[1.538]\fi},
numberformat={\sffamily\ifthu@bachelor\banxiaosi[1.154]\else\banxiaosi[1.538]\fi},
},
subsubsection={
afterindent=true,
beforeskip={\ifthu@bachelor 12bp\else 16bp\fi\@plus 1ex \@minus .2ex},
afterskip={6bp \@plus .2ex},
format={\thu@title@font\ifthu@bachelor\xiaosi[1.25]\else\xiaosi[1.667]\fi},
format={\sffamily\ifthu@bachelor\xiaosi[1.25]\else\xiaosi[1.667]\fi},
},
paragraph/afterindent=true,
subparagraph/afterindent=true}
Expand Down Expand Up @@ -2071,8 +2066,7 @@
\setcounter{tocdepth}{2}
% \end{macrocode}
%
% 每章标题行前空 6 磅,后空 0 磅。如果使用目录项中英文要使用 Arial,那么就加上 \cs{sffamily}。
% 章节名中英文用 Arial 字体,页码仍用 Times。
% 每章标题行前空 6 磅,后空 0 磅。章节名中英文用 Arial 字体,页码仍用 Times。
% \begin{macro}{\tableofcontents}
% \changes{v2.0}{2005/12/18}{附录的目录项需要调整一下。以及公式编号方式等等。}
% \changes{v2.5}{2006/05/13}{取消 \pkg{titletoc} 宏包,用 \cs{dottedtocline} 调整
Expand All @@ -2093,29 +2087,28 @@
% 调整目录样式,允许指定目录字体。
% \changes{v5.2.2}{2016/01/23}{用 \cs{patchcmd} 修改 \cs{@dottedtocline}。}
% \begin{macrocode}
\ifthu@arialtoc
\def\thu@toc@font{\sffamily}
\fi
\def\@pnumwidth{2em}
\def\@tocrmarg{\@pnumwidth}
\def\@dotsep{1}
\patchcmd{\@dottedtocline}{#4}{\csname thu@toc@font\endcsname #4}{}{}
\patchcmd{\@dottedtocline}{\hb@xt@\@pnumwidth}{\hbox}{}{}
\ifthu@tocarialchapter
\thu@tocarialchapterentrytrue\thu@tocarialchapterpagetrue
\fi
\def\thu@toc@chapter@entry@font{\ifthu@tocarialchapterentry\sffamily\fi}
\def\thu@toc@chapter@page@font{\ifthu@tocarialchapterpage\sffamily\fi}
\renewcommand*\l@chapter[2]{%
\ifnum \c@tocdepth >\m@ne
\addpenalty{-\@highpenalty}%
\ifthu@bachelor \vskip 6bp \else \vskip 4bp \fi \@plus\p@
\ifthu@bachelor\vskip 6bp\else\vskip 4bp\fi \@plus\p@
\setlength\@tempdima{4em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode
\advance\leftskip\@tempdima
\hskip -\leftskip
% numberline is called here, and it uses \@tempdima
{\ifthu@bachelor\sffamily\else\csname thu@toc@font\endcsname\fi\heiti #1}
\leaders\hbox{$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill
\nobreak{\normalfont\normalcolor #2}\par
{\thu@toc@chapter@entry@font #1}%
\leaders\hbox{$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill%
\nobreak{\thu@toc@chapter@page@font #2}\par
\penalty\@highpenalty
\endgroup
\fi}
Expand All @@ -2126,6 +2119,8 @@
% 南中未作明确规定,示例文件中对于一级和二级节标题分别缩进 1 和 1.5 个汉字符。
% \changes{v5.0.0}{2015/04/28}{修正学位论文中目录里节前缩进(\#103)}
% \begin{macrocode}
% \patchcmd{\@dottedtocline}{#4}{\csname thu@toc@font\endcsname #4}{}{}
\patchcmd{\@dottedtocline}{\hb@xt@\@pnumwidth}{\hbox}{}{}
\renewcommand*\l@section{%
\@dottedtocline{1}{\ccwd}{2.1em}}
\renewcommand*\l@subsection{%
Expand Down Expand Up @@ -2844,7 +2839,7 @@
% \end{macro}
%
% \begin{macro}{\thu@makeabstract}
% 中文摘要部分的标题为\textbf{摘要},用黑体三号字。
% 中文摘要部分的标题为\textbf{摘要},用黑体三号字。
% \changes{v2.5.1}{2006/05/24}{教务处又不要正文前的页眉了。}
% \changes{v2.5.1}{2006/05/24}{不管是哪种论文格式,摘要都要右开。}
% \changes{v2.5.2}{2006/05/29}{在研究生论文中,摘要不出现在目录中,但是要在书签中出现。}
Expand Down
2 changes: 1 addition & 1 deletion thuthesis.ins
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%%
%% Copyright (C) 2005-2017 by Ruini Xue <[email protected]>
%% Copyright (C) 2005-2018 by Ruini Xue <[email protected]>
%%
%% This file is part of the ThuThesis package project.
%% ---------------------------------------------------
Expand Down

0 comments on commit 91215e1

Please sign in to comment.