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 TEXas performing some simple arithmetic or comparing two lengths. For anything else youwill have to read one or more of the <strong>TeX</strong> books or tutorials.In England witnesses at a trial have to swear to ‘Tell the truth, the whole truth, andnothing but the truth’. I will try and tell the truth about <strong>TeX</strong> but, to misquote Hamlet<strong>The</strong>re are more things in heaven and <strong>TeX</strong>, Horatio,Than are dreamt of in your philosophy.E.1 THE TEX PROCESSAs we are delving deeper than normal and because at the bottom it is the <strong>TeX</strong> languagethat does all the work, it is useful to have an idea of how <strong>TeX</strong> processes a source file toproduce a dvi file. It is all explained in detail by Knuth [Knu84] and also perhaps moreaccessibly by Eijkhout [Eij92]; the following is a simplified description. Basically there arefour processes invloved and the output from one process is the input to the following one.Input <strong>The</strong> input process, which Knuth terms the ‘eyes’, reads the source file and convertswhat it sees into tokens. <strong>The</strong>re are essentially two kinds of token. A token is either asingle character such as a letter or a digit or a punctuation mark, or a token is a controlsequence. A control sequence consists of a backslash and either all the alphabeticcharacters immediately following it, or the single non-alphabetic following it. Controlsequence is the general term for what I have been calling a macro or a command.Expansion <strong>The</strong> expansion processor is what Knuth calls ‘<strong>TeX</strong>’s mouth’. In this processsome of the tokens from the input processor are expanded. Expansion replaces atoken by other tokens or sometimes by no token. <strong>The</strong> expandible tokens includemacros, conditionals, and a number of <strong>TeX</strong> primitives.Execution <strong>The</strong> execution process is <strong>TeX</strong>’s ‘stomach’. This handles all the tokens outputby the expansion processor. Control sequences that are not expandible are termedexecutable, and the execution processor executes the executable tokens. Charactertokens are neither expandible nor executable. It handles any macro defintions andalso builds horizontal, vertical and mathematical lists.Layout <strong>The</strong> layout processor (<strong>TeX</strong>’s ‘bowels’) breaks horizontal lists into paragraphs,mathematical lists into formulae, and vertical lists into pages. <strong>The</strong> final output isthe dvi file.In spite of the sequential nature implied by this description the overall process includessome feedback from a later process to an earlier one which may affect what that does.It is probably the expansion processor that needs to be best understood. Its input isa sequence of tokens from the input processor and its output is a sequence of differenttokens.In outline, the expansion processor takes each input token in turn and sees if it is expandible;if it is not it simply passes it on to the output. If the token is expandible then itis replaced by its expansion. <strong>The</strong> most common expandible tokens are control sequencesthat have been defined as macros. If the macro takes no arguments then the macro’s nameis replaced by its definition. If the macro takes arguments, sufficient tokens are collected430

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

Saved successfully!

Ooh no, something went wrong!