本文介绍了在Windows下TeX的安装及使用。
What TeX是一个排版软件,LaTeX从TeX衍生而来,命令较为简单.
TeX provides an unusual macro language; The TeX macro language has been successfully used to extend TeX to, for instance, LaTeX and ConTeXt. When TeX “compiles” a document, it follows (from the user’s point of view) the following processing sequence: Macros → TeX → Driver → Output.
Install 安装CTeX ,CTeX打包了MiTeX以及其他一些宏包、字体等。
直接用原生的latex需要加载宏包才能支持汉字,否则编译会报错:Invalid UTF-8 byte or sequence at line 4 replaced by U+FFFD.
XeTeX就是为了支持多语言而重新设计的新一代TeX系统,这意味着在XeTeX眼里,中文文档和英文文档再没有任何区别,无需额外的外挂包;而且,XeTeX原生支持系统字体,这意味着我们无需再额外编译字体,系统安装了什么字体,我们就能使用什么字体。
使用xelatex编译,不需要写\begin{CJK*}{UTF8}{song}
example.tex 1 2 3 4 5 6 7 \documentclass [12pt,a4paper] {article} \usepackage {fontspec} \setmainfont {Microsoft YaHei} \begin {document} Hello,World! 这是一个测试的中文文档! \end {document}
用notepad输入,保存成utf-8格式
, 后用xelatex example.tex编译,生成pdf。
Usage & Warning
\fontsize{字号}{基本行距}
其中字号和基本行距两个参数是纯数字,单位是 pt。命令也在 \selectfont 后生效。
Overfull \hbox (76.35919pt too wide) in paragraph at lines 11--15
找到对应的提示行,然后将最后几个单词任意截断,然后另起一行即可。
texdoc fontspec
可以查看宏包fontspec
的帮助文档。
fc-list
可以查看电脑中安装了哪些字体;fc-list ;lang=zh-cn
可以查看安装了哪些中文字体。
附上一个台湾版cwTeX中的示例(台湾的明体应该对应大陆的宋体)
TeX view raw 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 \documentclass [12pt,a4paper] {article} \XeTeXlinebreaklocale "zh" \XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt \linespread {1.5} \usepackage {fontspec,xunicode,} \usepackage [small, sf] {titlesec} \newfontfamily \youyuan {YouYuan} \newfontfamily \hwcaiyun {STCaiyun} \newfontfamily \hwhupo {STHupo} \newfontfamily \yaoti {FZYaoTi} \newfontfamily \kaiti {KaiTi} \newfontfamily \xsong {NSimSun} \newfontfamily \hwsong {STSong} \newfontfamily \yahei {Microsoft YaHei} \newfontfamily \fangsong {FangSong} \newfontfamily \song {SimSun} \newfontfamily \hwfangsong {STFangsong} \newfontfamily \weiti {STXinwei} \newfontfamily \heiti {SimHei} \newfontfamily \hwxingkai {STXingkai} \newfontfamily \hwlishu {STLiti} \newfontfamily \zhongsong {STZhongsong} \newfontfamily \shuti {FZShuTi} \newfontfamily \hwhei {STXihei} \newfontfamily \lishu {LiSu} \newfontfamily \hwkai {STKaiti} \setmainfont [BoldFont={SimHei}] {SimSun} \setsansfont [Mapping=tex-text] {Microsoft Sans Serif} \setmonofont {Courier New} \titleformat* {\section} {\youyuan} \titleformat* {\subsection} {\youyuan} \begin {document} \begin {center} {\Large \textbf {排版的原则}}\\ [5mm] 吴聪敏\\ [2mm] 2005.03 \end {center} \bigskip \fontsize {12} {20pt} \selectfont 排版的目的是为了有效率地表达你的意见, 让读者容易阅读或吸收。 \section {常见的排版错误} 桌上排版系统普及之后,每个人都能排版, 但这不表示每个人都能做出好的排版。 关于字体之使用,常见的错误如下: \begin {itemize} \item 楷体与仿宋体等可用于标题, 但不宜用于正文;正文请使用明体。 \item 较长之英文段落应使用纯英文字体编排, 如 Times New Roman,Book Antiquarian 等。 使用中文之细明体或楷体之英文字体, 结果保证惨不忍睹。 \item 欲强调之字词,请使用粗黑体或圆体,勿加底线。\end {itemize} Windows 系统提供明体与楷体两种字体, 许多人只能使用楷体排版正文或投影片, 但排版效果奇差无比。 除了字体之外,版面应注意之细节如下: \begin {enumerate} \itemsep =-2pt \item 文章前端请写下题目,作者名字,日期。\item 版面之一行勿拉太长,行距不应过小。\item 标点符号不应出现在一行前端(避头点)。\item 标示注解之号码在句子标点符号之后。\item 章节编号使用阿拉伯数字,如1.1节,2.3节;避免使用“一、二节”,或“二、三节”。 \item 阿拉伯数字“1,534”比“一千五百三十四”清楚。\end {enumerate} \section {图形与表格} 图形与表格是表现咨询的有效方法, 但是图表作的不好,无法达到目标。 常见的表格排版错误是格线太多, 但另一个问题是单位不清楚。 大型图表应移于版面的上方或下方,而非排版于段落中间。 非万不得已,表格勿拆为两页。 \par \vfill \jobname .tex \end {document}
效果
排版的原则.pdf
References:
TeX
LaTex
使用xelatex生成中文pdf
LaTeX/Errors and Warnings
cwTeX排版系統