shifujun/UESTCthesis

基于xeCJK的毕业论文模板

Closed this issue · 14 comments

师兄你好!我是物理电子学院14级的硕士研究生王稳。最近也在研究用LaTeX写作毕业论文的事情,觉得现有的模板太依赖于CTEX,想基于通用的引擎XeLaTeX写一个更加方便的版本出来,目前正在想办法解决扉页和参考文献的问题,目前完成的模板在overleaf上的地址是这里。我的GitHub主页是https://github.com/wanygen。想问一下封面和参考文献的格式是怎么解决的,也欢迎师兄针对我的代码提出宝贵的意见。

我们可以先讨论一下依赖于ctex有什么不方便的地方。这里的ctex指的是ctexbook文类,而不是ctex套装,对吧?

overleaf网站我在家打开速度太慢,明天上班的时候如果能想起来我再看看。我看你GitHub主页上没有你的模板,所以我没看到代码。

封面(包括所有前置内容),我的模板最早的版本是有的。你可以看看1.0版本的模板。后来的版本就去掉了。因为我们的目的是方便又准确的排版出毕业论文,所以也不能太追求要用LaTeX来完成所有工作。在用LaTeX排版封面上遇到的一个主要问题是:封面上用到了加粗的黑体。这个“加粗”是Word实现的一种渲染效果,并不是字体本身的样子。所以LaTeX不能做出加粗的黑体。次要问题还有一些下划线的对齐和粗细问题。下划线等其实可以通过仔细调整数值来达到和Word一样的效果。所以,这些问题都是使用LaTeX带来的。而学校已经提供了封面等前置内容的Word模板,而且这些前置内容和后面的内容毫无关系,连页码都不是连续的。所以完全可以分别打印出来装订在一起。对于pdf文件来说也可以合成在一起。

参考文献是我自己写的bst,里面的很多代码是抄的国标的那个bst。因为我们校的参考文献格式是自己规定的标准,所以肯定要自己写的。

关于XeLaTeX,我不是没考虑过。XeLaTeX相对于pdflatex来说,只是多了更简单的字体选择能力。可是毕业论文又用不上各种各样的字体,毕业论文要用到的字体pdflatex都能满足。再有一点就是宏包的兼容性问题,兼容pdflatex的宏包要多于XeLaTeX。你几乎找不到不兼容pdflatex的宏包。最后就是,XeLaTeX的编译速度要比pdflatex慢的多,特别是在大论文或书籍上。

改用xeCJK主要是觉得这样深入地依赖CTEX不是很“干净”,即使是对ctexbook这个类的依赖。其实主要原因还是XeTeX引擎对系统字体的渲染效果要好一些。
capture
像上面字体的效果左边pdflatex的引擎相比右边xelatex看起来要单薄得多,看pdf更加明显。总的来说pdflatex不是一个适合调用系统字体的引擎。还有就是对Times New Roman字体的支持,latex自带的times字体并不真正是Times New Roman,效果也要略逊一筹,不知道CTEX对这个问题是怎么处理的。

“干净”的依赖有什么好处?不能理解你说的”干净“。

你得理解”渲染“是什么意思。”渲染“和编译器没有关系。”渲染“是阅读器或打印机要做的事。

Times New Roman字体是一个需要付费的有版权的字体,不能随意使用。

不管则么样,xetex编译出来的效果用阅读器看确实更漂亮一些。真要纠结版权的话SimSun和SimHei也是有版权的,况且在windows上编译使用字体本身并不超越许可。pdflatex确实没有兼容性问题,但是ctex就不一定了,我觉得是有隐患的。而且学校格式说明上写的就是Times New Roman,不是其他任何一种长得像的字体。

我觉得这两个方案可以并行存在。
我平时用LyX比较多,处理中文时,大多数情况下就用XeTeX,效果很好;其他时候用pdfLaTeX也不错。
而且这两个方案转换起来并不费事,至少在LyX中仅需更改两个参数就行了,我看LyX导出的TeX源文档也仅仅只是在导言区有微小差别而已。

我现在在写基于xeCJK的包,现在还需要调一下各种间距,然后就是参考文献的格式。我想利用一下现有的参考文献格式定义,就是uestcthesis.bst,但是编译老是提示各种函数未定义,不晓得怎么搞的。目前在overleaf上调整,那个链接能看到最新的进展,如果能行的话这样就不用本地安装各种东西了,有什么大的进展就更新到github上。

诚然模板同时支持XeLaTeX编译确实只需要加几个命令设置几个选项就可以了。但是对于模板维护来说,每次功能的调整、bug的修复都要在两种编译器上测试,这是提高了一倍的成本。因为这是一个固定格式的模板,我们肯定希望不管是谁使用,得到的效果都是一样的。所以编译器的确定是十分重要的。类似的,模板还将依赖的宏包都打包了,也是为了确保所有人用到的宏包都是一个版本,不会出现同样的论文在不同机器上编译效果不一致。例如,模板的前两个版本就出现了有的人编译时段首没有空两格的问题,就是在模板未打包依赖宏包时,不同机器上使用的ctex宏包版本不一致造成的。

我正在想办法读懂BST文件的代码。我想问一下,那个BST文件编译的时候为什么提示有三个函数未定义?

