. Z. {) `6 ^5 O' x3 x! w
注:文章里的代码我自己测试是可以直接复制进winedt编译成功的。但是有朋友反馈说编译不成功,检查后的结果大概是在发帖的时候,排版系统自主“智能”增添了一些换行符制表符等类似物。因此如果直接复制编译不成功的时候,请尝试手打一遍。(*^__^*) 嘻嘻……$ ~( a5 P6 h; L
0 m6 q, f1 j. p# z5 l
1.LaTeX软件的安装和使用 i* p- J4 D/ ]3 Z5 H8 M3 j% o1 `* F2 M$ P: h
方法A(自助):在MikTeX的官网下载免费的MikTeX编译包(150Mb)并安装。下载WinEdt(9.5Mb)(收费)或TexMaker(32Mb)(免费)等编辑界面软件并安装。 . S+ x' }( p2 e9 |; I8 i0 W# W. ]" r方法B(打包):在ctex.org下载ctex套装(203Mb或1.3Gb)(含MikTeX及WinEdt)' B5 ]) f5 ?* P
新人不必纠结软件问题,随便什么软件随便什么版本只要下载下来能编译出pdf来就可以,先下载了装上来试试再说。我推荐winedt也是方便我在介绍按钮样子的时候可以统一描述。, [; E5 L1 e1 p+ X9 O( X9 r
- ~& c. \! R, j( j/ A. [* D
2.第一个文档 : t6 }) t( R* r) ]0 @' R' X: L5 z打开WinEdt,建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8。 4 w5 R2 M# W1 n2 T; w
0 ~1 r$ n& m0 S% B. f/ }
\documentclass{article} * Y" X4 ?( a2 [5 Q3 m! A
\begin{document} ! c- }/ t, C& J [5 a# ^% J" O hello, world $ \8 C: K/ G! {" s
\end{document} # n3 C4 C w( R, o4 Q
; i" A' M3 {5 U) |9 |6 G
然后在WinEdt的工具栏中找到编译按钮(在垃圾桶和字母B中间),在下拉菜单中选择XeLaTeX,并点击编译。 如果顺利的话,我们就可以顺利生成出第一个pdf文件,点击工具栏中的放大镜按钮就可以快速打开生成的pdf文件。 - L* c4 p$ Z- |! ^4 {
# d, p( k) v1 l! g
3.标题、作者和注释 # l/ a8 r) T# L6 N. U建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 8 a0 s+ c7 E0 `' `1 t5 y3 c2 ^
- i& e* S$ v* p) ~; p i; P! z\documentclass{article} $ D: j, \/ L5 b) y! b; G \author{My Name} " @- j5 ?5 e6 w0 x, p3 d
\title{The Title} 1 e! X6 b' {( p$ J' H& t\begin{document} 3 W" E& l3 [) M! s
\maketitle 4 D$ y% I$ f x1 L4 i& O hello, world % This is comment " p6 l# r6 L) S\end{document} , P- J* C7 `( Z) R%意为本行右边所有内容被注释掉,在生成的pdf中不会显示。% O( Q5 f- S& L9 A
2 R& S3 M6 w; Q6 c6 i8 S
4.章节和段落 5 {& r7 w2 z, u( x建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 $ z' g. k" b$ S2 G3 e
& j( I/ F# S" \/ ^* I
\documentclass{article} 0 ?0 M6 O6 H3 ] \title{Hello World} $ ^$ c! [1 O! Z0 e
\begin{document} h- Y2 }# b0 t$ k: c
\maketitle + v* k4 E$ B5 f3 [: w
\section{Hello China} China is in East Asia. $ A7 p2 e) q. S5 ?; i* G8 E
\subsection{Hello Beijing} Beijing is the capital of China. - m: |3 c; P8 _* x- G9 O
\subsubsection{Hello Dongcheng District} # N; i7 }( q1 ]! l
\paragraph{Tian'anmen Square}is in the center of Beijing ' d5 ]) K5 H- I& u H \subparagraph{Chairman Mao} is in the center of Tian'anmen Square u9 t" x3 y# u M5 X
\subsection{Hello Guangzhou} 4 U" q p9 p* ?( {9 g7 k \paragraph{Sun Yat-sen University} is the best university in Guangzhou. & `0 F( D0 R6 x\end{document} 9 s- N7 ^- P/ @ % e3 j9 k/ J# a0 E: d$ |$ o4 }退格只是为了看起来层次清晰美观。实际操作上未必要如此,每一行之前的空格不影响编译生成PDF的排版结果。 # o H, E8 E3 r, S
, @7 m6 N* P) ~- R. c/ d1 f5.加入目录 0 g5 R8 S; i6 _! y
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 . b5 E' N1 Q& I) V4 P; B, \, g. s% l2 y& N3 r
\documentclass{article} 6 z2 n# e, c1 |. C) w
\begin{document} - x8 j& [% ]1 }, c& z \tableofcontents % T" G0 j7 }7 z5 Z1 z7 X0 m: v
\section{Hello China} China is in East Asia. 6 x, [, [7 F, a( I
\subsection{Hello Beijing} Beijing is the capital of China. - \$ j+ C b' A& s% `+ W
\subsubsection{Hello Dongcheng District} 6 ^8 \2 w' n! {" [
\paragraph{Hello Tian'anmen Square}is in the center of Beijing $ @) j4 v0 k1 W \' w) G6 c- u
\subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square ! U4 p/ y% S. w% R5 U* `
\end{document} 2 S6 z/ z4 H/ h9 X T7 P6 o1 ?7 ^
6.换行 " X9 w6 u6 b; C; k" J
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 & J8 q5 Y& F: H) O w
, |( o" C3 J) U/ j" d\documentclass{article} 1 T0 ^3 o; R" r0 G- E9 c\begin{document} + r9 @/ ]% D& i1 r- f Beijing is : g8 P: q1 i- R
the capital + _' V" [1 z: b. P& |/ a- y
of China. ! n0 K+ B9 Y) G
/ {+ L% K+ e& n& e, e Washington is 0 N% R4 s8 X3 v" n; p 9 u6 ?* f9 V ]' A- O7 S the capital 0 U6 f j0 O2 L+ G
! v2 C# C G7 r5 g
of America. 6 s+ {8 t0 o/ ~$ h. h! n" o
; h6 L7 ~8 r* q4 `6 u Amsterdam is \\ the capital \\ 1 o6 r" e" T2 Q$ h
of Netherlands. * s* I/ f! O( [4 F4 G- ]4 S5 g\end{document}$ k1 L& K7 Y6 _) u0 h* i
; J; p* A# c4 n" Y: a* O$ V空一行为另起一段,\\为段内强制换行。 ( p) E% w% ^) l( k我对之前手滑写出New York is the capital of America这类低级错误表示非常抱歉。 - U2 p* L8 o3 y; R5 P* o: t7 Q3 K % b$ Y: [% _9 _- J7.数学公式 % p3 d+ N: d* p* o% a建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 6 U& \/ ~# r! O" ^4 [
: d X3 F; J' ? l: B% I\documentclass{article} 2 X' d, c- P n2 H0 [: d
\usepackage{amsmath} ; D7 j' e1 A1 U w+ a, r( h; u* T# W
\usepackage{amssymb} * Y3 N; Y. H2 v& A\begin{document} 2 L+ d: n, `+ a* r' `6 V The Newton's second law is F=ma. 2 m* u& q; R. l: I: V3 J5 ] / M* D" O- [- [5 H) R9 i The Newton's second law is $F=ma$. + X! }" V9 g% y" w1 \+ o8 i9 @( U3 H' s0 K, K" k6 d% N" m& x
The Newton's second law is ' N J3 ], o# K7 L6 f. A }
$$F=ma$$ * _9 u# Y1 O6 k0 R6 ?1 q7 n; e) S
6 v: P Q U+ }
The Newton's second law is 9 F% b' G1 {& N: \% u
\[F=ma\] 0 F6 ?# J6 m1 l- O8 [6 Y3 k. ^
n* [4 t7 ^( v. N" N' G# H8 j Greek Letters $\eta$ and $\mu$ . `8 @ _8 E& ?: A+ ]+ B' b2 d. H& j6 z
Fraction $\frac{a}{b}$ ( t7 G3 o) L; M6 Z; p L" R$ I/ U1 ^/ E* x3 P- L
Power $a^b$ 4 L4 g* ]1 C, d8 D/ o $ [$ B( T: d% O7 T& X1 b0 b Subscript $a_b$ + J! ^& e2 `' F. a6 \, E8 c7 \/ h+ c7 J
Derivate $\frac{\partial y}{\partial t} $ 5 A" K+ z( f f0 q+ L; j
4 [9 \' p, A. ^0 S! S
Vector $\vec{n}$ 4 q+ S2 p) _( w* t- ?# \6 b( v6 @: u/ j/ u/ u, e. p
Bold $\mathbf{n}$ * A0 F; ^+ D' G1 ~! i8 Q( e
& l: P* K' n3 h$ `( W To time differential $\dot{F}$ . ^& G: ^, M! w$ z/ G9 ], U
' p2 F# L, `) n e4 N+ E
Matrix (lcr here means left, center or right for each column) 3 ^( J: b0 L7 X6 B' c \[ 8 @/ b' r, w; ~) f2 {
\left[ ( Y" ?% q! T5 f. I" {/ D' G; h& D \begin{array}{lcr} , n; M. A( }& s0 g( |& e
a1 & b22 & c333 \\ ' |8 \( @3 Q- D
d444 & e555555 & f6 3 ], s5 v1 G# ~: \* l( t8 w \end{array} 1 J: x8 A. }( y/ l1 ?7 N& Z
\right] ' `7 L$ i9 _+ C. M) @% R( r
\] 9 t' R7 }% c2 ?3 |5 ^1 T. [& O8 q ! ~8 {' ^! |" ?9 }Equations(here \& is the symbol for aligning different rows) * U; N4 n$ Y7 o1 z\begin{align} : h# q t* U8 I3 o+ r k2 B a+b&=c\\ - o6 k$ w0 b- }! w+ K( I- H d&=e+f+g & r& _% ^; x O\end{align} + u! U& M4 a' T( W a 7 ?9 w) \% T+ W+ D/ p' t\[ 6 d0 ?- j6 y( F6 m9 v6 u
\left\{ " g# x9 g- B. ]( U7 f8 X
\begin{aligned} ! ^, U) J/ w& U &a+b=c\\ * B% ^4 j( v4 \/ f }& l5 ]9 [ } &d=e+f+g 7 N' n1 h0 s5 r( G5 J \end{aligned} 9 m- s; y) e1 t; j$ p' ~ \right. 1 @) u; H' A" C* I x\] 8 A/ x H, w0 z$ ^6 o9 h- } z( G S+ |1 k4 @& _+ y2 u" C- a1 N8 N. D7 Q
\end{document} $ ~/ J; D" |/ _: \$ Q, X' ~5 I4 c) |. ]. Y0 l* |
具体细节可以自行搜索LaTeX的数学符号表或别人给的例子。+ c% ~& g/ c/ }, C; }
$...$是开启行内数学模式,用于和文本合在一起使用。% L2 I" S9 z* P' |5 x: b3 L- h
$$...$$和\[...\]是另起一行居中开启数学模式。通常用起来差别不是很大,不过$$会修改默认的公式行间距,有时可能会对文章的整体效果有影响。 y8 o0 x1 a0 c ~" M% V4 _