LaTeX Seminar II: Commands

advertisement
LaTeX Seminar II: Commands
Clifford E. Weil
February 18, 2004
Simple Commands. These are commands of the form \ followed by
one or more characters. They are of two types.
A. \followed by one or more alphabetic characters. For example \alpha for the
Greek letter α. Because such a command can have any number of characters in
it, TeX must be told when the command ends and when regular text resumes.
This is done with a space. Because most commands of this form are used only
in math mode, there is no problem with space after the symbol the commands
produces, but if a command produces text in text mode, the command must be
followed by a mandatory space symbol.
B. \followed by ONE non-alphabetic character.
Examples of such were seem last week. \% which produces the % sign, \$
for the $ sign etc. But there are more whose use will be given later. TeX knows
when such commands have ended; so the space problem above doesn’t occur
with these commands.
Compound Commands. These are commands that have one or
more required arguments and perhaps some optional arguments as well. Required arguments are put between a pair of braces { }, while optional ones are
put between a pair of bracket [ ]. Examples are coming.
All commands are case sensitive.
To begin learning about commands, we’ll start with the preamble.
Commands in the Preamble
\documentclass[12pt,twocolumn,a4paper]{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage[french]{babel}
\markboth{author}{Title}
\pagestyle{style}
Some of the page styles are:
1. empty
2. plain
3. headings
\addtolength{name of length}{amount to add} or \setlength{name of length}{length}.
Some of the dimensions that can be changed are:
1
1. \topmargin
2. \oddsidemargin
3. \evensidemargin
4. \textheight
5. \textwidth
Finally a most useful command is
\newcommand{\name}{definition}.
For example \newcommand{\R}{\mathbb R}. Later in the body of the
document typing $\R$ will produce R. There is an optional argument for the
newcommand command as well. A useful example is
\newcommand{\charf}[1]
{\mbox{\raise.48ex\hbox{$\chi$}$ {#1}$}}.
So typing \charf{A} will produce χA .
Some Commands after the Command \begin{document}.
The font size and font style can be changed for a portion of the document using these commands: {\large text}, {\Large text}, {\LARGE text}, {\huge
text}, {\Huge text}, and for smaller sizes use: {\small text}, {\footnotesize
text}, {\scriptsize text}, {\tiny text}. To alter the font style use: \textit{text},
\textsc{text}, \textbf{text}, \textsl{text}, \textsf{text}, or \texttt{text}.
The default font style is roman in text mode and math italics in math mode.
If you want roman style in math mode, the command is just \text{text}. For
the others in math mode, replace text by math. For example in math mode to
get bold face type \mathbf{math stuff}.
The size and style commands can be combined but be sure to change the
size first and then the style. For example {\Large\texttt{big words}} will get
big words.
In the article class the following sectioning commands are available:
\section{section name}, \subsection{subsection name}, \subsubsection{. . . },
\paragraph{paragraph name} and \subparagraph{. . . }. LaTeX automatically
numbers these. If numbers aren’t wanted, type \section*. This so-called ∗ form is available for any command that produces a number. A very useful addition to numbering commands is the labeling facility. For example
\section{Introduction} allows reference to that section anywhere in the document simply by typing,. . . in Section \ref{intro} . . . .
The following table of simple commands will produce the more common
accents.
2
3
Now let’s discuss what commands are special to math mode. There are
several math mode only simple commands but the first one I what to introduce
is the command to produce fractions. It is \frac{numerator}{denominator}.
As a simple example $\frac{sin x}{x}$ will produce sinx x . However when the
numerator and\or denominator are more complicated, the font size is to too
small to be read easily. In that case replace frac by dfrac. For example
sin ex
$\dfrac{\sin e^x} {\frac{1}{2}x}$ will produce 1 .
2x
Another common one is \sqrt{expression} or more
√ generally \sqrt[number]{
expression}. For example $\sqrt[3]{17}$ produces 3 17.
To get Greek letters math mode must be used. The commands are in the
following table.
4
5
For example to get the Greek letter α, type $\alpha$ unless you’re already
in math mode in which case you omit the pair of $ signs.
Then there is the large collection of simple commands that produce mathematical symbols and accents. Some of them are displayed in the following
tables. All of these tables have been lifted from the document called The Not
So Short Introduction to LaTeX 2 that can be downloaded from
http:\\www.math.hkbu.edu.hk/TeX/
6
7
8
9
There are many more such symbols. Find them in the article referenced
earlier. Some additional simple commands that produce typical mathematical
functions and are listed in the next table.
10
11
If this list doesn’t contain a function you what or a mathematical operation you need, you can make your own by using the following command in the
preamble.
\DeclareMathOperator{\name}{definition}. For example
\DeclareMathOperator{\dist}{dist} in math mode will produce dist(A, B).
Note the small amount of space betweet the word dist and the argument
(A, B). Here LaTeX produces that space for you, but sometimes you must do it
Rb
Rb
for yourself. For example compare a sin xdx and a sin x dx. The small space
before the dx comes from the simple command \,. It’s called a thin space and
can be used in any mode. Other space commands are \: medium space, \;
thick space, \! negative thin space. These three work only in math mode.
12
Download