星期四, 九月 10, 2009

更多Latex的功能

一,在Latex文档中产生空格
1,
\hspace{xx} 产生xx长的水平空格
\vspace{xx} 产生xx长的垂直空格。

Latex里面的长度单位有:
pt  point         (1 in = 72.27 pt)

pc pica (1 pc = 12 pt)
in inch (1 in = 25.4 mm)
bp big point (1 in = 72 bp)
cm centimetre (1 cm = 10 mm)
mm millimetre
dd didot point (1157 dd = 1238 pt)
cc cicero (1 cc = 12 dd)
sp scaled point (65536 sp = 1 pt)
当换行时,\hspace{xx}产生的空格会被取消,如果要强制指定产生水平空格,用\hspace*;
同理,当换页时,\vspace{xx}产生的空行也会被取消,强制指定用\vspace*。

2,但句子结尾时,'.'后面会自动加上一个空格,当有些情况'.'并不是句子结尾。
比如Mr.Wu, etc.and,这时要在.后加上“\ ”(反斜线+一空格)。

3,换行时latex会自动把词拆开,如果不想2个或个词被拆开放在2行,可以用在词与词之间加上~。

4,\noindent强制不缩进,\indent强制不缩进。

二,列表
1,编号列表:

\begin{enumerate}


\item

A
\item
B
...

\end{enumerate}
将产生一个列表,列表里的子项A和B将被自动标上编号1,2...

2,无编号列表
用itemize代替上面的enumerate,则产生无编号列表。这时编号1,2...将被一个大黑点代替。

3,描述性列表
在编号列表的item后面加上{xx},这时xx将代替编号1,2...作为每个子项的前缀。

三,显示引用
1,\begin{quote} ... \end{quote},整个引用都将缩进,但引用内部的每一段不再缩进,适
合于短引用,比如一段话。
2,\begin{quotation} ... \end{quotation},整个引用都将缩进,而且引用内部的每一段还将按正常格式再缩进。

四,表格
\begin{tabular}和\end{tabular}表示开始和结束

格式举例:
\begin{tabular}{format}

\hline
$n$&$n!$\\
\hline
1&1\\
2&2\\
3&6\\
4&24\\
\cline{1-1}
5&120\\
6&720\\
&5040\\
8&40320\\
9&362880\\
10&3628800\\
\hline
\end{tabular}
format可以是以下几种值的集合
l 表明对应的列要向左对齐
c 表明对应的列要向中对齐
r 表明对应的列要向右对齐
p{width} specifies a left-justified column of the given width
| 在列与列之间插入一条竖线(即网格)
@{text}在列与列之间插入文本text

(注:如果想要无网格,则format里不加入'|')

\hline表明插入一条水平线。
\cline{x-y}表明从x到y列(包括x和y)加入一条水平线。

&分隔没一行的列,如果要把某一格(即对应某一行某一列)置空,则直接用&跳过。
\\表明换行


合并表格:
\multicolumn{num}{fmt}{text}
num表明总共要占用num列的宽度,fmt为子项的fromat,text表明子项的内容。

下面是一个比较复杂的例子:
[GIF Image]

\begin{tabular}{|l||l|l||l|l|}

\hline
&\multicolumn{2}{l|}{Singular}&\multicolumn{2}{l|}{Plural}\\
\cline{2-5}
&English&\textbf{Gaeilge}&English&\textbf{Gaeilge}\\
\hline\hline
1st Person&at me&\textbf{agam}&at us&\textbf{againn}\\
2nd Person&at you&\textbf{agat}&at you&\textbf{agaibh}\\
3rd Person&at him&\textbf{aige}&at them&\textbf{acu}\\
&at her&\textbf{aici}& & \\
\hline
\end{tabular}

五,Latex的总体格式
一典型的例子:
\documentclass[a4paper,12pt]{article}
\begin{document}
......
\end{document}
1,
documentclass
的样式包括article
, report, bookletter。
方框里的列表为可选的,可以包括:
11pt:字体大小为11个pt
12pt:字体大小为12个pt
twocolumn:输出分为2列
a4paper:输出为A4纸

2,页码
\documentclass和\begin之间加入\pagestyle{option},option可以是:
plain:页码在底部,这是文章和报告的默认格式
empty:无页码
headings:页码在顶部
myheadings:
Similar to the headings pagestyle, except that the material to go at the top of the page is determined by \markboth and \markright commands

六,自定义宏
这一般用在同一文章中多次出现同一公式的情况下,自定义宏可以省去很多时间.

Defining your own Control Sequences in LaTeX

Suppose that we are producing a paper that makes frequent use of some mathematical expression. For example, suppose that integrals like

[GIF Image]
occur frequently throughout the text. This formula is obtained by typing
\[ \int_{-\infty}^{+\infty} f(x)\,dx.\]  
It would be nice if we could type \inftyint (say) to obtain the integral sign at the beginning. This can be done using\newcommand. What we do is to place a line with the command
\newcommand{\inftyint}{\int_{-\infty}^{+\infty}} 
near the beginning of the input file (e.g., after the \documentclass command but before the \begin{document} command). Then we only have to type
\[ \inftyint f(x)\,dx.\]  
to obtain the above formula.

We can modify this procedure slightly. Suppose that we we defined a new control sequence \intwrtx by putting the line

