8 ~+ Z- N5 G# ]1 d/ X7 U" C
注:文章里的代码我自己测试是可以直接复制进winedt编译成功的。但是有朋友反馈说编译不成功,检查后的结果大概是在发帖的时候,排版系统自主“智能”增添了一些换行符制表符等类似物。因此如果直接复制编译不成功的时候,请尝试手打一遍。(*^__^*) 嘻嘻…… $ H- g$ P" D J: {7 P1 C; O/ q# |2 ]* C2 O% I
1.LaTeX软件的安装和使用 - r1 S s. g5 M8 m) a1 x; ?: n. |- p9 d6 R
方法A(自助):在MikTeX的官网下载免费的MikTeX编译包(150Mb)并安装。下载WinEdt(9.5Mb)(收费)或TexMaker(32Mb)(免费)等编辑界面软件并安装。 7 E* E3 O" n) @0 B, g! {/ N2 W9 ~
方法B(打包):在ctex.org下载ctex套装(203Mb或1.3Gb)(含MikTeX及WinEdt) C& N8 w Q. u新人不必纠结软件问题,随便什么软件随便什么版本只要下载下来能编译出pdf来就可以,先下载了装上来试试再说。我推荐winedt也是方便我在介绍按钮样子的时候可以统一描述。1 H$ e' @0 m0 W8 E. p8 M$ C
2 a* |4 \4 M& `+ |- T
2.第一个文档 " n7 m i+ j2 W$ D) @% I1 x o打开WinEdt,建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8。 : J7 y6 ^7 w+ J( ~' w
- V- u- G& }1 U$ x% ~
\documentclass{article} c' P! p) s; M- t0 o/ `( x\begin{document} 7 F9 K, J- n6 q( U; @' k hello, world 2 z9 I! y/ n7 L _, y\end{document} , t0 l: u0 M& j _/ t: d6 ~: C ' \5 T0 }0 l3 I; t! j% X6 v然后在WinEdt的工具栏中找到编译按钮(在垃圾桶和字母B中间),在下拉菜单中选择XeLaTeX,并点击编译。 如果顺利的话,我们就可以顺利生成出第一个pdf文件,点击工具栏中的放大镜按钮就可以快速打开生成的pdf文件。 ; E, k% Y7 j; a, Y7 G3 R, y" i0 }! O- v9 `6 a
3.标题、作者和注释 - E4 W. B4 }6 Q$ t! M; j4 L
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 " @2 Z) e( n% y+ D$ [2 L
2 r$ c: g1 s8 O9 m
\documentclass{article} 2 a8 z9 E7 u! J# f3 w2 g+ c
\author{My Name} ) W. j* ]1 ~# m2 w8 {
\title{The Title} ! u8 d6 l: m, I0 A; Y
\begin{document} + M. t) I8 P; X9 V$ P; k
\maketitle 3 T4 ]# W+ Z: i' R+ G
hello, world % This is comment $ F& B8 B5 L# j" O
\end{document}9 W0 {$ q8 o' {4 |6 p' c/ l4 p, X: {
%意为本行右边所有内容被注释掉,在生成的pdf中不会显示。/ W: }0 `1 W& p3 ?) S7 E
8 `5 [2 G3 G7 M* K7 r4.章节和段落 7 c# X; y W+ x/ m
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 0 d3 W7 K- l5 N' ^% c& e# E
0 B) A. _' ?8 A6 t7 J" ~/ ]\documentclass{article} % w. |! S6 {4 N# f+ i \title{Hello World} 7 {5 e$ d! @1 M1 Y- e5 ?\begin{document} 8 k$ d) n. I( y9 R0 y
\maketitle * e% B$ v# u$ r9 l! X" D+ S; J \section{Hello China} China is in East Asia. ) T6 c! j* I: S- b7 z( _5 m* @' r \subsection{Hello Beijing} Beijing is the capital of China. * y& F* |% p0 N q8 v% X \subsubsection{Hello Dongcheng District} / P- M/ D0 ?) O2 H, w- h \paragraph{Tian'anmen Square}is in the center of Beijing , I& |# B& _9 y: Y5 o
\subparagraph{Chairman Mao} is in the center of Tian'anmen Square 2 l: y3 s. R3 g9 t. u4 k
\subsection{Hello Guangzhou} $ J7 b. t, x0 w K# ` \paragraph{Sun Yat-sen University} is the best university in Guangzhou. / H9 w4 Q. R6 A( P\end{document} . A4 z- ~, s! s: {
" I1 _. K! x7 P% [3 }
退格只是为了看起来层次清晰美观。实际操作上未必要如此,每一行之前的空格不影响编译生成PDF的排版结果。 ( W6 v5 x3 @5 x4 D! p# r0 p" h
# V# _8 W$ N) O! N5.加入目录 " {, B8 {- z1 A% b建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 ; y% X% ]6 a; C ) q8 h* V6 A1 N! I2 Z! g\documentclass{article} h/ D5 f1 s* E; \: @\begin{document} 1 X8 i- G8 S E" _" d" n% G W
\tableofcontents , g- W) u( B# I" i5 |- O0 T$ { \section{Hello China} China is in East Asia. C ]! p0 T* {7 b+ q* e
\subsection{Hello Beijing} Beijing is the capital of China. 2 C5 N3 q) n# ^" H! W: A2 W
\subsubsection{Hello Dongcheng District} % _" C- a+ f1 ~5 i! V! I
\paragraph{Hello Tian'anmen Square}is in the center of Beijing , R4 O4 ]' y' f
\subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square ; g) j c/ ]5 {$ K- S
\end{document} & y9 d* i3 z1 _+ A" K; X5 q+ y. `' f$ e0 F T# \
6.换行 % g5 Q& Z, V6 M7 D+ r, ?2 d6 d建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 T. R% Z2 e8 g( L# E
6 l" q I0 O- @& F- Y8 D* D\documentclass{article} 5 a6 A) z# q& A2 K- T
\begin{document} 2 e4 ?4 K2 x: J8 l1 B5 N+ f Beijing is 0 D1 c1 `. \6 ?
the capital + }9 H; |- ^+ n0 O! H5 D2 `2 H of China. 7 v: h# v8 W& x* Y7 N
y6 U" Z0 k$ X( ~- z Washington is * p. H9 e1 M6 k* Y/ J' k3 q& k" o% }3 V+ I2 l: h: R; R
the capital ' c! |0 p( o7 J7 L; J4 Q$ R4 q' C9 B( N3 z; e7 n" h; N8 h
of America. + v1 j; R5 F! r 6 \$ Q9 ?+ K3 J9 K# `8 u2 c# l3 e Amsterdam is \\ the capital \\ : E) j, q- K. l9 k2 i0 ?1 f
of Netherlands. . T; b* t' I: b( K5 X* l1 X
\end{document} ( F4 U9 V# d2 b3 A: ~ % s- F, R% X! ^, e. x空一行为另起一段,\\为段内强制换行。* J+ u5 i4 b1 s
我对之前手滑写出New York is the capital of America这类低级错误表示非常抱歉。3 D7 H3 \4 s& P) N6 B
' q# ^) ^- g; j4 u3 G4 ^% g7.数学公式 * p5 }3 v) x: T$ ~* H/ A) T' t9 K
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 - }( }' y6 ?6 S: p) s+ I 1 R0 w! E! q3 E5 b8 g: _8 {1 c3 \\documentclass{article} 1 x. R( r ? Z- Y* e \usepackage{amsmath} - ^! h# J0 X0 S7 ~& f' }3 _- M
\usepackage{amssymb} * O1 k F5 l0 ~# h
\begin{document} + ^4 O, P+ W! x The Newton's second law is F=ma. ! r* v3 p6 l* \. c! J: X' W) ~; l4 r6 n5 m
The Newton's second law is $F=ma$. 0 e5 d: s1 f0 P: s: Q" J ; k; \8 q: r2 T9 }" b' V& y The Newton's second law is 5 z7 i' N- W( E8 ^. V
$$F=ma$$ 3 V( B( D. s5 ~. g8 G6 t q9 o1 V% r
The Newton's second law is 6 K) F; H: f2 w b: Y* J \[F=ma\] 3 L7 `" v+ ^+ x # `6 M2 k, B# t3 ` Greek Letters $\eta$ and $\mu$ 7 x2 V& S% ~& }$ D: H( j. |, Z
Fraction $\frac{a}{b}$ 8 Z0 s! @; h( P# ]! U/ o % o6 A/ ]5 d# m7 K6 t Power $a^b$ 5 Q( U9 e0 a+ w; |$ B! ]( h$ ^. J5 [
Subscript $a_b$ 7 |; {5 Z& G) Q$ i7 z$ V0 j& E / c3 }$ {" C! d Derivate $\frac{\partial y}{\partial t} $ : f5 z8 x! _/ {) W) a! `7 P7 g2 K" W4 G# @
Vector $\vec{n}$ , h" _' W3 E4 ^1 m& w
( I, [3 G6 v& b/ x) K9 b
Bold $\mathbf{n}$ + j) K5 _+ z7 g; r7 a) W 3 E1 D' I. k$ E To time differential $\dot{F}$ 9 G! y( j/ `2 \& r" |8 R# o \ e7 e8 @( T
Matrix (lcr here means left, center or right for each column) + `5 v }: A& N3 [
\[ # E5 j( |6 t/ C( B7 _1 | \left[ ' h/ x7 C% J* U. M7 P
\begin{array}{lcr} ) X# z+ x6 J1 |- v a1 & b22 & c333 \\ ) M7 d7 P9 X6 v. S" G5 O3 W2 U' W
d444 & e555555 & f6 0 f1 }: j9 B4 ]6 f$ X% C8 v v1 ~
\end{array} ! E% Z T" B6 C5 G$ h- t1 Z
\right] + c% }2 `' t. K' l8 f
\] 4 ]' s% o( }/ k
" N4 R- Y0 C' V, v8 uEquations(here \& is the symbol for aligning different rows) 4 v2 n" a/ W1 |, \0 ~3 ^" |. E\begin{align} 3 ^0 \! |% f' e4 n3 Y+ m% Y# @* _
a+b&=c\\ & ~7 f9 V$ V8 l( q( I! I& L
d&=e+f+g . I% F7 z1 Y2 Z! ^5 P" |\end{align} 4 c. S8 }$ d' I8 O, e* A6 z & r i! |! [# b\[ ! j" y3 ^3 l8 D0 u% s
\left\{ - @7 H, U8 `5 D7 [, {2 J- G
\begin{aligned} . d# k: W) ]5 m }8 v( n
&a+b=c\\ ( o, z$ d# W( L P2 E: V
&d=e+f+g , a2 Q3 D! M/ s; n# V \end{aligned} 4 ]9 T: s; ?* J# _" l& m \right. # V4 i2 j8 y' S2 M\] 9 F& ^, d0 F8 [5 P5 P5 C5 ~ " m6 n: z5 [- v\end{document} 8 m2 k, K6 R- Y8 m! z2 [* e 7 P9 c- W# ^! o! r3 @4 K+ H具体细节可以自行搜索LaTeX的数学符号表或别人给的例子。 0 _! @+ _. E+ {4 ~7 e# P$...$是开启行内数学模式,用于和文本合在一起使用。$ x8 G3 w" B! h4 Y7 a: L4 [
$$...$$和\[...\]是另起一行居中开启数学模式。通常用起来差别不是很大,不过$$会修改默认的公式行间距,有时可能会对文章的整体效果有影响。/ a; {* q& I2 S/ Y/ K: t