Extras

Amongst the dozens of LaTeX elements we've neglected, there are one or two that didn't fit neatly into this presentation but are sometimes useful.

Contents and Sections

A title will only be numbered if its 'depth' isn't more than secnumdepth and will only appear in the contents page if the 'depth' isn't more than the value of tocdepth. So, for example, doing

\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{3}

will cause section 1.4.3 to be numbered, but it won't appear in the contents. Also if you want a shorter name in the contents page
\subsection[Pagebreaks etc] {Pagebreaks, space, footnotes, references}

Dashes and Hyphens

In LaTeX you can get a longer hyphen by using two or three dashes, i.e. -- or ---. The short hyphen is for use in hyphenated words like "co-ordinate", the longer one for numerical ranges like "2--3", and the longest one for a dash in text --- like that!

Page Sizes and Margins

Although LaTeX has pretty good defaults for most purposes, you will occasionally want to override them, in which case you can use:

\paperwidth=15.5cm
\paperheight=23.25cm
\textwidth=11.625cm
\textheight=17.438cm
to set the width of the paper, and how much space you want to devote to the text.

You can also set the various margins using:

% Driver margin is 1in=2.54cm by default so command below effectively
% sets the oddsidemargin to 1.292cm
\oddsidemargin=-1.248cm
\evensidemargin=5.543cm

\topmargin=-1.52cm
\headheight=0.48cm

% shift margins to allow room for binding
\addtolength{\oddsidemargin}{0.5cm}
\addtolength{\evensidemargin}{-0.5cm}

Footnotes

You can use the command \footnote{} to put a footnote in your text. LaTeX will insert a small superscripted number at the point where you put the \footnote{} command, and the footnote will appear at the bottom of the page alongside the appropriate number.

Line Spacing

The only time you're likely to need this is if a formal document (such as a thesis) has to have double- or one-and-a-half line spacing. Just in case you do need it, the LaTeX commands are quite straightforward. Use the setspace package, and then you can use the doublespace or onehalfspace environments at will.

Other Symbols

There are lots and lots of symbols and symbol-related commands defined in LaTeX, but some of the more useful are:

Your Own Commands

Sometimes you want to define your own command. To do this, use the \newcommand or \renewcommand commands (depending on whether you're defining a new command or altering an existing one) before you start your document environment. E.g.,

% redefine vector style
\renewcommand{\vec}[1]{\ensuremath{\mathbf #1}}

% redefine matrix style
\renewcommand{\matrix}[1]{\ensuremath{\mathbf #1}}
Note the use of \ensuremath to make sure that if the command is used in ordinary text, it automatically switches to maths mode (and back).

The \renewcommand is very powerful and useful. The optional argument says how many arguments you want your command to take, and you then refer to those arguments using #1, #2 etc. Thus the \vec command defined above takes a single argument, and when used it switches to maths mode (if it isn't already in maths mode), and uses the maths bold font to typeset argument 1.

Here's an example of a more complicated command, which defines a matrix element in Dirac notation:

% define new matrix element, \ME command
\newcommand{\ME}[3]{\ensuremath{\left \langle \left. #1
\right.  \right| #2 \left| \left. #3 \right. \right \rangle}}
It takes three arguments, and typesets them separately so that \ME{a}{M}{b} produces a nice version of < a | M | b > . Note that we've used \langle and \rangle to produce nice arrows, and \left and \right to stretch those nice arrows to the appropriate height for whatever goes inside them.


Previous page Next page