manual030.html 8.34 KB
Newer Older
1 2 3 4
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
Ralf Treinen's avatar
Ralf Treinen committed
5 6 7
<meta name="generator" content="hevea 2.32">
<meta name="Author" content="Luc Maranget">
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script><link rel="stylesheet" type="text/css" href="manual.css">
8 9 10
<title>Definitions, Numbering</title>
</head>
<body>
Ralf Treinen's avatar
Ralf Treinen committed
11 12 13
<a href="manual029.html"><img src="previous_motif.svg" alt="Previous"></a>
<a href="manual022.html"><img src="contents_motif.svg" alt="Up"></a>
<a href="manual031.html"><img src="next_motif.svg" alt="Next"></a>
14 15 16 17 18 19 20
<hr>
<h2 class="section" id="sec136">B.8&#XA0;&#XA0;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>
21
</li><li><a href="manual030.html#sec141">The <span class="c013">ifthen</span> Package</a>
22 23
</li></ul>
<h3 class="subsection" id="sec137">B.8.1&#XA0;&#XA0;Defining Commands</h3>
Ralf Treinen's avatar
Ralf Treinen committed
24 25 26 27
<p><a id="usermacro"></a></p><p><a id="hevea_default174"></a>
<a id="hevea_default175"></a>
<a id="hevea_default176"></a>
H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A understands command definitions given in L<sup>A</sup>T<sub>E</sub>X style. Such
28
definitions are made using
29
<code>\newcommand</code>, <code>\renewcommand</code> and <code>\providecommand</code>.
30 31 32
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.
Ralf Treinen's avatar
Ralf Treinen committed
33 34 35
However, H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A is more tolerant: if command
<span class="c019">name</span> already exists, then a subsequent <code>\newcommand{</code><span class="c019">name</span><code>}</code>&#X2026;is ignored. If macro <span class="c019">name</span> does not exists, then
<code>\renewcommand{</code><span class="c019">name</span><code>}</code>&#X2026;performs a definition of <span class="c019">name</span>. In both cases, L<sup>A</sup>T<sub>E</sub>X would crash, H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A just issues
36
warnings.</p><p>The behaviour of <code>\newcommand</code> allows to shadow document
37 38 39
definition, provided the new definitions are processed before the
document definitions.
This is easily done by grouping the shadowing definition in a
Ralf Treinen's avatar
Ralf Treinen committed
40 41
specific style file given as an argument to H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A (see section&#XA0;<a href="manual007.html#heveaonly">5.1</a>).
Conversely, changes of base macros (<em>i.e.</em> the ones that H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A
42
defines before loading any user-specified file) must be performed
43
using <code>\renewcommand</code>.</p><p>Scoping rules apply to macros, as they do in L<sup>A</sup>T<sub>E</sub>X.
44
Environments and groups define a scope and command definition
Ralf Treinen's avatar
Ralf Treinen committed
45
are local to the scope they occur.</p><p>It is worth noticing that H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A also partly implements T<sub>E</sub>X definitions
46
(using <code>\def</code>) and bindings (using <code>\let</code>), see
Ralf Treinen's avatar
Ralf Treinen committed
47
section&#XA0;<a href="extras.html#texmacro">B.16.1</a> for details.</p>
48 49
<h3 class="subsection" id="sec138">B.8.2&#XA0;&#XA0;Defining Environments</h3>
<p>
Ralf Treinen's avatar
Ralf Treinen committed
50
H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A accepts environment definitions and redefinitions
51
by <code>\newenvironment</code> and <code>\renewenvironment</code>.
52
The support is complete and should conform
53 54 55 56
to&#XA0;[<a href="manual047.html#latex">L<sup>A</sup>T<sub>E</sub>X</a>, Sections&#XA0;C.8.2].</p><p>Environments define a scope both for commands and environment
definitions.</p>
<h3 class="subsection" id="sec139">B.8.3&#XA0;&#XA0;Theorem-like Environments</h3>
<p>
57
New theorem-like environments can also be introduced and redefined,
58 59 60 61
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&#XA0;&#XA0;Numbering</h3>
<p>
62
L<sup>A</sup>T<sub>E</sub>X counters are (fully ?) supported.
Ralf Treinen's avatar
Ralf Treinen committed
63 64 65 66
In particular, defining a counter <span class="c019">cmd</span> with
<code>\newcounter{</code><span class="c019">cmd</span><code>}</code> creates a macro
<code>\the</code><span class="c019">cmd</span> that outputs the counter value.
Then the <code>\the</code><span class="c019">cmd</span> command can be redefined.
67
For instance, section numbering can be turned into alphabetic style by:
68 69
</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
Ralf Treinen's avatar
Ralf Treinen committed
70 71
this style will clobber the output. However, H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A implements
the <span class="c019">calc</span> package that makes using T<sub>E</sub>X style for counters
72
useless in most situations (see section&#XA0;<a href="manual-packages.html#calc">B.17.3</a>).</p>
73
<h3 class="subsection" id="sec141">B.8.5&#XA0;&#XA0;The <span class="c013">ifthen</span> Package</h3>
74
<p><a id="ifthen"></a>
Ralf Treinen's avatar
Ralf Treinen committed
75
<a id="hevea_default177"></a>
76
The <span class="c013">ifthen</span> package is partially supported.
77
The one unsupported construct is the
78
<code>\lengthtest</code> test expression, which is
Ralf Treinen's avatar
Ralf Treinen committed
79
undefined.</p><p>As a consequence, H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A accepts the following example from the
80
L<sup>A</sup>T<sub>E</sub>X manual:
81
</p><pre class="verbatim">\newcounter{ca}\newcounter{cb}%
82 83 84 85 86 87 88 89 90 91
\newcommand{\printgcd}[2]{%
  \setcounter{ca}{#1}\setcounter{cb}{#2}%
  Gcd(#1,#2) =
  \whiledo{\not\(\value{ca}= \value{cb}\)}%
    {\ifthenelse{\value{ca}&gt;\value{cb}}%
      {\addtocounter{ca}{-\value{cb}}}%
      {\addtocounter{cb}{-\value{ca}}}%
    gcd(\arabic{ca}, \arabic{cb}) = }%
  \arabic{ca}.}%
For example: \printgcd{54}{30}
Ralf Treinen's avatar
Ralf Treinen committed
92 93 94
</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="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A.
95
Some of them are of interest to users.
96
</p><dl class="description"><dt class="dt-description">
97 98
<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
Ralf Treinen's avatar
Ralf Treinen committed
99 100 101 102 103
initial value <span class="c019">false</span>.
</dd><dt class="dt-description"><span class="c014">mmode</span></dt><dd class="dd-description"> This register value reflects H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A operating
mode, it is <span class="c019">true</span> in math-mode and <span class="c019">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="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A operating
mode, it is <span class="c019">true</span> in display-mode and <span class="c019">false</span> otherwise.
104
</dd><dt class="dt-description"><span class="c014">footer</span></dt><dd class="dd-description"> Initial value is <span class="c013">true</span>.
Ralf Treinen's avatar
Ralf Treinen committed
105 106 107
When set false, H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A does not insert its footer &#X201C;<em>This
document has been translated by H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A</em>&#X201D;.</dd></dl><p>Finally, note that H<span class="c016"><sup>E</sup></span>V<span class="c016"><sup>E</sup></span>A also recognised &#XE0; la T<sub>E</sub>X conditional
macros (see section&#XA0;<a href="extras.html#texcond">B.16.1.4</a>). Such macros are fully compatible
108
with the boolean registers of the <span class="c013">ifthen</span> package, as it is
109 110
the case in L<sup>A</sup>T<sub>E</sub>X.</p>
<hr>
Ralf Treinen's avatar
Ralf Treinen committed
111 112 113
<a href="manual029.html"><img src="previous_motif.svg" alt="Previous"></a>
<a href="manual022.html"><img src="contents_motif.svg" alt="Up"></a>
<a href="manual031.html"><img src="next_motif.svg" alt="Next"></a>
114 115
</body>
</html>