28.03.2013 Views

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

!<br />

\newlength{\new len cmd}<br />

8.3. User-defined comm<strong>and</strong>s 185<br />

which establishes \new len cmd as a length with a value of 0pt. All the<br />

above comm<strong>and</strong>s may be used <strong>to</strong> manipulate its value further.<br />

The comm<strong>and</strong><br />

\addvspace{length spec}<br />

inserts extra vertical spacing of the amount length spec at that point where it<br />

appears. If more than one such comm<strong>and</strong> is given, the <strong>to</strong>tal inserted spacing will<br />

be that of the largest argument <strong>and</strong> not the sum of them all. This comm<strong>and</strong> may<br />

only be given between paragraphs. Its application for user-defined comm<strong>and</strong>s<br />

<strong>and</strong> environments lies in the generation of structures that should behave like<br />

paragraphs.<br />

8.3 User-defined comm<strong>and</strong>s<br />

New comm<strong>and</strong>s may be defined or redefined under L AT E X with the comm<strong>and</strong>s<br />

\newcomm<strong>and</strong>{\com name}[narg][opt]{def }<br />

\renewcomm<strong>and</strong>{\com name}[narg][opt]{def }<br />

The first version is used <strong>to</strong> define a comm<strong>and</strong> \com name that does not<br />

yet exist. Its name may be any combination of letters that do not form<br />

the name of another comm<strong>and</strong>. The second version redefines an already<br />

existing comm<strong>and</strong> \com name. In both cases, an error message is printed<br />

if the incorrect variant is called. The first optional argument narg is a<br />

number between 1 <strong>and</strong> 9 specifying how many arguments the new or<br />

altered comm<strong>and</strong> is <strong>to</strong> have. A second optional argument opt gives the<br />

default value for an optional argument that the new comm<strong>and</strong> may take.<br />

The actual definition of the comm<strong>and</strong> is contained in the text def.<br />

8.3.1 Comm<strong>and</strong>s without arguments<br />

We will first illustrate the use of the \newcomm<strong>and</strong> without the optional<br />

argument [narg]. This form is applied when a fixed combination of<br />

L AT E X or user comm<strong>and</strong>s is <strong>to</strong> be repeated frequently as a comm<strong>and</strong> with<br />

its own name. For example, the structure x1, . . . , xn, called an x-vec<strong>to</strong>r,<br />

often occurs in mathematical formulas <strong>and</strong> is formed in math mode with<br />

x_1,\ldots,x_n. Typing<br />

\newcomm<strong>and</strong>{\xvec}{x_1,\ldots,x_n}<br />

creates a new comm<strong>and</strong> named \xvec that may be called <strong>and</strong> used just<br />

like any other comm<strong>and</strong>. When called, it inserts the sequence of text <strong>and</strong><br />

comm<strong>and</strong>s, in this case x_1,\ldots,x_n, in<strong>to</strong> the current text exactly as

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

Saved successfully!

Ooh no, something went wrong!