8 Z! ~7 b+ L% }. M9 I& S' m3 k
注:文章里的代码我自己测试是可以直接复制进winedt编译成功的。但是有朋友反馈说编译不成功,检查后的结果大概是在发帖的时候,排版系统自主“智能”增添了一些换行符制表符等类似物。因此如果直接复制编译不成功的时候,请尝试手打一遍。(*^__^*) 嘻嘻……+ e, Z7 A, p; C/ T
$ \1 K6 a! A; @0 s4 h, n/ q
1.LaTeX软件的安装和使用 & }* B) O% f9 z" t' Y0 j* H7 O 0 j: u% T1 r( q- ^4 t9 L: B- \方法A(自助):在MikTeX的官网下载免费的MikTeX编译包(150Mb)并安装。下载WinEdt(9.5Mb)(收费)或TexMaker(32Mb)(免费)等编辑界面软件并安装。 , k9 ~: p$ R/ j
方法B(打包):在ctex.org下载ctex套装(203Mb或1.3Gb)(含MikTeX及WinEdt) e" ^5 r4 t% j
新人不必纠结软件问题,随便什么软件随便什么版本只要下载下来能编译出pdf来就可以,先下载了装上来试试再说。我推荐winedt也是方便我在介绍按钮样子的时候可以统一描述。 ) [/ n Y. D' C& n5 i2 `3 J 1 q2 T. t6 A5 }8 A2.第一个文档 $ g" L/ S% u' ^0 E
打开WinEdt,建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8。 . j4 l8 `7 g3 ~6 b8 d8 X& R7 B( Z( |$ W) T3 }. N
\documentclass{article} ) ` ^. o5 P8 ?* j7 |: P2 t) _
\begin{document} $ }. [+ S; n5 M3 Y4 m9 M G& l
hello, world . F% s6 o1 h0 k$ H( |0 ]2 @. E\end{document} 7 m, P2 S& N8 y
8 Q3 y. s. i4 F( v' ~ o2 i
然后在WinEdt的工具栏中找到编译按钮(在垃圾桶和字母B中间),在下拉菜单中选择XeLaTeX,并点击编译。 如果顺利的话,我们就可以顺利生成出第一个pdf文件,点击工具栏中的放大镜按钮就可以快速打开生成的pdf文件。 }* s S4 ~) i1 D' ^8 u8 L4 Y
( e0 |% ^8 G2 @3.标题、作者和注释 . C/ v4 B: K% R E9 ]建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 2 k) l1 q$ N( i( `) `' d6 W% [6 v- @/ L
\documentclass{article} ( _: Y0 A6 _* ]* Q0 Q8 s/ o& |
\author{My Name} 7 }4 E4 s8 f2 \, @( S \title{The Title} : h; B' l' r, B: @! ]& J( y( T
\begin{document} : ?# K6 M6 g" E4 O. T
\maketitle ) h( ~$ W# N( x3 B hello, world % This is comment 0 `$ z4 b9 _% \% |9 n/ v\end{document}) l2 V: @: a. c
%意为本行右边所有内容被注释掉,在生成的pdf中不会显示。$ d% @, r: p) Z V$ U4 p
$ q7 s* I A2 q! |* l; s9 S* V; E
4.章节和段落 - z+ b4 n9 s% }1 I, r/ J
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 3 @( R# }8 X0 W- | }- W7 E( `2 z$ g2 H
\documentclass{article} . L! I4 C1 N0 H
\title{Hello World} 8 {* ?% C, @7 e\begin{document} 7 b; N1 j6 W/ W( z
\maketitle : L6 t* q1 i2 x2 x" y
\section{Hello China} China is in East Asia. # T- `# R( I! b; F# M0 @2 z+ _' I: v \subsection{Hello Beijing} Beijing is the capital of China. 6 n- m4 V9 k" A$ [) }0 T
\subsubsection{Hello Dongcheng District} 5 J* r; h5 B/ D- e
\paragraph{Tian'anmen Square}is in the center of Beijing " F7 v# D1 t8 c6 s% N/ ?6 } \subparagraph{Chairman Mao} is in the center of Tian'anmen Square ) R( i9 B, G* C: @" M, e I7 \2 q/ Y \subsection{Hello Guangzhou} 0 V; n! ]8 [4 \% \
\paragraph{Sun Yat-sen University} is the best university in Guangzhou. + h! _6 B; ^8 R+ C; A8 j' u
\end{document} 7 q' J* l: Y& `! z9 ^. _
. c2 m; @5 n. D* U, S: F9 O退格只是为了看起来层次清晰美观。实际操作上未必要如此,每一行之前的空格不影响编译生成PDF的排版结果。 " W Y" t6 s* h6 k
/ {9 v# E" G# A; m0 p4 }$ \
5.加入目录 & a7 }% A+ g7 ~
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 ( K; `$ B% Z' a
5 p, H& y# V$ ], g3 u$ z0 n
\documentclass{article} , h5 k, n! @ {. Z3 C3 _
\begin{document} ' f5 l6 ^1 H( {; T# r& ?3 H& c \tableofcontents " w$ ~. u: K1 G
\section{Hello China} China is in East Asia. 0 n( V2 u+ |% m$ ^% T% }4 x \subsection{Hello Beijing} Beijing is the capital of China. & X" f* ~- H* r( F6 R Z
\subsubsection{Hello Dongcheng District} 9 h4 h! i4 N. D! t; R0 C" I6 v
\paragraph{Hello Tian'anmen Square}is in the center of Beijing ' J3 A" h+ \+ r2 j
\subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square ' X* w }% R( @5 o" ~! H\end{document} 3 L+ t+ o- I& q. A. r. T% v9 O
# s7 H u0 {& E0 w! p# i; m
6.换行 : o j5 R' x. r" R2 Y* U/ C建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 " B! y. y Z( N
" i& _1 s2 |4 e' G3 B
\documentclass{article} ' k3 W2 {% a% ]' @\begin{document} & H3 X7 b; O. e2 _
Beijing is 4 k6 \ Z/ W+ [0 G+ K the capital * s0 p# Y2 D( ]6 X% M of China. & ?3 ?3 C% t, n& w) K( ]* O8 I/ @6 e - f, c: U3 l' r4 P& F Washington is - W7 w( ?" y8 ]! R4 ]2 i# @
# R8 z* e! _: j% p: a
the capital . y: e# Q; ~/ y: t) q6 C & { U2 b& h/ y/ \$ h& Y( x3 ] of America. / J; B0 Q7 H I; q y% m4 H% S 2 t/ P6 s3 A8 w' ?9 D1 Q9 M" F Amsterdam is \\ the capital \\ / I5 y/ f4 {! T6 W( C of Netherlands. 6 g* {. g) [ e' r. s; x\end{document} c6 ]5 |5 e" T. o1 W4 e
7 \# M4 j: f. d) ^空一行为另起一段,\\为段内强制换行。 }' K& V7 |! J3 G- o
我对之前手滑写出New York is the capital of America这类低级错误表示非常抱歉。9 [4 r9 ]5 h: D5 {7 G
i& s/ ?' f# b4 y( m
7.数学公式 " v! T, o6 P q6 P8 f
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 ( N7 M" `$ R; j8 P. v) }4 T- j$ c( j/ ^9 T# n4 ?
\documentclass{article} " \# Q1 s# l* _2 p4 _* r
\usepackage{amsmath} 1 @ A+ L/ L1 R \usepackage{amssymb} " Z$ D2 D8 ^# y
\begin{document} 8 u7 P- G6 y2 g9 \' h9 L The Newton's second law is F=ma. / m7 G; v2 F, c9 g, P, I5 b
3 i1 c" U$ N9 L! M( x( u The Newton's second law is $F=ma$. 2 B1 {5 U& n# ~ D% I1 g) l6 O( U5 c7 v
The Newton's second law is - y; v) Z/ o/ x3 `
$$F=ma$$ : d. @5 Y2 |+ e) t$ t. s/ Z6 z
The Newton's second law is - }6 ~' Y0 T N6 `- U \[F=ma\] k" J9 a0 T* l4 E/ r m2 f5 ]) | & p) i* b' V" Q7 J6 s, Q Greek Letters $\eta$ and $\mu$ 2 ~* S; D% Y" n1 [+ g , r- c+ j( e; n, ^. m7 G" b Fraction $\frac{a}{b}$ - j+ d* | {2 y3 ?5 {6 p3 V6 ~% @, Z/ x# c# Z1 p
Power $a^b$ % y% Z- D' z. @1 o$ U$ V8 p$ j& z7 o4 q" J! Y" y1 c+ l! T; w
Subscript $a_b$ : S& t! h7 m1 y4 a" d. T5 f9 r 4 @. y( K/ i3 t; u; u Derivate $\frac{\partial y}{\partial t} $ 5 d- W6 m5 v# @* _8 y( M/ m # L; c1 s W" s* y Vector $\vec{n}$ 5 l6 e2 e2 O1 |) b; x
+ x) a2 T, D; f: i# ]
Bold $\mathbf{n}$ 3 B" s8 k& l' z' t7 }) z9 K) s6 r
To time differential $\dot{F}$ 3 b; K1 A ]4 ?! w
6 D0 ]7 y& F. l0 L% {) a6 P
Matrix (lcr here means left, center or right for each column) 5 m8 B# N+ `; F' n, q7 A" `
\[ 2 P1 ~8 ~- @9 S& Z9 @4 h
\left[ 6 v9 C9 c, N9 S) V# |
\begin{array}{lcr} H6 |; w: r% r" I8 t1 [# G. _( v a1 & b22 & c333 \\ + l }0 q" z! ^; t d444 & e555555 & f6 : X3 m' q7 Z! Y3 J; i
\end{array} e/ S* C. s$ W3 \- r
\right] 5 E' ~: o" k! t5 b# u7 r; |
\] 4 I. Q. h) r* w" F; g; {7 E 1 u2 n' [* `, W+ o7 s4 P/ w, `& A. bEquations(here \& is the symbol for aligning different rows) + l1 E5 h8 B' h6 J( O! ]4 E\begin{align} " x! f2 ]7 a8 m; B' T9 }
a+b&=c\\ 4 [9 ?( E6 h4 K, j4 ~ d&=e+f+g $ \$ @" u* d$ s' u
\end{align} ( {( l0 b) ^( U# ~ \6 Z. _0 x 3 l4 T4 U' |4 v* t* z\[ # U2 u! N5 d* z5 D* z
\left\{ - _2 `- Z8 k* u+ U& h# b* r! ]
\begin{aligned} 1 G" E, x. j. D5 i
&a+b=c\\ , a- }4 p$ `. D+ R &d=e+f+g - F, U W& Q$ O
\end{aligned} % x# p, b: j; s" e8 i2 B v \right. % T& r# q; h# O" d! \8 `
\] # P6 O+ T* `, o4 r) G
+ X, o( f. N/ A6 G; f! w% \& M* X\end{document} ! \9 {9 w& _% Z; u$ B* L & R, D1 q. f3 I" [0 H% h" j具体细节可以自行搜索LaTeX的数学符号表或别人给的例子。7 O8 q$ q; ]2 c V
$...$是开启行内数学模式,用于和文本合在一起使用。, A3 n0 D9 s4 e) O0 G( z
$$...$$和\[...\]是另起一行居中开启数学模式。通常用起来差别不是很大,不过$$会修改默认的公式行间距,有时可能会对文章的整体效果有影响。 , _- t% |: }- g8 l: z6 ^1 h7 G
PS:有一些网站可以通过画图的方式来生成公式,有的编辑器集成了各种数学功能按钮。这对于公式需求少的人来说很方便,具体信息可以自己去搜索。但是如果你的文章中要出现大段的证明过程,就会发觉还是要老老实实地google一篇latex数学符号表,然后不懂的去查代码,自己用手指敲来得干脆利索。再进阶一点,可以去搜一下有关LaTeX的自定义command的内容去看一下,在敲公式时能省很多力气。 9 s9 q& D& p3 } 8 ?# z, X* X6 T; U3 G* M8.插入图片 - |- c7 C) B8 e# M3 O
将待插入的图片姑且先命名为figure1.jpg $ d% ^3 R+ ~( i9 M% x6 H( i; A
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,放在和图片文件同一个文件夹里,编译并观察现象。 ; C" Z4 l2 @3 Z' {. J4 R( `( U( I( ]1 I( z u T. ], H! ~ a
\documentclass{article} 2 w5 n8 m9 l1 i* Z
\usepackage{graphicx} 6 z p1 s+ ^5 |7 Y\begin{document} u2 H# Y8 G, p5 M O, E \includegraphics[width=4.00in,height=3.00in]{figure1.jpg} 8 P3 P0 S+ \9 P( Q# h
\end{document} 8 C& \. i% X5 ~: D. E* e . L2 ~/ i" h* I$ kPS:在老版本的LaTeX中是只支持eps图片格式的,现在的LaTeX对jpg、bmp、png等等常见图片都可以支持。/ r) C& t0 `* b/ n/ C2 y
" d, r2 m7 k3 [) N- L2 P+ H# {9.简单表格 * A/ a) J; K3 E: K5 C
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 7 s s+ K' t3 h: o3 E
& S+ B, t3 ~* C g' S3 ]% \
\documentclass{article} # z( c. a/ n9 T* I\begin{document} , Z, f3 Q! u! `9 y4 ~ \begin{tabular}{|c|c|} |9 D) D: p8 @2 G% d' L aaa & b \\ ( G& D/ n5 o5 [/ x9 e
c & ddddd\\ 0 M6 @* ~1 u! r% S' U% W& k# A0 J/ a
\end{tabular} 7 Y. X, T5 b t+ X$ B( A, G( A5 P
3 [5 h: @2 h' w
\begin{tabular}{|l|r|} a Y' [2 J. |$ M. G
\hline F+ R+ M7 i0 X/ y, h aaaa & b \\ . w k4 O- |& r5 S4 { \hline 1 }5 e" G, C9 e6 F) B) K c & ddddd\\ 4 q# {# F# S& N9 J \hline # V5 {; p0 S$ N% j- _- ` \end{tabular} # i# x% t/ x( G$ [ \begin{center} $ ~" D7 S. x7 E& F$ \9 ? \begin{tabular}{|c|c|} " i3 M$ G9 }$ |! ]2 g% e
\hline 6 W# |! ^; p, `" ]2 X a & b \\ \hline / T" E5 ^5 }3 m9 l0 P c & d\\ 1 f" ~' _! O$ u7 Z7 `7 ?$ z/ s5 E) _
\hline 2 S: Z7 r/ u: O q$ v& @( Q
\end{tabular} 0 D/ t9 C, A; D$ m9 W( S \end{center} & P6 l! ]' H9 B% O a R, t
\end{document} . P0 _; t \6 O) @/ J注意观察有无\hline和有无\begin{center}的区别。注意观察\begin{tabular}后的lcr的区别,分别是left对齐,center对齐和right对齐。 " @" m! i, x4 I0 V" d V6 V# p
' w+ n- k* o( A# Y' L
10.结尾 / Q; K/ o& ~7 p% Y到目前为止,你已经可以用LaTeX自带的article模板来书写一篇基本的论文框架了。在论文从框架到完整的过程中,必然还存在许多的细节问题,比如字体字号,比如图片拼合,比如复杂的表格等等。 : S! E. M% r4 y6 U ^
那些问题可以咨询google。通常来说我们作为初学者会提出的问题,早就已经有许多的先辈们在网络上提过同样的问题了,看看别人的回答就可以的。 ) [$ Y2 C9 U: C7 O8 Q=============================== , s& h. [0 }! m$ ~' J
附录(有些我认为不是新手急需,但的确是比较有用的信息): X* u& Z9 u! q/ z