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.

190 Chapter 8. User Cus<strong>to</strong>mizations<br />

First, a new length parameter \wdth is created, then \defbox is defined<br />

so that \wdth is set equal <strong>to</strong> the length of its argument (Section 8.2), <strong>and</strong><br />

finally \textbox makes a framed box of that same width containing its<br />

argument, centered. (Do not name the length parameter \width, for this<br />

already exists, Section 4.7.5.)<br />

as wide as this text\\<br />

\defbox{as wide as this text}\textbox{}\\<br />

\textbox{text}\\<br />

\textbox{longer text}<br />

as wide as this text<br />

text<br />

longer text<br />

Example 3: A footnote comm<strong>and</strong> \myftnote is <strong>to</strong> be created that behaves<br />

as the normal comm<strong>and</strong> \footnote{text} in putting text in<strong>to</strong> a footnote,<br />

but instead of using numbers as the marker, it should take the symbols<br />

∗ † ‡ § ∗∗ †† ‡‡ one after the other, starting again with the symbol ∗<br />

on each new page. First a new counter must be established that will be<br />

reset <strong>to</strong> zero every time the page counter is incremented. This is done<br />

with (see Section 8.1.2)<br />

\newcounter{myfn}[page]<br />

making a user-defined counter myfn that is set <strong>to</strong> zero every time the<br />

page counter is incremented. ∗ Next the comm<strong>and</strong><br />

\renewcomm<strong>and</strong>{\thefootnote}{\fnsymbol{footnote}}<br />

redefines the footnote marker <strong>to</strong> be that symbol in the sequence given<br />

by the counter footnote (Sections 4.10.2 <strong>and</strong> 8.1.4). Now the actual new<br />

footnote comm<strong>and</strong> can be constructed with<br />

\newcomm<strong>and</strong>{\myftnote}[1]{\setcounter{footnote}{\value{myfn}}%<br />

\footnote{#1}\stepcounter{myfn}}<br />

yielding the desired results. The user-defined comm<strong>and</strong> \myftnote possesses<br />

one argument, which is passed <strong>to</strong> the L AT E X \footnote comm<strong>and</strong><br />

after the L AT E X counter footnote has been set equal <strong>to</strong> the value of the<br />

user counter myfn. Once the comm<strong>and</strong> \footnote has been executed,<br />

the counter myfn is then incremented by one with \stepcounter{myfn}.<br />

This counter, however, is reset <strong>to</strong> zero whenever the page counter is<br />

incremented, that is, whenever a new page begins.<br />

The footnote on the previous page was generated with the comm<strong>and</strong><br />

\myftnote as described. It is now used here † <strong>and</strong> again here ‡ , demonstrating<br />

how the symbols have been reset on a new page.<br />

Example 4: A comm<strong>and</strong> \alpheqn is <strong>to</strong> be set up so that once it has been<br />

called, the subsequent equations will all have the same number but be<br />

∗ Actually the page counter is not incremented exactly at the end of the page; LAT E X reads<br />

in the whole paragraph before it decides if <strong>and</strong> where a page break should occur. This can<br />

cause problems with resetting the myfn counter near the <strong>to</strong>p of a page.<br />

† another footnote<br />

‡ <strong>and</strong> yet another footnote

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

Saved successfully!

Ooh no, something went wrong!