Skip to content

Commit

Permalink
搞定参考文献的页眉
Browse files Browse the repository at this point in the history
由于参考文献部分调用了thebibliography环境,我们在该环境中定义的页眉由于前面commit提到的bug无法显式,因此曲线救国,定义一个`\tjbibliographyheading`命令。我的原则是,打死也不放弃fancyhdr哈哈。
  • Loading branch information
marquistj13 committed Feb 20, 2018
1 parent abf1b64 commit 5f12b72
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 52 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@

斗胆将其称为TongjiThesis v2.0。

不过目前仍有很多地方和学校的word版本不一致,我还在继续改
不过已经学校的word版本基本一致

主要参考资料:
* [ThuThesis 2017/12/24 5.4.3](https://github.com/xueruini/thuthesis)
* [最新版本的TongjiThesis, 即Tongji LUG 2014年的RC2版](https://sourceforge.net/projects/tongjithesis/)。 以下用`老版`代指。
* [linxdcn](https://github.com/linxdcn/TongjiThesis)同学汇总的wildwolf(据zhouyuan说,wildwolf是同济汽车学院的老师)、[svandex](https://github.com/svandex/masthesis)[zhao-chen](https://github.com/zhao-chen/TongjiThesis)的版本。[zhouyuan有本硕博版](https://github.com/zhouyuan/tongjithesis)。主要参考了这几位校友改的封面、摘要等部分,学习其页眉设置技巧。我最终使用了[fire-emblem](https://github.com/fire-emblem/)亲手提供的fancyhdr页眉设置代码,并将其与adapt自thuthesis的`\tongji@chapter`结合,从而实现很优雅的页眉设置方式。

## 一点微小的工作
### 页眉
这个页眉问题耗了我两天时间。虽然有前人的代码可以借鉴,但总会碰到新坑的。
总结一下我花这么久才解决页眉的几个原因:
1. [linxdcn](https://github.com/linxdcn/TongjiThesis)汇总的版本虽然已经解决了页眉问题,但没有使用fancyhdr,我个人比较倾向于使用新事物哈哈(虽然fancyhdr已经很老了)。
2. [fire-emblem](https://github.com/fire-emblem/)给我的fancyhdr部分的设定只能部分work(当然他的模板基于book,而我这次的重构是基于ctexbook,他的fancyhdr部分的设置是能够在老版基于book的tongjithesis完美运行的。)。即对于使用newcommand定义的页面,如摘要和目录都能work。如果用environment定义的页面的话,则无法正确设置页眉。详细来说,举个例子,对于“主要符号对照表”,我们建了个denotation环境,也就是说这个页面只有一个environment,那么latex并没有将其识别为新的chapter*,因此继续沿用前面chapt*的页眉设置。原因猜测:目测是ctexbook的bug,即,它不把一个单纯的environment当成新的chapter* 。难道我把ctexset的浮动体对象设的比例不对? 现在的解决方案是,不用自定义的环境。全部改成`\NewDocumentCommand`
3. 历史的进程。

## 主要改动
相较于老版tongjithesis,我这个版本融合了thuthesis (ThuThesis 2017/12/24 5.4.3)的很多新改动,个人认为比较大的改动如下:
1. 加入更详尽的注释。我甚至将很多宏的用法用例子进行阐述,当然详细的注释主要集中在“宏展开”的部分。这就极大地方便了模板的阅读和理解,期待校友们更多地参与到对此模板的改进。
Expand Down
50 changes: 6 additions & 44 deletions changes.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
## 改动
使用latex的标准book class `\LoadClass[12pt,a4paper,openany]{book}`
* 使用latex的标准book class `\LoadClass[12pt,a4paper,openany]{book}`
使用`ctexbook` `\LoadClass[a4paper,openany,UTF8,zihao=-4,scheme=plain]{ctexbook}`

`\RequirePackage`部分主要参考自thuthesis

xparse 提供了LATEX2ε的\newcommand macro的一种高性能的替代,即 \NewDocumentCommand



去掉了tj的`\RequirePackage{hypernat}`,hypernat比较老了(2001年的),它的功能是使得natbib 的multiple sequential citations (e.g [3,2,1]) will be compressed to [1-3], where the '1' and the '3' are (color)linked to the bibliography.但现在不用这个hypernat也可以实现了,我推测是其他宏包自带了这些功能,不细细追究了。

* `\RequirePackage`部分主要参考自thuthesis
* xparse 提供了LATEX2ε的\newcommand macro的一种高性能的替代,即 \NewDocumentCommand
* 去掉了tj的`\RequirePackage{hypernat}`,hypernat比较老了(2001年的),它的功能是使得natbib 的multiple sequential citations (e.g [3,2,1]) will be compressed to [1-3], where the '1' and the '3' are (color)linked to the bibliography.但现在不用这个hypernat也可以实现了,我推测是其他宏包自带了这些功能,不细细追究了。
* 使用geometry进行页面尺寸的设置。
* 将footskip设为0.54cm(原tj的为1.5cm)
* 去掉了所有`\if@openright`的判断,因为没这个需求。这样也能简化代码逻辑。
* 使用fancyhdr设置页眉页脚
* 原模板的图表字体用大五,现在改成了五号
* 并排图形。\pkg{subfigure}、\pkg{subfig} 已经不再推荐,用新的\pkg{subcaption}.
* 并排图形。\pkg{subfigure}、\pkg{subfig} 已经不再推荐,用新的\pkg{subcaption}.
需要注意的是,由于我们的新模板中使用了subcaption的浮动体的配置,并且加载了subcaption,就不能再加载subfig了(两个包有冲突),因此我们再也无法使用subfig提供的`\subfloat`命令了。不用这么悲伤,我们可以使用subcaption的`subcaptionbox`直接将其替换即可。同时注意标题在`subcaptionbox`中是必选参数,即用`{}`,而非`\subfloat``[]`
*

## 要改的地方:
* 目录字体
```
Expand All @@ -27,8 +21,6 @@ xparse 提供了LATEX2ε的\newcommand macro的一种高性能的替代,即 \N
raggedbottom,
arialtitle}
```

* 页眉页脚部分需要调教\fancypagestyle{tongji@headings}
* 图标的标题要求单倍行距
探索:
```
Expand All @@ -42,41 +34,11 @@ https://liam0205.me/2013/10/17/LaTeX-Linespace/ 这里介绍了行距的概念
http://bbs.ctex.org/forum.php?mod=viewthread&tid=41619 这里说1.5就是word的单倍行距。
下面这个链接:https://tex.stackexchange.com/questions/13742/what-does-double-spacing-mean
有讨论,有空看看。

* 将cfg的CJKtoday命名设为Zhtoday
* 章节标题具体设置在.cfg中,但各级标题的具体字号设置仍需核实(在cls中),行距也是需要核实。
* 目录中的章标题,清华的是黑体小四,咱的是宋体小四,怎么改?
* wildwolf加入的`tongji@cabstractheadings``tongji@cabstractheadings`要研究一下。
目测新版的\tongji@chapter*支持以上两个headings的功能?

* schoole 的e要改掉。

## 要尝试的地方
* pdfpagelabels选项
* 章节标题的新定义方法,使用ctex宏集
```
% 全文首行缩进 2 字符,标点符号用全角
\ctexset{%
punct=quanjiao,
space=auto,
autoindent=true}
% \ctexset的详细介绍见《ctex宏集手册》,我现在看的是2018/01/28 v2.4.12
% 它有很多实用选项,如chapter/name = {第,章},section/name = {\S},
```

* 使用ctex宏集的\zihao 代替\tongji@define@fontsize
* 页眉页脚很方便,但是有一个非常隐蔽的坑
```
% \pkg{fancyhdr} 定义页眉页脚很方便,但是有一个非常隐蔽的坑。通过 \pkg{fancyhdr}
% 定义的样式在第一次被调用时会修改 \cs{chaptermark},这会导致页眉信息错误(多余
% 章号并且英文大写)
% thuthesis对此专门进行了解决:
% \AtBeginDocument{%
% \pagestyle{thu@empty}
% \renewcommand{\chaptermark}[1]{\@mkboth{\CTEXthechapter\hskip\ccwd#1}{}}}
% 但由于以上bug是基于book.cls的老版本时的bug,新版基于ctexbook的应该没有这个bug了吧?
````
* 清华的授权页支持扫描
`\includepdf{#1}`这个命令实现的,有机会可以用一下。
* 图索引,同济的少了个\addvspace{6bp}
3 changes: 1 addition & 2 deletions data/chap02.tex
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ \subsubsection{多个图形}

如果多个图形相互独立,并不共用一个图形计数器,那么用 \verb|minipage| 或者
\verb|parbox| 就可以。否则,请参看图~\ref{fig:big1},它包含两个小图,分别是图~\ref{fig:subfig1}
和图~\ref{fig:subfig2}。推荐使用 \verb|\subfloat|,不要再用
\verb|\subfigure| 和 \verb|\subtable|。
和图~\ref{fig:subfig2}。推荐使用 \verb|\subcaption|,不要再用\verb|\subfloat|,\verb|\subfigure| 和 \verb|\subtable|了。
\begin{figure} %[h]
\centering%
\subcaption{第一个小图形}{%
Expand Down
1 change: 1 addition & 0 deletions thesis.tex
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
\backmatter

% 参考文献
\tjbibliographyheading % 这个用来设置参考文献的页眉
\bibliographystyle{tongjibib}
\bibliography{ref/refs}

Expand Down
18 changes: 13 additions & 5 deletions tongjithesis.cls
Original file line number Diff line number Diff line change
Expand Up @@ -978,11 +978,9 @@
\def\@onlinecite#1{\begingroup\let\@cite\NAT@citenum\citep{#1}\endgroup}
\def\tongjidot{\unskip.}
\def\tongjimasterbib{\iftongji@doctor [dissertation]\else [Master Thesis]\fi}
\def\tongjiphdbib{\iftongji@doctor [dissertation]\else [Doctor Thesis]\fi}
\def\tongjiphdbib{\iftongji@doctor [dissertation]\else [Doctor Thesis]\fi}
\renewenvironment{thebibliography}[1]{%
\tongji@chapter*{\bibname}%
% \thispagestyle{tongji@cabstractheadings}
% \pagestyle{tongji@cabstractheadings}
\tongji@chapter*{\bibname}[\wuhao\songti\tongji@schoolname~\tongji@capply~\bibname]
\wuhao[1.4]
\list{\@biblabel{\@arabic\c@enumiv}}%
{\renewcommand{\makelabel}[1]{##1\hfill}
Expand All @@ -1003,7 +1001,17 @@
{\def\@noitemerr
{\@latex@warning{Empty `thebibliography' environment}}%
\endlist\frenchspacing}

% 我实在无能啊,没法解决“页眉无法在environment中显示”的bug了,只好搞出来一个\tjbibliographyheading凑合着用。
\NewDocumentCommand{\tjbibliographyheading}{}
{
\thispagestyle{fancy}
\fancyhead{}
\fancyhead[RO,LE]{\wuhao\songti\tongji@schoolname~\tongji@capply~\bibname}
\fancyfoot{}
\fancyfoot[C]{\songti\wuhao\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
}
% 附录
\let\tongji@appendix\appendix
\renewenvironment{appendix}{%
Expand Down

0 comments on commit 5f12b72

Please sign in to comment.