LaTeX基本概念
在LaTeX中有来个基本的概念:控制序列和环境。
1.控制序列(control sequence):一组由\
开始的命令。有两种类型的控
制序列:\
之后紧随一个多个单词组成的控制字(control word)和\
之后紧
随一个非字母组成的控制符(control symbol)。
2.环境(environment):LaTeX中的环境主要用于对一块数据进行排版。其格
式如下:
\begin{environment_name}
The content ...
\end{environment_name}
控制序列
在控制字中需要注意以下几点:
- TeX是大小写敏感的,因此
\pi
,\Pi
,\pI
和\PI
是四种不同的命令。 - 如果在控制序列之后紧接着是一个单词,那就必须在控制序列之后添加空格。
例如,控制字\TeX
会产生“TeX”的标志。如果想要输出TeXpert
,则需要
输入\TeX pert
而不是\TeXpert
。这是由于TeX会认为它处理的是拥有7个
字母的命令。有趣地是,\TeX3
将会产生“TeX3”的输出,这是由于”3”是一
个数字,而不是字母。 - 控制序列之后可以添加声明。声明包含两种类型:可选的(optional)和必须的
(required)。
例如\section[Duke]{Duke University}
命令。该命令告知LaTeX将开始新节
并且节标题是“Duke University”,但是,在目录中显示为“Duke”。在这
个例子中,[Duke]
是可选的,并且可以省略;{Duke University}
是必须
的,因此必须在大括号中填写一些信息。简而言之,就是将可选的内容放在中
括号中,必填的内容放在大括号中。
在控制字中,不需要使用空格来告知TeX命令在何处结束。例如\,
会产生一个
“窄空格(1\,cm
会输出1 cm
)。
示例1 \'m \exercise3.1\\!
中有哪些控制序列?
解答: 上述示例中有三个控制序列。\'
是一个控制字符,\exercise
是一个
控制字,\\
是另一个控制字符。
示例2 \LaTeX
用来输出“LaTe”的标志。那么\LaTeX is great
会输出
什么?
解答: 输出结果是“LaTeXis great”。
示例3 命令\input1
会导入名为1.tex的文件。那么\input123
命令将会
做什么?
解答: 命令\input123
会导入名为1.tex的文件,并且输出数字“23”。
如果想要导入名为123.tex的文件,则需要输入\input{123}
命令。
环境
环境在LaTeX是十分重要的一个概念,它广泛应用与LaTeX文档中。考虑如何将一
段文字居中排列?此时,就可以通过center
环境来实现,具体如下所示:
\begin{center}
The line should be centered.
\end{center}
更多复杂的环境应用还在学习中。
示例
在认识了上述LaTeX中两个重要的基本概念之后,就可以进行简单的排版工作了。
接下来将展示一个简单的排版示例。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\title{My First \LaTeX\ Exercise}
\author{Helin Gai}
\maketitle
\tableofcontents
\section[Fonts]{The Changing Definition of Font}
In the days of handset type, a \emph{font}\footnote{A term that comes
from an early French word meaning ''molding'' or ''casting.''}
comprised one or more drawers full of type blocks in a single
size. With the advent of the Monotype and Linotype machines, a font
then became a set of molds (or \emph{matrices}) from which type could
be cast as it was needed, on the fly.
All of this type was destined for a specific kind of printing press,
the \emph{letterpress}. On a letterpress the printed impression is
created by inking a raised surface (which can be a photographic image
as well as type) whose image is transferred under pressure to the
paper. Recessed areas---those below \emph{type-high}---receive no ink,
do not come into contact with the paper, and so create the ''blank''
areas of the page.
\section[\LaTeX]{The Glorious \LaTeX}
The first paragraph of a new section is not
indented. \TeX\ recognizeds the end of a paragraph when it comes to a
blank line in your manuscript file.
Subsequent paragraphs areindented.\footnote{Oh, try avoid footnotes!}
(See?) The computer breaks a paragraph's text into lines in an
interesting way-and hyphenates words \emph{automatically} when
necessary.
\end{document}
参考文献
《The Art of LaTeX》