\newcommand{\intwrtx}[1]{\int_{-\infty}^{+\infty} #1 \,dx} 
at the beginning of the input file. If we then type the line
\[ \intwrtx{f(x)}.\]  
then we obtain
[GIF Image]
What has happened is that the expression in braces after \intwrtx has been substituted in the expression defining \intwrtx, replacing the #1 in that expression.

The number 1 inside square brackets in the \newcommand line defining \intwrtx indicates to LaTeX that it is to expect one expression (in braces) after \intwrtx to substitute for #1 in the definition of \intwrtx. If we defined a control sequence\intwrt by

\newcommand{\intwrt}[2]{\int_{-\infty}^{+\infty} #2 \,d #1} 
then it would expect two expressions to substitute in for #1 and #2 in the definition of \intwrt. Thus if we then type
\[ \intwrt{y}{f(y)}.\]  
we obtain
[GIF Image]

七,定理环境
这多用于数学推导,证明等的文章中。

Theorem Environments

In LaTeX, one can create `environments' for statements of theorems, lemmas, propositions, corollaries, etc., and also for proofs, definitions, examples and remarks. These can be established using appropriate \newtheorem and \newenvironment commands: these commands are best included in the LaTeX input file before \begin{document}. The following code will create theorem,lemma, proposition, corollary, proof, definition, example and remark environments, together with a control sequence\qed which produces `tombstones' for the ends of proofs:

\newtheorem{theorem}{Theorem}[section] \newtheorem{lemma}[theorem]{Lemma} \newtheorem{proposition}[theorem]{Proposition} \newtheorem{corollary}[theorem]{Corollary}  \newenvironment{proof}[1][Proof]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}} \newenvironment{definition}[1][Definition]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}} \newenvironment{example}[1][Example]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}} \newenvironment{remark}[1][Remark]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}  \newcommand{\qed}{\nobreak \ifvmode \relax \else       \ifdim\lastskip<1.5em>
(For an explanation of the syntax of the LaTeX commands used to define the above environments, consult the LaTeX User's Guide and Reference Manual by Leslie Lamport.)

The statement of any theorem can then be enclosed between \begin{theorem} and \end{theorem}. The theorem will be labelled and numbered by LaTeX, and the statement of the theorem with be automatically italicised. Lemmas, propositions and corollaries will be treated similarly.

To introduce cross-references, one can give the command \label{name} within the statement of a theorem, lemma, proposition or corollary in order assign the given name to that result. To reference the number assigned to that result in some other theorem, one gives the command \ref{name}; this will be replaced by the number automatically assigned by LaTeX to that result when the LaTeX program is executed. The necessary space above and below the statement of the theorem will automatically be generated by LaTeX.

The environments and commands introduced above are used in typesetting the following text:

[GIF Image]
This text is typeset from the following LaTeX input:
\begin{definition} Let $H$ be a subgroup of a group~$G$.  A \emph{left coset} of $H$ in $G$ is a subset of $G$ that is of the form $xH$, where $x \in G$ and $xH = \{ xh : h \in H \}$. Similarly a \emph{right coset} of $H$ in $G$ is a subset of $G$ that is of the form $Hx$, where $Hx = \{ hx : h \in H \}$ \end{definition}  Note that a subgroup~$H$ of a group $G$ is itself a left coset of $H$ in $G$.  \begin{lemma} \label{LeftCosetsDisjoint} Let $H$ be a subgroup of a group $G$, and let $x$ and $y$ be elements of $G$.  Suppose that $xH \cap yH$ is non-empty. Then $xH = yH$. \end{lemma}  \begin{proof} Let $z$ be some element of $xH \cap yH$.  Then $z = xa$ for some $a \in H$, and $z = yb$ for some $b \in H$. If $h$ is any element of $H$ then $ah \in H$ and $a^{-1}h \in H$, since $H$ is a subgroup of $G$. But $zh = x(ah)$ and $xh = z(a^{-1}h)$ for all $h \in H$. Therefore $zH \subset xH$ and $xH \subset zH$, and thus $xH = zH$.  Similarly $yH = zH$, and thus $xH = yH$, as required.\qed \end{proof}  \begin{lemma} \label{SizeOfLeftCoset} Let $H$ be a finite subgroup of a group $G$.  Then each left coset of $H$ in $G$ has the same number of elements as $H$. \end{lemma}  \begin{proof} Let $H = \{ h_1, h_2,\ldots, h_m\}$, where $h_1, h_2,\ldots, h_m$ are distinct, and let $x$ be an element of $G$.  Then the left coset $xH$ consists of the elements $x h_j$ for $j = 1,2,\ldots,m$. Suppose that $j$ and $k$ are integers between $1$ and $m$ for which $x h_j = x h_k$.  Then $h_j = x^{-1} (x h_j) = x^{-1} (x h_k) = h_k$, and thus $j = k$, since $h_1, h_2,\ldots, h_m$ are distinct.  It follows that the elements $x h_1, x h_2,\ldots, x h_m$ are distinct. We conclude that the subgroup~$H$ and the left coset $xH$ both have $m$ elements, as required.\qed \end{proof}  \begin{theorem} \emph{(Lagrange's Theorem)} \label{Lagrange} Let $G$ be a finite group, and let $H$ be a subgroup of $G$.  Then the order of $H$ divides the order of $G$. \end{theorem}  \begin{proof} Each element~$x$ of $G$ belongs to at least one left coset of $H$ in $G$ (namely the coset $xH$), and no element can belong to two distinct left cosets of $H$ in $G$ (see Lemma~\ref{LeftCosetsDisjoint}).  Therefore every element of $G$ belongs to exactly one left coset of $H$. Moreover each left coset of $H$ contains $|H|$ elements (Lemma~\ref{SizeOfLeftCoset}).  Therefore $|G| = n |H|$, where $n$ is the number of left cosets of $H$ in $G$. The result follows.\qed \end{proof}

没有评论: