12.07.2015 Views

The memoir class - The UK TeX Archive

The memoir class - The UK TeX Archive

The memoir class - The UK TeX Archive

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

E. LATEX AND TEXHalf Dome in Yosemite or the North Face of the Eiger without having first gained experienceon friendlier rocks.<strong>The</strong> La<strong>TeX</strong> kernel is full of internal commands and a few are mentioned in Lamport.<strong>The</strong>re is no place where you can go to get explanations of all the La<strong>TeX</strong> commands, but ifyou run La<strong>TeX</strong> on the source2e.tex file which is in the standard La<strong>TeX</strong> distribution youwill get the commented kernel code. <strong>The</strong> index of the commands runs to about 40 doublecolumn pages. Each <strong>class</strong> and package introduce new commands over and above those inthe kernel.La<strong>TeX</strong> includes \newcommand, \providecommand and \renewcommand as means of(re-)defining a command, but <strong>TeX</strong> provides only one method.\def〈cmd〉〈arg-spec〉{〈text〉}\def specifies that within the local group the command \cmd is defined as 〈text〉, and anyprevious definitions of 〈cmd〉 within the group are overwritten. Neither the 〈text〉 nor anyarguments can include an end-of-paragraph. <strong>The</strong> La<strong>TeX</strong> equivalent to \def is the pair ofcommands \providecommand* followed by \renewcommand*.<strong>The</strong> 〈arg-spec〉 is a list of the argument numbers (e.g., #1#2) in sequential order, the listending at the ‘{’ starting the 〈text〉. Any spaces or other characters in the argument list aresignificant. <strong>The</strong>se must appear in the actual argument list when the macro is used.\long \global\gdef〈cmd〉〈arg-spec〉{〈text〉}\edef〈cmd〉〈arg-spec〉{〈text〉}\xdef〈cmd〉〈arg-spec〉{〈text〉}If you use the \long qualifier before \def (as \long\def...) then the 〈text〉 andarguments may include paragraphs. <strong>The</strong> La<strong>TeX</strong> version of this is the unstarred\providecommand followed by \renewcommand.To make a command global instead of local to the current group, the \global qualifiercan be used with \def (as \global\def...) when defining it; \gdef is provided as ashorthand for this common case.Normally any macros within the replacement 〈text〉 of a command defined by \def areexpanded when the command is called. <strong>The</strong> macro \edef also defines a command but inthis case any macros in the replacement 〈text〉 are expanded when the command is defined.Both \long and \global may be used to qualify \edef, and like \gdef being shorthandfor \global\def, \xdef is short for \global\edef.<strong>The</strong>re is much more to the \def family of commands than I have given; consult elsewherefor all the gory details.\let〈cmda〉=〈cmdb〉<strong>The</strong> \let macro gives 〈cmda〉 the same definition as 〈cmdb〉 at the time the \let is called. <strong>The</strong>= sign is optional. \let is often used when you want to save the definition of a command.Here is a short example of how some of \def and \let work.\def\name{Alf}\let\fred = \name\name, \fred. % prints Alf, Alf.\def\name{Fred}\name, \fred. % prints Fred, Alf.434

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!