@WangEn 您好,请问那个字体问题就没法解决吗?我把这个latex生成的pdf和word模板都打印出来,比较后发现差别还是有点大,毕竟一眼就能看出来pdf字体略小,间距大,没有word字体饱满。

@thesby 估计只能换编译引擎了,XeLaTeX编译的字体效果应该是可以的,我在重新写一个模板,目前还有一些小问题,你可以先用一下试试。overleaf上可以下载到,能帮忙改一下代码当然更好。https://www.overleaf.com/8148727jbfryynqbqxm

bst提示3个函数没定义的log贴一下吧。那个bst应该是不够严谨,不过一般都是warnning,应该不会终止编译的。

编译脚本里面这两句是什么意思?

makeindex -s $jobname.ist -t $jobname.glg -o $jobname.gls $jobname.glo
makeindex -s $jobname.ist -t $jobname.alg -o $jobname.acr $jobname.acn

似乎没有这两句就会提示函数未定义,像一般的自动化编译系统的行为一样。错误信息如下:

This is BibTeX, Version 0.99d (TeX Live 2016)
The top-level auxiliary file: thesis.aux
A level-1 auxiliary file: contents/Cabstract.aux
A level-1 auxiliary file: contents/Eabstract.aux
A level-1 auxiliary file: chapters/ChapterA.aux
A level-1 auxiliary file: chapters/ChapterB.aux
A level-1 auxiliary file: chapters/ChapterC.aux
A level-1 auxiliary file: chapters/ChapterD.aux
The style file: uestcthesis.bst
new.block is an unknown function---line 83 of file uestcthesis.bst
remove.dots is an unknown function---line 455 of file uestcthesis.bst
remove.dots is an unknown function---line 503 of file uestcthesis.bst
remove.dots is an unknown function---line 555 of file uestcthesis.bst
remove.dots is an unknown function---line 599 of file uestcthesis.bst
format.pages is an unknown function---line 1139 of file uestcthesis.bst
format.pages is an unknown function---line 1170 of file uestcthesis.bst
format.pages is an unknown function---line 1179 of file uestcthesis.bst
format.pages is an unknown function---line 1209 of file uestcthesis.bst
format.pages is an unknown function---line 1218 of file uestcthesis.bst
*publisher is an unknown function---line 1882 of file uestcthesis.bst
* * is an unknown function---line 1891 of file uestcthesis.bst
Database file #1: contents/reference.bib
You can't pop an empty literal stack for entry wang1999sanwei
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry liuxf2006
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry liuxf2006
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry zhu1973wulixue
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry chen2001hao
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry chen2001hao
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry gu2012lao
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry feng997he
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry xiao2012yi
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry zhong1994zhong
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry clerc2010discrete
while executing---line 2628 of file uestcthesis.bst
"\" can't start a style-file command---line 2637 of file uestcthesis.bst
 : 
 : \endinput
(Error may have been on previous line)
(There were 24 error messages)

编译脚本里面这两句是什么意思?

makeindex -s $jobname.ist -t $jobname.glg -o $jobname.gls $jobname.glo
makeindex -s $jobname.ist -t $jobname.alg -o $jobname.acr $jobname.acn

似乎没有这两句就会提示函数未定义,像一般的自动化编译系统的行为一样。错误信息如下:

This is BibTeX, Version 0.99d (TeX Live 2016)
The top-level auxiliary file: thesis.aux
A level-1 auxiliary file: contents/Cabstract.aux
A level-1 auxiliary file: contents/Eabstract.aux
A level-1 auxiliary file: chapters/ChapterA.aux
A level-1 auxiliary file: chapters/ChapterB.aux
A level-1 auxiliary file: chapters/ChapterC.aux
A level-1 auxiliary file: chapters/ChapterD.aux
The style file: uestcthesis.bst
new.block is an unknown function---line 83 of file uestcthesis.bst
remove.dots is an unknown function---line 455 of file uestcthesis.bst
remove.dots is an unknown function---line 503 of file uestcthesis.bst
remove.dots is an unknown function---line 555 of file uestcthesis.bst
remove.dots is an unknown function---line 599 of file uestcthesis.bst
format.pages is an unknown function---line 1139 of file uestcthesis.bst
format.pages is an unknown function---line 1170 of file uestcthesis.bst
format.pages is an unknown function---line 1179 of file uestcthesis.bst
format.pages is an unknown function---line 1209 of file uestcthesis.bst
format.pages is an unknown function---line 1218 of file uestcthesis.bst
*publisher is an unknown function---line 1882 of file uestcthesis.bst
* * is an unknown function---line 1891 of file uestcthesis.bst
Database file #1: contents/reference.bib
You can't pop an empty literal stack for entry wang1999sanwei
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry liuxf2006
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry liuxf2006
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry zhu1973wulixue
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry chen2001hao
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry chen2001hao
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry gu2012lao
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry feng997he
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry xiao2012yi
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry zhong1994zhong
while executing---line 2628 of file uestcthesis.bst
You can't pop an empty literal stack for entry clerc2010discrete
while executing---line 2628 of file uestcthesis.bst
"\" can't start a style-file command---line 2637 of file uestcthesis.bst
 : 
 : \endinput
(Error may have been on previous line)
(There were 24 error messages)

请问最后怎么解决这个问题的?

那是另一个模版的编译脚本(https://github.com/shifujun/UESTCthesis)。