Skip to content

Commit

Permalink
Merge pull request #101 from alick/fixed-fonts
Browse files Browse the repository at this point in the history
close #94.
  • Loading branch information
xueruini committed Apr 20, 2015
2 parents 6090da0 + 5d4987d commit a3ccf6c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 38 deletions.
3 changes: 1 addition & 2 deletions data/chap01.tex
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ \section{字体命令}
知周乎万物,而道济天下,故不过。旁行而不流,乐天知命,故不忧。安土敦乎仁,故
能爱。范围天地之化而不过,曲成万物而不遗,通乎昼夜之道而知,故神无方而易无体。}

% 非本科生一般用不到幼圆与隶书字体。ctex 在 xelatex 编译时用 winfonts/adobefonts
% 选项也只配置了四款中文字体,没有提供幼圆和隶书。需要的同学可以使用 nofonts 选项
% 非本科生一般用不到幼圆与隶书字体。需要的同学可以使用 thufonts.def 文件
% 自行配置中文字体,或者换用 pdflatex 引擎编译。
{\ifcsname youyuan\endcsname\youyuan 有天地,然后万物生焉。盈天地之间者,唯万物,故受之以屯;屯者盈也,屯者物之
始生也。物生必蒙,故受之以蒙;蒙者蒙也,物之穉也。物穉不可不养也,故受之以需;
Expand Down
5 changes: 1 addition & 4 deletions main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
%%% TeX-master: t
%%% End:

\documentclass[bachelor,nofonts]{thuthesis}
\documentclass[bachelor]{thuthesis}
%\documentclass[master]{thuthesis}
%\documentclass[doctor]{thuthesis}
% \documentclass[%
% bachelor|master|doctor|postdoctor, % mandatory option
% winfonts|nofonts|adobefonts, % mandatory only for bachelor and Linuxer
% secret,
% openany|openright,
% arialtoc,arialtitle]{thuthesis}
% 当使用 XeLaTeX 编译时,本科生、Linux 用户需要加上 nofonts 选项;
% 当使用 PDFLaTeX 编译时,adobefonts 选项等效于 winfonts 选项(缺省选项)。

% 所有其它可能用到的包都统一放到这里了,可以根据自己的实际添加或者删除。
\usepackage{thutils}
Expand Down
1 change: 0 additions & 1 deletion shuji.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
\documentclass[doctor]{thuthesis}
% 如果要用 thufonts.def,使用 nofonts 选项

\ifxetex
\setCJKfamilyfont{zhfs}[RawFeature={vertical:}]{FangSong}
Expand Down
2 changes: 2 additions & 0 deletions thufonts.def
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
\setCJKfamilyfont{zhhei}{SimHei}
\setCJKfamilyfont{zhkai}{KaiTi}
\setCJKfamilyfont{zhfs}{FangSong}
% 研究生一般用不到隶书和幼圆字体,系统没有它们时可以删除如下两行
\setCJKfamilyfont{zhli}{LiSu}
\setCJKfamilyfont{zhyou}{YouYuan}

\newcommand*{\songti}{\CJKfamily{zhsong}}
\newcommand*{\heiti}{\CJKfamily{zhhei}}
\newcommand*{\kaishu}{\CJKfamily{zhkai}}
\newcommand*{\fangsong}{\CJKfamily{zhfs}}
% 研究生一般用不到隶书和幼圆字体,系统没有它们时可以删除如下两行
\newcommand*{\lishu}{\CJKfamily{zhli}}
\newcommand*{\youyuan}{\CJKfamily{zhyou}}
54 changes: 23 additions & 31 deletions thuthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,11 @@
% $ xelatex main # 此时生成完整的 pdf 文件
% \end{shell}
% Xe\TeX 最大的优势就是不再需要繁琐的字体配置。\thuthesis{} 通过 \pkg{xeCJK} 来控
% 制中文字体和标点压缩。模板里默认用的是中易的四款免费字体(宋,黑,楷,仿宋),
% 用户可以根据自己的实际情况自行替换。另外,本科论文封面要用到隶书,需要使用模板的
% nofonts 选项。字体配置参考第~\ref{sec:font-config} 节。
% 制中文字体和标点压缩。模板里默认用的是中易的六款免费字体(宋,黑,楷,仿宋,隶书
% 和幼圆),因学位论文需求不建议替换为其他字体。如果实在必要,可以通过定制
% \file{thufonts.def} 文件中的字体自行替换。研究生一般用不到隶书和幼圆字体,如果
% 系统上没有它们,可以直接将 \file{thufonts.def} 文件以及论文的 \file{.tex} 文件中
% 相应行删除。字体配置参考第~\ref{sec:font-config} 节。
%
% \subsubsection{dvipdfmx}
% \label{sec:dvipdfmx}
Expand Down Expand Up @@ -401,18 +403,15 @@
% 的 \file{main.tex} 和 \file{data/}。
%
% \begin{example}
% \documentclass[bachelor,nofonts]{thuthesis}
% %\documentclass[master,adobefonts]{thuthesis}
% \documentclass[bachelor]{thuthesis}
% %\documentclass[master]{thuthesis}
% %\documentclass[doctor]{thuthesis}
% %\documentclass[%
% % bachelor|master|doctor|postdoctor, % 必选选项
% % winfonts|nofonts|adobefonts, % 本科生、Linux 用户使用 XeLaTeX 时必选
% % secret, % 可选选项
% % openany|openright, % 可选选项
% % arialtoc,arialtitle % 可选选项
% % ]{thuthesis}
% % 当使用 xelatex 编译时,本科生、Linux 用户需要加上 nofonts 选项;
% % 当使用 pdflatex 编译时,adobefonts 选项等效于 winfonts 选项(缺省选项)。
%
% % 所有其它可能用到的包都统一放到这里了,可以根据自己的实际添加或者删除。
% \usepackage{thutils}
Expand Down Expand Up @@ -519,14 +518,6 @@
% 都是 \option{openany}。}这两个选项不用专门设置,\thuthesis{} 会根据当前论文类
% 型自动选择。
%
% \item[winfonts, adobefonts, nofonts]
% 这些选项用来指导 \pkg{ctex} 宏包/文档类设置选用的中文字体。
% \begin{itemize}
% \item \option{winfonts} 指定使用中易的六款字体(Xe\TeX 下为四种)。
% \item \option{adobefonts} 指定使用 Adobe 的四款免费中文字体。
% \item \option{nofonts} 不提供可用的中文字体,由用户自行设定。
% \end{itemize}
%
% \item[arial]
% 使用真正的 \option{arial} 字体。此选项会装载 \pkg{arial} 字体宏包,如果此宏包
% 不存在,就装
Expand Down Expand Up @@ -554,13 +545,8 @@
%
% 第一种方式的字体配置比较繁琐,建议使用 \emph{donated@newsmth} 制作的中文字体包
% (自包含安装方法),请用户自行下载安装,此处不再赘述。本模板推荐使用第二种方法,
% 只要把所需字体放入系统字体文件夹(也可以指定自定义文件夹)即可。用户可以使
% 用 \option{winfonts},\option{adobefonts},\option{nofonts} 选项来选择可用的中
% 文字库,缺省为 \option{winfonts} 有效,使用中易字体。当使用 xelatex 编译
% 时,\option{winfonts} 只有中易的四款字体(宋体、黑体、楷书和仿宋)可用,而本科
% 生需要用到幼圆,另外 Linux 系统缺少上述字体,这些用户可以通过指
% 定 \option{nofonts} 选项,利用 \file{thufonts.def} 文件配置所需字体。使用中易
% 六种字体的配置如下:
% 只要把所需字体放入系统字体文件夹(也可以指定自定义文件夹)即可。用户可以使用
% \file{thufonts.def} 文件配置所需字体。使用中易六种字体的配置如下:
% \begin{example}
% \ProvidesFile{thufonts.def}
% \setCJKmainfont[BoldFont={SimHei},ItalicFont={KaiTi}]{SimSun}
Expand All @@ -583,6 +569,10 @@
% 对 Windows XP 来说如下,|KaiTi| 需要替换为 |KaiTi_GB2312|,|FangSong| 需要替换
% 为 |FangSong_GB2312|。
%
% 研究生一般用不到隶书和幼圆字体。如果系统中没有导致报错,可以将
% \file{thufonts.def} 文件中 zhli 和 zhyou 相应行删除,并将论文 \file{.tex} 文件
% 中引用 |\lishu| 和 |\youyuan| 的文字删除。
%
% 宏包中包含了 \file{zhfonts.py} 脚本,为 Linux/Mac 用户提供一种交互式的方式从系
% 统中文字体中选择合适的六种字体,最终生成对应的 \file{thufonts.def}文件。要使用
% 它,只需在命令行输入该脚本的完整路径即可。
Expand Down Expand Up @@ -1101,7 +1091,12 @@
\ExecuteOptions{utf,arialtitle}
\ProcessOptions\relax
\PassOptionsToPackage{no-math}{fontspec}
\LoadClass[cs4size,a4paper,openany,nocap,UTF8]{ctexbook}
\RequirePackage{ifxetex}
\ifxetex
\LoadClass[cs4size,a4paper,openany,nocap,nofonts,UTF8]{ctexbook}
\else
\LoadClass[cs4size,a4paper,openany,nocap,winfonts,UTF8]{ctexbook}
\fi
% \end{macrocode}
%
% 用户至少要提供一个选项:指定论文类型。
Expand All @@ -1123,7 +1118,6 @@
%
% 引用的宏包和相应的定义。
% \begin{macrocode}
\RequirePackage{ifxetex}
\RequirePackage{ifthen,calc}
% \end{macrocode}
%
Expand Down Expand Up @@ -1185,13 +1179,11 @@
\def\CJK@null{\kern\CJKnullspace\Unicode{48}{7}\kern\CJKnullspace}
\defaultfontfeatures{Mapping=tex-text} % use TeX --
% \end{macrocode}
% 默认采用中易的四款 (宋,黑,楷,仿宋) 免费字体。本科生还需要隶书,需要手工修
% \file{thufonts.def} 文件。缺少中文字体的 Linux 用户可以通
% 过 \file{thufonts.def} 文件定义字体。
% 默认采用中易的六款免费字体。缺少上述字体的用户可以通过
% \file{thufonts.def} 文件自定义字体。
% \changes{v4.9}{2015/04/17}{固定字体设置,同时改善与 ctex 兼容性。}
% \begin{macrocode}
\ifCTEX@nofonts
\input{thufonts.def}
\fi
\input{thufonts.def}

\setmainfont{Times New Roman}
\setsansfont{Arial}
Expand Down

0 comments on commit a3ccf6c

Please sign in to comment.