<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta name="generator" content="hevea 2.06"> <META name="Author" content="Luc Maranget"><link rel="stylesheet" type="text/css" href="manual.css"> <title>Definitions, Numbering</title> </head> <body> <a href="manual029.html"><img src="previous_motif.gif" alt="Previous"></a> <a href="manual022.html"><img src="contents_motif.gif" alt="Up"></a> <a href="manual031.html"><img src="next_motif.gif" alt="Next"></a> <hr> <h2 class="section" id="sec136">B.8  Definitions, Numbering</h2> <ul> <li><a href="manual030.html#sec137">Defining Commands</a> </li><li><a href="manual030.html#sec138">Defining Environments</a> </li><li><a href="manual030.html#sec139">Theorem-like Environments</a> </li><li><a href="manual030.html#sec140">Numbering</a> </li><li><a href="manual030.html#sec141">The <span class="c013">ifthen</span> Package</a> </li></ul> <h3 class="subsection" id="sec137">B.8.1  Defining Commands</h3> <p><a id="usermacro"></a></p><p><a id="hevea_default170"></a> <a id="hevea_default171"></a> <a id="hevea_default172"></a> H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A understands command definitions given in L<sup>A</sup>T<sub>E</sub>X style. Such definitions are made using <code>\newcommand</code>, <code>\renewcommand</code> and <code>\providecommand</code>. These three constructs accept the same arguments and have the same meaning as in L<sup>A</sup>T<sub>E</sub>X, in particular it is possible to define an user command with one optional argument. However, H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A is more tolerant: if command <span class="c018">name</span> already exists, then a subsequent <code>\newcommand{</code><span class="c018">name</span><code>}</code>…is ignored. If macro <span class="c018">name</span> does not exists, then <code>\renewcommand{</code><span class="c018">name</span><code>}</code>…performs a definition of <span class="c018">name</span>. In both cases, L<sup>A</sup>T<sub>E</sub>X would crash, H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A just issues warnings.</p><p>The behaviour of <code>\newcommand</code> allows to shadow document definition, provided the new definitions are processed before the document definitions. This is easily done by grouping the shadowing definition in a specific style file given as an argument to H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A (see section <a href="manual007.html#heveaonly">5.1</a>). Conversely, changes of base macros (<em>i.e.</em> the ones that H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A defines before loading any user-specified file) must be performed using <code>\renewcommand</code>.</p><p>Scoping rules apply to macros, as they do in L<sup>A</sup>T<sub>E</sub>X. Environments and groups define a scope and command definition are local to the scope they occur.</p><p>It is worth noticing that H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A also partly implements T<sub>E</sub>X definitions (using <code>\def</code>) and bindings (using <code>\let</code>), see section <a href="manual038.html#texmacro">B.16.1</a> for details.</p> <h3 class="subsection" id="sec138">B.8.2  Defining Environments</h3> <p> H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A accepts environment definitions and redefinitions by <code>\newenvironment</code> and <code>\renewenvironment</code>. The support is complete and should conform to [<a href="manual047.html#latex">L<sup>A</sup>T<sub>E</sub>X</a>, Sections C.8.2].</p><p>Environments define a scope both for commands and environment definitions.</p> <h3 class="subsection" id="sec139">B.8.3  Theorem-like Environments</h3> <p> New theorem-like environments can also be introduced and redefined, using <code>\newtheorem</code> and <code>\renewtheorem</code>.</p><p>Note that, by contrast with plain environments definitions, theorem-like environment definitions are global definitions.</p> <h3 class="subsection" id="sec140">B.8.4  Numbering</h3> <p> L<sup>A</sup>T<sub>E</sub>X counters are (fully ?) supported. In particular, defining a counter <span class="c018">cmd</span> with <code>\newcounter{</code><span class="c018">cmd</span><code>}</code> creates a macro <code>\the</code><span class="c018">cmd</span> that outputs the counter value. Then the <code>\the</code><span class="c018">cmd</span> command can be redefined. For instance, section numbering can be turned into alphabetic style by: </p><pre class="verbatim">\renewcommand{\thesection}{\alph{section}} </pre><p>Note that T<sub>E</sub>X style for counters is not supported at all and that using this style will clobber the output. However, H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A implements the <span class="c018">calc</span> package that makes using T<sub>E</sub>X style for counters useless in most situations (see section <a href="manual-packages.html#calc">B.17.3</a>).</p> <h3 class="subsection" id="sec141">B.8.5  The <span class="c013">ifthen</span> Package</h3> <p><a id="ifthen"></a> <a id="hevea_default173"></a> The <span class="c013">ifthen</span> package is partially supported. The one unsupported construct is the <code>\lengthtest</code> test expression, which is undefined.</p><p>As a consequence, H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A accepts the following example from the L<sup>A</sup>T<sub>E</sub>X manual: </p><pre class="verbatim">\newcounter{ca}\newcounter{cb}% \newcommand{\printgcd}[2]{% \setcounter{ca}{#1}\setcounter{cb}{#2}% Gcd(#1,#2) = \whiledo{\not\(\value{ca}= \value{cb}\)}% {\ifthenelse{\value{ca}>\value{cb}}% {\addtocounter{ca}{-\value{cb}}}% {\addtocounter{cb}{-\value{ca}}}% gcd(\arabic{ca}, \arabic{cb}) = }% \arabic{ca}.}% For example: \printgcd{54}{30} </pre><p>For example: Gcd(54,30) = gcd(24, 30) = gcd(24, 6) = gcd(18, 6) = gcd(12, 6) = gcd(6, 6) = 6.</p><p>Additionally, a few boolean registers are defined by H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A. Some of them are of interest to users. </p><dl class="description"><dt class="dt-description"> <span class="c014">hevea</span></dt><dd class="dd-description"> Initial value is <span class="c013">true</span>. The <span class="c013">hevea.sty</span> style file also defines this register with initial value <span class="c018">false</span>. </dd><dt class="dt-description"><span class="c014">mmode</span></dt><dd class="dd-description"> This register value reflects H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A operating mode, it is <span class="c018">true</span> in math-mode and <span class="c018">false</span> otherwise. </dd><dt class="dt-description"><span class="c014">display</span></dt><dd class="dd-description"> This register value reflects H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A operating mode, it is <span class="c018">true</span> in display-mode and <span class="c018">false</span> otherwise. </dd><dt class="dt-description"><span class="c014">footer</span></dt><dd class="dd-description"> Initial value is <span class="c013">true</span>. When set false, H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A does not insert its footer “<em>This document has been translated by H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A</em>”.</dd></dl><p>Finally, note that H<span class="c015"><sup>E</sup></span>V<span class="c015"><sup>E</sup></span>A also recognised à la T<sub>E</sub>X conditional macros (see section <a href="manual038.html#texcond">B.16.1.4</a>). Such macros are fully compatible with the boolean registers of the <span class="c013">ifthen</span> package, as it is the case in L<sup>A</sup>T<sub>E</sub>X.</p> <hr> <a href="manual029.html"><img src="previous_motif.gif" alt="Previous"></a> <a href="manual022.html"><img src="contents_motif.gif" alt="Up"></a> <a href="manual031.html"><img src="next_motif.gif" alt="Next"></a> </body> </html>