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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

\begin{filecontents}{mymacros}<br />

\newcomm<strong>and</strong>{\te}{the end}<br />

\end{filecontents}<br />

the newly written file mymacros.tex contains<br />

D.2. L AT E X programming comm<strong>and</strong>s 449<br />

%% <strong>LaTeX</strong>2e file ‘mymacros’<br />

%% generated by the ‘filecontents’ environment<br />

%% from source ‘mydoc’ on 2003/01/31.<br />

%%<br />

\newcomm<strong>and</strong>{\te}{the end}<br />

Note that the filecontents environment adds some comment lines<br />

<strong>to</strong> explain where the new file came from. If this is undesirable, the<br />

filecontents* environment may be used instead.<br />

D.2.10 Useful internal comm<strong>and</strong>s<br />

Notwithst<strong>and</strong>ing the guidelines in Section D.1.2 that recommend avoiding internal<br />

! L AT E X comm<strong>and</strong>s, there are a number that are fairly fundamental, <strong>and</strong> indeed form<br />

many of the building blocks of the L AT E X kernel <strong>and</strong> many st<strong>and</strong>ard packages. Since<br />

they are still internal comm<strong>and</strong>s, they are not guaranteed for all future updates.<br />

However, if they were <strong>to</strong> vanish, many of the interesting extension packages<br />

provided by the L AT E X Team itself would have <strong>to</strong> be drastically overhauled. We<br />

merely present them briefly here for the sake of the bolder user.<br />

\@namedef{cmd}{def }<br />

\@nameuse{cmd}<br />

define <strong>and</strong> execute a comm<strong>and</strong> named \cmd, where the backslash is not included<br />

in the comm<strong>and</strong> name. This name may contain any characters, even those<br />

normally forbidden in comm<strong>and</strong> names.<br />

\@ifundefined{cmd}{true}{false}<br />

executes true if the comm<strong>and</strong> \cmd does not exist, else false. Again, the backslash<br />

is not included in cmd, <strong>and</strong> any characters may appear in the comm<strong>and</strong> name.<br />

This test is often used <strong>to</strong> define comm<strong>and</strong>s conditionally, a task that has been<br />

taken over by \providecomm<strong>and</strong>. It may also be employed <strong>to</strong> determine whether<br />

the main class is article-like or not: \@ifundefined{chapter}{..}{..} tests<br />

for the existence of the \chapter comm<strong>and</strong>.<br />

\@ifnextcharchar{true}{false}<br />

tests if the next character is char, <strong>and</strong> if so, executes true, else false. This<br />

comm<strong>and</strong> is traditionally used <strong>to</strong> define comm<strong>and</strong>s with optional arguments,<br />

where char is [. The extended syntax of \newcomm<strong>and</strong> offers a high-level means<br />

of achieving this.<br />

\@ifstar{true}{false}

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

Saved successfully!

Ooh no, something went wrong!