) T9 e. {, u4 }3 V注:文章里的代码我自己测试是可以直接复制进winedt编译成功的。但是有朋友反馈说编译不成功,检查后的结果大概是在发帖的时候,排版系统自主“智能”增添了一些换行符制表符等类似物。因此如果直接复制编译不成功的时候,请尝试手打一遍。(*^__^*) 嘻嘻……# m f% w3 b6 X& U
7 K r5 t9 Z& ]/ R1.LaTeX软件的安装和使用 % M n0 z( T! w- e5 I* B # ]4 z- x0 k, u9 b* T方法A(自助):在MikTeX的官网下载免费的MikTeX编译包(150Mb)并安装。下载WinEdt(9.5Mb)(收费)或TexMaker(32Mb)(免费)等编辑界面软件并安装。 + ]( l" f7 _$ W" k! \4 R& z
方法B(打包):在ctex.org下载ctex套装(203Mb或1.3Gb)(含MikTeX及WinEdt) . i9 _6 T7 z" c0 p% \5 |新人不必纠结软件问题,随便什么软件随便什么版本只要下载下来能编译出pdf来就可以,先下载了装上来试试再说。我推荐winedt也是方便我在介绍按钮样子的时候可以统一描述。 - r. x/ R6 U2 T" D s1 O8 W . W) ?) W' N3 W; r1 |2.第一个文档 1 f( a% d$ X" ^2 P# @8 i7 e2 Q
打开WinEdt,建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8。 % H- x# e8 k+ q' A" y/ A3 [& W+ k, N! x! d
\documentclass{article} # A+ D' j) t. K/ H3 d" \/ Z\begin{document} + Q" M/ n' z6 x) ~( N: s2 V
hello, world : T. F* m( ~5 ?; b/ G9 d\end{document} 4 u- X- l. K! N2 i7 }3 j : A1 b1 N: n; i9 j p然后在WinEdt的工具栏中找到编译按钮(在垃圾桶和字母B中间),在下拉菜单中选择XeLaTeX,并点击编译。 如果顺利的话,我们就可以顺利生成出第一个pdf文件,点击工具栏中的放大镜按钮就可以快速打开生成的pdf文件。 4 t: y N) a* q * h [! V' ^. n- E( c2 r4 k1 I8 B7 ]3.标题、作者和注释 % q- }+ v$ u! p& k
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 1 \! O; Q, J1 z- k; I
$ X: i9 d! T- ]# t: T7 Q0 z
\documentclass{article} 3 g! H# u( y+ r; w; t* z8 V6 F5 Z1 o \author{My Name} 1 s* n- x$ ?7 @/ A- J3 [* Z B \title{The Title} # f- A5 _' \2 X3 n) |* R! G) }\begin{document} 4 E1 l0 C% m7 s$ o5 E8 W f \maketitle , Y5 W/ n: B1 Q& D" e) K6 v hello, world % This is comment 1 S) J0 l }: X7 N0 Z# P4 f6 t! o( n% v\end{document}' n. Q7 T. G+ t9 k8 b
%意为本行右边所有内容被注释掉,在生成的pdf中不会显示。1 `( G# f& H" y Q }2 H$ U+ `
+ B& j9 ]) E; I' `
4.章节和段落 0 I9 y( e/ H+ s( K1 k- R
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 ) [+ }, E6 Q4 Q4 \8 M- y( j! p8 q8 u5 H( i; S3 C+ q
\documentclass{article} 0 c$ l: b5 A8 s3 f' I
\title{Hello World} 1 p3 Q6 I, Z/ G: x1 _8 `- P\begin{document} % x5 Z' _( L& ?
\maketitle ; x M- K8 N- k: I
\section{Hello China} China is in East Asia. + e+ h! u; m9 j' s' u% v \subsection{Hello Beijing} Beijing is the capital of China. 7 a- b& b$ F$ V
\subsubsection{Hello Dongcheng District} 9 n8 @4 y6 {' u9 @$ j \paragraph{Tian'anmen Square}is in the center of Beijing 7 n$ j# U0 x. ?- [. l3 G5 \' z
\subparagraph{Chairman Mao} is in the center of Tian'anmen Square 4 o- h; }8 C3 ]/ ~
\subsection{Hello Guangzhou} * s% M& y6 y5 z- c6 o. t
\paragraph{Sun Yat-sen University} is the best university in Guangzhou. % v7 a4 f* Y) N, Z6 _& \1 b\end{document} 6 h# f& `. z: r+ s3 E" ?9 b- z * [" U$ m7 X+ d! p0 _退格只是为了看起来层次清晰美观。实际操作上未必要如此,每一行之前的空格不影响编译生成PDF的排版结果。 2 Q7 e. R# L) g; F" ~( W! P) z& c. O! g- v8 K: @, |! h
5.加入目录 ; P3 n" f9 G! n+ A M- i
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 ) M2 y+ A5 M9 v% L. ~
- q" M1 ~% n- m3 X6 C\documentclass{article} , N4 y4 U8 d; h\begin{document} ( N; M$ z% Q, @9 Z
\tableofcontents 1 {4 B' L' h, v8 o$ P \section{Hello China} China is in East Asia. + @$ r. n* ?5 b* f" \ \subsection{Hello Beijing} Beijing is the capital of China. B \2 U' J$ O" [ \subsubsection{Hello Dongcheng District} ) l, g6 n4 h/ Q S; v( l# d. C# Y \paragraph{Hello Tian'anmen Square}is in the center of Beijing " |) ^; `/ B, M0 T
\subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square ' {" _ R ^+ z- h6 ]- F
\end{document} u- w- d; X5 @$ {1 r h4 M& c* q# e9 Z6.换行 2 D9 z$ k4 Z0 w2 b建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 9 A4 T; @; L N+ k2 n! C! K4 m5 P* z F2 L, u- K
\documentclass{article} , |- Y0 D/ _- `- R" D$ W& P
\begin{document} + y5 I; R# N% N) Z) u
Beijing is 5 O/ @3 t. G `0 `0 ^/ N- R
the capital ) T9 ^9 w* N* I* G5 {$ z1 n of China. 0 X6 S0 n$ E4 M' {1 h ' l; ~+ J \8 U2 z9 r, }7 | Washington is * U0 v" d4 P) e * m+ i- w5 k8 P& _. c the capital : ~ D2 J1 ~( Y . Y! e3 N6 c! [; [( T of America. 5 ?: G9 _* u1 b, Q
% L! F3 B( Y& W0 p" b6 K: }0 b
Amsterdam is \\ the capital \\ ; a( n' O* P: G of Netherlands. ' U' ?' R- L* w\end{document}8 F0 S' n8 u% M# p J
% h( V& f* F% F. F
空一行为另起一段,\\为段内强制换行。, |( g( F; o* n
我对之前手滑写出New York is the capital of America这类低级错误表示非常抱歉。$ X% N" g: Q' A, B2 `. b
$ p W4 }; _/ U7.数学公式 2 N% r$ n9 h* H% e1 A
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 9 c z. f& P8 i" }& h# L! ^
$ e3 g5 ?" S0 }6 k3 ~: k, X" [
\documentclass{article} . x8 O4 d( j f; N* L5 V9 } \usepackage{amsmath} * u, P0 ], T: X8 i
\usepackage{amssymb} : ?9 P7 y8 B2 z0 ?, J" q- T8 B$ G
\begin{document} & \* O; K0 |( ?, `! `
The Newton's second law is F=ma. 5 ~+ `+ n! s& U- ^
M5 D& g& ~9 p6 v% p3 p The Newton's second law is $F=ma$. , F% g' m# U1 v3 V, u$ K ' E3 `; v3 X7 p The Newton's second law is # v4 Z0 I# F/ \: k) Z; L
$$F=ma$$ + n `& ?2 H: M- D
2 q4 D2 }0 I& y% ~3 h The Newton's second law is & \, G- v+ c6 a9 r) w
\[F=ma\] * u& y6 Q. l9 L4 w9 _1 K 1 ]* s: B5 b" M7 `3 N& ? Greek Letters $\eta$ and $\mu$ 1 U1 z; l2 v# {- f* \1 n, _ 7 q3 A4 r7 ~( b4 D, V0 B Fraction $\frac{a}{b}$ & R! @) k9 c {0 c) x) q$ O& z) d# h/ n! ^; V7 Z8 |; Q
Power $a^b$ 9 p" a: Y' A) X; i" H% N6 j% e
4 P0 @1 Y5 a4 H
Subscript $a_b$ ' W; o0 V; m, T9 { . v, c3 Q) k- n( x( c! G9 f Derivate $\frac{\partial y}{\partial t} $ ) R' w$ o+ n D- ?# o; O( ^0 L8 F/ J: r+ a5 P* m
Vector $\vec{n}$ & Y E+ d+ i% y2 u+ S5 M) W ' X1 H e" R' |0 }- ]4 v Bold $\mathbf{n}$ ; I) r% p3 O; I# |
8 e/ o8 M8 s# V9 _$ } R& G* R To time differential $\dot{F}$ $ T8 O3 Q/ t x& K9 X
$ j: z/ l& u0 P( o9 b b2 B- u Matrix (lcr here means left, center or right for each column) " z9 F7 S2 v- p% Y$ _# X" M: D \[ 9 g& z3 p% L3 r
\left[ 9 K D0 u$ X( @4 h \begin{array}{lcr} ]( _, b4 W: D, Z3 Z) R9 L( {+ l
a1 & b22 & c333 \\ 5 g7 J# L9 B+ e0 B d444 & e555555 & f6 * k/ `0 }. F% m" }9 B$ r1 N \end{array} $ n$ p, T) l( D& ?9 @
\right] ! Y, x% y/ Z4 p1 G" _2 I
\] 8 o5 G1 b8 s9 @# ?; ]* `3 g# e) b$ \/ S- g
Equations(here \& is the symbol for aligning different rows) 1 C, P- O4 }+ t# Y( i0 }6 n\begin{align} 7 p7 M6 _4 I) \5 P9 q/ F, r0 ` a+b&=c\\ " e- M* ]6 f m d&=e+f+g & K! V: Q3 y1 Z; R- N+ r\end{align} # u: h" ]+ n7 v$ C/ D% P' N$ M8 E
\[ : k7 w* g+ @' M) H6 c7 }$ C5 i, x \left\{ E$ T% ]* u2 i( e4 N1 [" C
\begin{aligned} ! @/ C) ^. W0 W, S &a+b=c\\ 4 B3 e* v6 x7 a- D &d=e+f+g # _, O7 E; [: G' ] \end{aligned} 9 ^; x4 v3 N+ ?# C. v \right. 9 H& F, n: Q4 p* z/ v( V6 H
\] S: E. f- P( t9 D( R7 [; i; U; z y7 v% q& a) m* s
\end{document} 0 m/ K; G& m3 S* H& {9 x) V& X
- }& e) U4 t6 N+ w具体细节可以自行搜索LaTeX的数学符号表或别人给的例子。 j4 \: w7 i/ W! M
$...$是开启行内数学模式,用于和文本合在一起使用。 - x o% f0 x4 r5 M6 m$$...$$和\[...\]是另起一行居中开启数学模式。通常用起来差别不是很大,不过$$会修改默认的公式行间距,有时可能会对文章的整体效果有影响。! J+ d- z" }* L5 j( i" y