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.

\S<strong>to</strong>pEventually{final text}<br />

D.7. Managing code <strong>and</strong> documentation 469<br />

where final text is <strong>to</strong> appear at the very end of the article; if only the<br />

description part is printed, final text is printed immediately <strong>and</strong> the<br />

documentation is ended.<br />

The coding part<br />

The coding part should normally contain the more specialized material<br />

that is of no interest <strong>to</strong> the everyday user. The special comm<strong>and</strong>s that<br />

may be used here are<br />

\begin{macro}{\macro name} text <strong>and</strong> code \end{macro}<br />

\begin{environment}{env name} text <strong>and</strong> code \end{environment}<br />

both of which again insert a marginal note <strong>and</strong> make an entry in the index.<br />

They also organize any \changes comm<strong>and</strong>s, as explained below.<br />

The most important environment in the coding part is macrocode,<br />

which prints its contents as in verbatim, optionally with a code line<br />

number. The form of this environment is somewhat special:<br />

\begin{macrocode}<br />

lines of code<br />

\end{macrocode}<br />

The four spaces before the \end{macrocode} are obliga<strong>to</strong>ry; those before<br />

the \begin are not necessary, but it is good practice <strong>to</strong> insert them for<br />

symmetry. This environment also counts all the backslashes within it for<br />

a checksum test, <strong>and</strong> makes an index entry for every comm<strong>and</strong> name that<br />

it finds. So it is something more than a mere verbatim environment!<br />

The coding part is brought <strong>to</strong> an end with<br />

\Finale<br />

which carries out the checksum test <strong>and</strong> prints the s<strong>to</strong>red final text from<br />

\S<strong>to</strong>pEventually. There may actually be more text following it, which<br />

is only printed when both description <strong>and</strong> coding parts are output.<br />

Index of macros <strong>and</strong> record of changes<br />

The doc package makes au<strong>to</strong>matic entries in<strong>to</strong> an index by means of<br />

the two \Describexxx comm<strong>and</strong>s <strong>and</strong> the two environments presented<br />

above. As well, all comm<strong>and</strong>s that appear in the coding are indexed.<br />

However, the indexing is turned on only if one of<br />

\CodelineIndex or \PageIndex<br />

is given in the preamble. The first references the indexed comm<strong>and</strong>s <strong>to</strong><br />

the number of the code line where they appear, the second <strong>to</strong> the page

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

Saved successfully!

Ooh no, something went wrong!