% ctex-xecjk-nofonts.def: Linux 的 xeCJK 字体设置,默认为文泉驿字体 % vim:ft=tex
%WenQuanYi Bitmap Song:style=Bold %WenQuanYi Bitmap Song:style=Regular %WenQuanYi Zen Hei Mono,文泉驛等寬正黑,文泉驿等宽正黑:style=Medium,中等 %WenQuanYi Zen Hei,文泉驛正黑,文泉驿正黑:style=Medium,中等 %WenQuanYi Micro Hei Mono,文泉驛等寬微米黑,文泉驿等宽微米黑:style=Regular %WenQuanYi Micro Hei,文泉驛微米黑,文泉驿微米黑:style=Regular
\setCJKfamilyfont{zhsong}{WenQuanYi Zen Hei} \setCJKfamilyfont{zhhei}{WenQuanYi Zen Hei} \setCJKfamilyfont{zhkai}{WenQuanYi Micro Hei} \setCJKfamilyfont{zhfs}{WenQuanYi Micro Hei Mono}
cd /tmp vim new.tex #内容如下,保存 \documentclass{article} \begin{document} hello, world \end{document}
xelatex new.tex #编译生成pdf
打开生成的pdf查看。
2 .标题、作者和注释 编辑tex文件内容如下,并编译,查看生成的pdf并思考
1 2 3 4 5 6 7
\documentclass{article} \author{My Name} \title{The Title} \begin{document} \maketitle hello, world % This is comment \end{document}
3 .章节和段落 编辑tex文件内容如下,并编译,查看生成的pdf并思考
1 2 3 4 5 6 7 8 9 10 11 12 13
\documentclass{article} \title{Hello World} \begin{document} \maketitle \section{Hello China} China is in East Asia. \subsection{Hello Beijing} Beijing is the capital of China. \subsubsection{Hello Dongcheng District} \paragraph{Tian'anmen Square}is in the center of Beijing \subparagraph{Chairman Mao} is in the center of Tian'anmen Square \subsection{Hello Guangzhou} \paragraph{Sun Yat-sen University} is the best university in Guangzhou. \end{document}
4 .加入目录 编辑tex文件内容如下,并编译,查看生成的pdf并思考
1 2 3 4 5 6 7 8 9
\documentclass{article} \begin{document} \tableofcontents \section{Hello China} China is in East Asia. \subsection{Hello Beijing} Beijing is the capital of China. \subsubsection{Hello Dongcheng District} \paragraph{Hello Tian'anmen Square}is in the center of Beijing \subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square \end{document}
当然你也可以写成以下形式(去掉所有行前退格)
1 2 3 4 5 6 7 8 9
\documentclass{article} \begin{document} \tableofcontents \section{Hello China} China is in East Asia. \subsection{Hello Beijing} Beijing is the capital of China. \subsubsection{Hello Dongcheng District} \paragraph{Hello Tian'anmen Square}is in the center of Beijing \subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square \end{document}
加入行前的退格以在编辑时显得有条例,结构清晰
行前的退格与个人爱好习惯有关,以下不再做另行示例
行前退格不影响编译生成pdf的格式效果,编译时会被自动忽略
5 .换行 编辑tex文件内容如下,并编译,查看生成的pdf并思考
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
\documentclass{article} \begin{document} Beijing is the capital of China.
Washington is
the capital
of America.
Amsterdam is \\ the capital \\ of Netherlands. \end{document}
\documentclass{article} \usepackage{amsmath} \usepackage{amssymb} \begin{document} The Newton's second law is F=ma. The Newton's second law is $F=ma$.
The Newton's second law is $$F=ma$$ The Newton's second law is \[F=ma\]
Greek Letters $\eta$ and $\mu$
Fraction $\frac{a}{b}$
Power $a^b$
Subscript $a_b$
Derivate $\frac{\partial y}{\partial t} $
Vector $\vec{n}$
Bold $\mathbf{n}$
To time differential $\dot{F}$
Matrix (lcr here means left, center or right for each column) \[ \left[ \begin{array}{lcr} a1 & b22 & c333 \\ d444 & e555555 & f6 \end{array} \right] \]
Equations(here \& is the symbol for aligning different rows) \begin{align} a+b&=c\\ d&=e+f+g \end{align}
B .模版 模板就是在\documentclass{}后面的大括号里的内容。 在这一份教程中,我们使用的是LaTeX默认自带的模板article,以及中文模板ctexart。 模板就是实现我之前所介绍的LaTeX的经验总结的第二点的实现方式。 一篇文章,我们定义了section,定义了paragraph,就是没有定义字体字号,因为字体字号这一部分通常来说是在模板中实现的。 一个模板可以规定,section这个层级都用什么字体什么字号怎么对齐,subsection这个层级用什么字体什么字号怎么对齐,paragraph又用什么字体什么字号怎么对齐。 当然模板里还可以包含一些自定义的口令,以及页眉页脚页边距一类的页面设置。 由于模板的使用,在我的使用经验里来看,绝对不可能算是基本入门级的内容,所以在正文里当然不会提及。 如果有人实在想学,如果LaTeX已经接触到这个程度上了,那么再去翻其他厚一些的教材,也不亏了。
C .参考文献和制作幻灯片 做参考文献的时候,文章也已经快写到尾声了,而幻灯片更不是进阶一些的需求。对这两个功能有需求的LaTeX user,使用LaTeX也已经相当熟练了,自己去google一下或查阅其他厚教程是很理所当然的,一点也不冤枉。 在此我就只提供两个搜索关键词,参考文献可以搜bibtex,制作幻灯片可以搜beamer。