标题: LaTeX新人教程,30分钟从完全陌生到基本入门 [打印本页] 作者: ∮蘑菇O_o沫 时间: 2014-5-17 00:49 标题: LaTeX新人教程,30分钟从完全陌生到基本入门 5 V/ [" w" H2 n4 M
注:文章里的代码我自己测试是可以直接复制进winedt编译成功的。但是有朋友反馈说编译不成功,检查后的结果大概是在发帖的时候,排版系统自主“智能”增添了一些换行符制表符等类似物。因此如果直接复制编译不成功的时候,请尝试手打一遍。(*^__^*) 嘻嘻…… 5 @% f& h9 z& u3 `; l7 s2 x5 H2 H* T7 C# r5 y# P
1.LaTeX软件的安装和使用 ( r# T' ]$ D$ G. U1 Z: R9 d/ u$ @ % Z/ ` l8 f: ~& }% l方法A(自助):在MikTeX的官网下载免费的MikTeX编译包(150Mb)并安装。下载WinEdt(9.5Mb)(收费)或TexMaker(32Mb)(免费)等编辑界面软件并安装。 * I$ _8 Z) g9 @方法B(打包):在ctex.org下载ctex套装(203Mb或1.3Gb)(含MikTeX及WinEdt) 8 x5 t6 x& g5 D- m; A; r$ l2 k! T新人不必纠结软件问题,随便什么软件随便什么版本只要下载下来能编译出pdf来就可以,先下载了装上来试试再说。我推荐winedt也是方便我在介绍按钮样子的时候可以统一描述。 + E9 i- h2 N b R% _ " @% A' O3 R- _) C9 [6 q% w A2.第一个文档 # l& |9 Y* H8 \' R; ^& v
打开WinEdt,建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8。 0 V4 x$ P" @2 G" K5 _' ?$ q6 P0 e' s+ g
\documentclass{article} 8 j l( o+ U! I+ d M8 i% v, h\begin{document} + z3 S9 ], D3 D6 \0 [
hello, world / t n- s. H+ Y7 g, {\end{document} ]+ s) h5 L& n! c
i" i2 c3 ^1 b$ s$ V0 N* N
然后在WinEdt的工具栏中找到编译按钮(在垃圾桶和字母B中间),在下拉菜单中选择XeLaTeX,并点击编译。 如果顺利的话,我们就可以顺利生成出第一个pdf文件,点击工具栏中的放大镜按钮就可以快速打开生成的pdf文件。 $ Y0 C+ f* r1 U R
6 z' {, m) e$ ~
3.标题、作者和注释 0 [4 y5 w, h6 u: o- F6 Q3 `建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 ; B7 c- u9 Z9 w, Q7 l& u
, `6 p7 p8 i/ N7 \\documentclass{article} ; e0 F. W( }4 @& j; K/ U# N$ x9 A( a \author{My Name} 3 E, x7 ]1 Y2 s \title{The Title} 9 D- R( }9 I3 W" o: n( }- w: q ^6 l\begin{document} " r$ `' |! m/ {- c4 m% `* C \maketitle 3 R- t% f, D+ l( ^7 V! d hello, world % This is comment & }3 j8 v0 n1 H! Y9 O1 v6 [
\end{document} " `, G8 d& p* ]& I, F+ L%意为本行右边所有内容被注释掉,在生成的pdf中不会显示。 5 ^8 M) ~) |' {: _! P4 N) I8 u6 L3 b
4.章节和段落 5 D' Y( _3 w& g0 P" K5 D建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 1 Y4 A9 k) J R; v
/ o2 G. v2 E) \8 U- Q3 S& a1 V0 `0 j% S\documentclass{article} * ~4 K9 o0 P8 B; \' y' s; C
\title{Hello World} # \$ Z4 X j5 [2 L, p: Z
\begin{document} ! ?& w# c' S1 G7 [3 Q \maketitle / \" b+ ~) g) N& l1 |/ S! j \section{Hello China} China is in East Asia. 3 m+ Y( m9 `. n+ D+ {, }' D4 r
\subsection{Hello Beijing} Beijing is the capital of China. $ Y$ I M* \, I
\subsubsection{Hello Dongcheng District} + m( _5 T' k# t& b* B8 N: m' S8 |! R- ~
\paragraph{Tian'anmen Square}is in the center of Beijing 4 Y/ A, m$ L+ L3 |# p \subparagraph{Chairman Mao} is in the center of Tian'anmen Square , p0 S3 Y6 A0 Q \subsection{Hello Guangzhou} + N" l* G* W, v' `6 n \paragraph{Sun Yat-sen University} is the best university in Guangzhou. 5 m. }+ K% u( q( Q\end{document} 8 y. J7 {1 y* `9 B5 J
8 J$ T! k8 X& \( }, E! w& ^) d. C退格只是为了看起来层次清晰美观。实际操作上未必要如此,每一行之前的空格不影响编译生成PDF的排版结果。 - y; }8 s7 I8 z! V 7 m+ s3 e# q: z% K5.加入目录 - V. s5 g$ K" ~1 X建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 * s, p, F' P* H3 _7 s ( O n4 _" ?: K/ V& F\documentclass{article} - Z6 d5 u( P: @+ F\begin{document} ' A5 [6 ~. R9 r- a$ J- A \tableofcontents 3 f1 N0 k+ q: m9 D \section{Hello China} China is in East Asia. 2 i- M. {6 u: v \subsection{Hello Beijing} Beijing is the capital of China. / X+ R' Z5 B# p- L2 ^ \subsubsection{Hello Dongcheng District} % X$ B Z% d2 `* J* w! ]. j \paragraph{Hello Tian'anmen Square}is in the center of Beijing s7 g. f( X7 ]1 p9 y2 p- Y8 L
\subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square . N: s2 ~+ p% P4 ]- ~. M% \
\end{document} ( b& x. }6 {2 K 0 T o+ o8 T, \( w6.换行 , @6 D9 n: B3 ]6 A
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 + \6 G' s0 }8 ]. f$ m6 F
6 h" e% G9 |1 [
\documentclass{article} 1 i" ], O* f2 o! M ^\begin{document} 0 R L4 L3 I% ~. V# L
Beijing is 6 h1 P: E7 Y2 |6 X1 V
the capital ) V; D% f/ {& M) i) j5 c+ ` of China. # D2 _6 a% K7 @% Z' c+ ^ [( r- z ' x6 t. t2 w& f0 u Washington is 9 W; p2 \& H3 X; c) O5 T
: _: P, g3 w/ i( D the capital 5 v% [' e( e* F5 |
. O7 j+ C) E* r' |( A of America. # }, \/ K# L* c6 J% [3 Q
8 v& g- S7 A& K% I+ P6 p5 M Amsterdam is \\ the capital \\ ; w. [2 o7 N7 z4 \% U$ O1 C
of Netherlands. 2 |2 T9 I+ q9 ~5 u- R- Q3 Q+ } ]; Z, |
\end{document} 9 I. t/ r0 G6 f. q$ P% j- J $ U2 K* Q# r3 b% b/ f) k空一行为另起一段,\\为段内强制换行。7 w" t9 I f& m8 _
我对之前手滑写出New York is the capital of America这类低级错误表示非常抱歉。5 P/ n' X! I7 H6 a, S, ^: o: @& X
8 a+ ^7 S/ Z+ p, Q9 A, v" Z2 J, U* Z
7.数学公式 8 `3 J8 f$ }+ x( ?, |8 C8 p
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 a, ]' q, X+ Z& ?2 g 8 x+ T0 z) w3 c r\documentclass{article} ( @+ Q! ^, j9 l1 n* e
\usepackage{amsmath} * H/ Z! W2 y1 Z/ `' V
\usepackage{amssymb} 7 F" w% w) S0 K9 K\begin{document} - M% ?+ X4 }6 o+ @& P/ a
The Newton's second law is F=ma. 2 L( ?6 y1 [* N. W! ]3 ~. o+ o5 P0 S; I. U! z( K
The Newton's second law is $F=ma$. 8 T% K( b% S3 S6 W
* O; V, U6 j& l! i/ B% M
The Newton's second law is / `! ]" Q S2 \+ p/ \/ b& H: B
$$F=ma$$ 7 ^7 \& T; H" i# [' c3 [
# }5 ^% Y T, h5 }# h [9 s2 X
The Newton's second law is 7 B; ^! g, T( W, j. R2 v
\[F=ma\] ( K; g7 _0 D5 B% v, q8 K" m% U/ T! a
D4 p5 O& F# I" `" L. U2 A4 g) A5 o, M8 S
Greek Letters $\eta$ and $\mu$ 9 H, U p- U/ k& Y+ a7 Q8 g c3 s( e9 m; b6 P2 l7 V3 h4 n8 ^% j* K, V6 R
Fraction $\frac{a}{b}$ & ~0 l, z8 _( N' h- T" b2 e
8 H0 V" Z* U2 B8 _
Power $a^b$ * v, h- }4 N. F# m- y& y( V0 {8 R5 ?7 i3 {4 H/ T) N) R
Subscript $a_b$ ! W, q% I% C: m. w1 [& W
n" ^$ Q) v7 }1 t) D) @! f" j# v
Derivate $\frac{\partial y}{\partial t} $ * {4 W1 k% W ]