标题: LaTeX新人教程,30分钟从完全陌生到基本入门 [打印本页] 作者: ∮蘑菇O_o沫 时间: 2014-5-17 00:49 标题: LaTeX新人教程,30分钟从完全陌生到基本入门 / K# Y2 ]: ?- {0 F6 V! c
注:文章里的代码我自己测试是可以直接复制进winedt编译成功的。但是有朋友反馈说编译不成功,检查后的结果大概是在发帖的时候,排版系统自主“智能”增添了一些换行符制表符等类似物。因此如果直接复制编译不成功的时候,请尝试手打一遍。(*^__^*) 嘻嘻…… 4 L, a$ T6 N6 K4 |5 [/ F) R! X ( f, d; v" k; }, Y* w" _/ v' _, F1.LaTeX软件的安装和使用 ( @; U! ^2 ], n
3 f: w! v% P- i3 z# N
方法A(自助):在MikTeX的官网下载免费的MikTeX编译包(150Mb)并安装。下载WinEdt(9.5Mb)(收费)或TexMaker(32Mb)(免费)等编辑界面软件并安装。 ( w3 M- S. m# ?3 e
方法B(打包):在ctex.org下载ctex套装(203Mb或1.3Gb)(含MikTeX及WinEdt)* d E4 i/ z1 a1 n
新人不必纠结软件问题,随便什么软件随便什么版本只要下载下来能编译出pdf来就可以,先下载了装上来试试再说。我推荐winedt也是方便我在介绍按钮样子的时候可以统一描述。, n1 w% _+ m0 v2 F }
6 S R/ |5 _! z* T1 f
2.第一个文档 8 ^" H" p& T) Q3 S打开WinEdt,建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8。 % W: c D+ L6 G& X3 b! P/ A$ O4 ` + L2 o; Z# e- m\documentclass{article} # ?$ V( ?' c. @" |: \" |+ a\begin{document} 9 O! R! t8 l4 n. c/ t% s hello, world & [; S' }0 l6 B8 j5 P" `\end{document} 8 _; F* S( A, ]# o; x. @, Y# _
7 l% e0 p: D% _+ u
然后在WinEdt的工具栏中找到编译按钮(在垃圾桶和字母B中间),在下拉菜单中选择XeLaTeX,并点击编译。 如果顺利的话,我们就可以顺利生成出第一个pdf文件,点击工具栏中的放大镜按钮就可以快速打开生成的pdf文件。 2 D& h3 N+ t) P& j h' S+ D5 ^: b9 ]# b- R; G; U
3.标题、作者和注释 1 z, x" h: A5 U' `* x! e建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 Z& \6 O# ^6 m8 w8 \ _( R) j
% [- T4 d) h1 [' @& n* V3 @3 a
\documentclass{article} $ ~1 T, [8 B! }1 z3 y \author{My Name} " h8 B. e) c8 s R1 B. F \title{The Title} 4 ?2 K( e: Q" @9 d
\begin{document} ) ?) O4 [0 K6 M5 Z5 [ \maketitle - c* _. L4 H7 D6 x" z hello, world % This is comment " l; h/ F0 ]$ s; F3 p* P1 T- [
\end{document}- h& A& r7 p% E# G* N
%意为本行右边所有内容被注释掉,在生成的pdf中不会显示。 , r- h% f; N1 c/ O. A0 S; N $ w& Z- s- U) F2 n* m2 Z! [" y/ r4.章节和段落 $ B/ x+ V6 B' w8 Y% ]/ h' w6 \5 k3 o
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 2 _2 ?6 ^/ R. h5 \ T1 V% q& _; n' ?. S0 Y1 R. i& T
\documentclass{article} 8 X/ S6 Y9 r( n# ^. i: v$ G) M \title{Hello World} % l& k# @" T9 o, X3 l
\begin{document} 5 w7 V& q8 o+ _ o \maketitle - z) l+ u( c$ H# Q* C' u
\section{Hello China} China is in East Asia. 1 U8 }+ d" Q, q8 ?) a1 ` \subsection{Hello Beijing} Beijing is the capital of China. # R2 d* R$ Q8 S9 ?5 O( E \subsubsection{Hello Dongcheng District} ! p! _6 \3 V6 ~' V3 k \paragraph{Tian'anmen Square}is in the center of Beijing % ~# e! J* H" ^+ }
\subparagraph{Chairman Mao} is in the center of Tian'anmen Square & }# j0 X. @5 e7 f; p
\subsection{Hello Guangzhou} ' }- ^9 Z7 i2 ?6 O: I3 R
\paragraph{Sun Yat-sen University} is the best university in Guangzhou. 9 m; P; D8 g/ E6 p/ w/ }6 T\end{document} " I5 \5 M. c3 k7 T$ j # r5 F; q- b) ]" Z+ @: m5 c) K退格只是为了看起来层次清晰美观。实际操作上未必要如此,每一行之前的空格不影响编译生成PDF的排版结果。 : }( ]9 a4 L2 l: t7 ^- A; r
9 L9 ]' A$ }6 u4 H# H5.加入目录 9 }0 E" G1 Q" j- A# ]* \& H" }
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 7 o6 D. b/ k) u- \; x! Q6 b. P ; P; q* X( h; E& a2 M7 s" l( o\documentclass{article} ' r0 |3 W; i$ g4 H3 x h( z
\begin{document} + A5 r$ M( ~' j, N1 ~ d \tableofcontents + z- @5 t$ E4 O \section{Hello China} China is in East Asia. ! | n+ p* p M% a \subsection{Hello Beijing} Beijing is the capital of China. ! V9 x5 R" j4 o5 s6 G2 V7 v P \subsubsection{Hello Dongcheng District} 0 J2 @+ ]9 |3 E# k' `
\paragraph{Hello Tian'anmen Square}is in the center of Beijing ( y! ~5 n, d2 K
\subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square 0 D+ Q# z/ n3 D\end{document} . Z' x. T. B+ l$ S4 A+ k
, S; `( `! w5 ?% M* _
6.换行 2 b$ r4 B* c4 m建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 1 O5 h$ r$ @& e
' T9 J( W5 k5 S! x
\documentclass{article} 2 T2 a6 G6 Q5 F* ~. ~7 X/ R\begin{document} 9 B8 o" w) p( C: M
Beijing is . G) h1 ?, g. L# \, S7 w$ Q3 o the capital . {2 S0 O, @ Q& ~8 |2 r( m" t of China. 7 s7 X- U, @% B: p' Z
! r! \6 r+ F- a/ ^ Washington is + U& F) l0 x- H* Q; P
3 S! @0 \- f/ j- |7 j, ~
the capital 7 f. a4 a6 I3 S( R3 s1 G E
" R) ~, a8 h5 G6 ?2 x2 F
of America. ( m' ?, I% G( `3 t" L5 x( |0 L. b
Amsterdam is \\ the capital \\ 7 l" c8 j7 j. H8 w3 b9 a of Netherlands. 0 `5 ^9 f( {; L8 x* E9 Q6 O
\end{document}$ O. k# j. Z) \, t' ?, |
+ K) Y4 j; c9 }9 D! {6 T. h空一行为另起一段,\\为段内强制换行。$ p& w5 ~. [* O: A) }4 L
我对之前手滑写出New York is the capital of America这类低级错误表示非常抱歉。5 i9 n: P! v- H) y0 a' |
5 R, z: Z+ X' [( i- I7.数学公式 ) n( [! K4 }1 @, e+ ?( U
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 # ]: ]0 V: S2 T# v4 A" [9 B( d4 ?% f( R$ I: `8 V
\documentclass{article} ]9 p( j4 ~: g* }* r
\usepackage{amsmath} 1 E9 |2 R3 G: m# T7 q5 Q \usepackage{amssymb} 1 z3 a2 A1 e% X: h z* n0 Y\begin{document} " L4 [) A4 ]2 e" @
The Newton's second law is F=ma. 6 j9 {5 H/ e- n% M3 `; c; |8 m9 Z7 N8 {; ?$ Y* Y T
The Newton's second law is $F=ma$. ; b+ N8 ?6 X) i4 G4 o. L + Y; Q5 p. t, A The Newton's second law is & c) B$ s! e* Y: M; U6 a
$$F=ma$$ . P, ]4 K' W( `5 @$ L
* h& N# q1 o$ T) G
The Newton's second law is 1 _+ _. m; h6 F \[F=ma\] . A2 r7 X6 ^: K& `2 J+ W
! N3 e* a6 L7 C$ }5 ^& m( g% }$ \
Greek Letters $\eta$ and $\mu$ : n' w" k7 K2 i: l& I5 d# O, e
3 y. g, x6 z& E' k
Fraction $\frac{a}{b}$ ; u. x: W+ k& C- }! G$ K% e; g
8 c+ ~5 V/ S& ^6 O, `
Power $a^b$ 7 i) v7 i# y+ W/ I9 M# M+ P 0 K2 {* Z+ z$ b1 n O Subscript $a_b$ & k5 H: n) C/ _# A% r) F2 l) m) B7 F" Z6 S+ y' d* n: M9 X( }6 V0 b5 H
Derivate $\frac{\partial y}{\partial t} $ 9 j" P- y5 f8 Q5 \" t$ n
$ L! i9 N- I& \! x* I5 q1 K( a2 o+ [
Vector $\vec{n}$ ( O! [$ }$ p& F, K7 ? z$ z: Q ) L e, H0 o8 S5 T' E Bold $\mathbf{n}$ : G8 Y% I, v8 m+ Y& w5 j# b: r$ f+ B8 n* u
To time differential $\dot{F}$ , l, Z u2 j* O8 A \7 ]; X5 k) m% Y5 {1 W, |* ~: c* x* ?* p
Matrix (lcr here means left, center or right for each column) & _; t3 u/ j; H b \[ % |: E# m! {5 k8 U
\left[ . E1 D0 u) I2 X. j! {% {) P% R
\begin{array}{lcr} 4 ~: P# |! u' u( M* w, Q
a1 & b22 & c333 \\ 4 [, ~& W# \6 h& }. I0 D d444 & e555555 & f6 * G' k/ \8 S& b/ n- Y, u \end{array} / l8 a8 B' u- ^+ E \right] 7 r% e6 F+ ~* [" J
\] ' n" Q u6 \4 J# N1 s* p1 i( {% s; [+ d' f1 S* A" C& m
Equations(here \& is the symbol for aligning different rows) / d& t6 n, `% W+ _\begin{align} - v) p7 {. n) I( g a+b&=c\\ # z. d7 H& Q8 b d&=e+f+g 5 i+ P: C' D3 B& k$ F: e1 M\end{align} ( _) s1 f) K' y4 j! N
( `# m G6 `+ v" P0 i, F& u\[ $ j" j6 Z* G: F& ~ \left\{ . u$ I! A1 O. T( l3 A5 [% Q
\begin{aligned} 9 M G$ A4 V B% N &a+b=c\\ - F9 q9 V# g3 C2 A &d=e+f+g $ Y! E* }& T3 [ \end{aligned} % Z# D& c% ~. F" L/ N, r7 d \right. 8 z5 V( S8 ]- q3 y
\] , U8 S/ e( n* r3 l! R& x; @3 F$ U8 k . A4 x. s) n0 N- z3 ^\end{document} , |2 d7 K5 N I6 u