Extra Features
Author: Luc Maranget

B.16 | Extra Features

- Accents in maths
- TeX macros
- Command Definition inside Command Definition
- Date and time
- Fancy sectioning commands
- HEVEA as a Back-End for VideoC

This section describes HEVEA functionalities that extends on plain LATEX, as defined in [LATEX]. Most of the features described here are performed by default.

B.16.1 | Accents in maths

Loading the `mathaccents.hva` style files enables default typesetting of the math accents commands (`\hat`, `\tilde`,...), see Section B.7.4.

B.16.2 | TeX macros

Normally, HEVEA does not recognize constructs that are specific to TeX. However, some of the internal commands of HEVEA are homonymous to TeX macros, in order to enhance compatibility. Note that full compatibility with TeX is not guaranteed.

B.16.2.1 | À la TeX macros definitions

The `\def` construct for defining commands is supported. It is important to notice that HEVEA semantics for `\def` follows TeX semantics. That is, defining a command that already exists with `\def` succeeds. This is an important change with respect to previous versions of HEVEA, where `\def` had the same semantics as `\newcommand`.
Delimiting characters in command definition are supported. Consider the following example from the TeX Book:

    \def\Look{\textsc{Look}}
    \def\x{\textsc{x}}
    \def\cs AB#1#2C$#3\$ {#3{ab#1}#1 c\x #2}
    \cs AB {\Look}{}C${And \$}{look}\$ 5.

It yields: And $lookabLookLook cx5.
Please note that delimiting characters are supported as far as I could, problems are likely with delimiting characters which include spaces or command names, in particular the command name `\{`. One can include `\{` in a command argument by using the grouping characters `{`... `}`:

    \def\frenchquote(#1){«~\emph{#1}~» (in French)}
    He said \frenchquote(Alors cette accolade ouvrante {``\{''}~?).

Yields:
He said « Alors cette accolade ouvrante ``{'' ? » (in French).
Another source of incompatibilty with TeX is that substitution of macros parameters is not performed at the same moment by HEVEA and TeX. However, things should go smoothly at the first level of macro expansion, that is when the delimiters appear in source code at the same level as the macro that is to parse them. For instance, the following source will give different results in LATEX and in HEVEA:

    \def\cs#1A{``#1''}
    \def\othercs#1{\cs#1A}
    \othercs{coucouA}

LATEX output is ``coucou''A, while HEVEA output is ``coucouA''. Here is HEVEA output: ``coucouA'' Please note that in most situations this discrepancy will make HEVEA crash.

B.16.2.2 | The `\let` construct

HEVEA also processes a limited version of `\let`:
`\let` macro-name1 = macro-name2
The effect is to bind macro-name1 to whatever macro-name2 is bound to at the time `\let` is processed. This construct may prove very useful in situations where one whishes to slightly modify basic commands. See sections 9.3 and B.2 for examples of using `\let` in such a situation.

B.16.2.3 | The `\global` construct

It is possible to escape scope and to make global definitions and bindings by using the TeX construct `\global`. The `\global` construct is significant before `\def` and `\let` constructs.
Also note that `\gdef` is equivalent to `\global\def`.

B.16.2.4 | TeX Conditional Macros

The `\newif\if`name, where name is made of letters only, creates three macros: `\if`name, `\`name`true` and `\`name`false`. The latter two set the name condition to true and false, respectively. The `\if`name command tests the condition name:
`\if`name
text1
`\else`
text2
`\fi`
Text text1 is processed when name is true, otherwise text2 is processed. If text2 is empty, then the `\else` keyword can be omitted.
Note that HEVEA also implements LATEX `ifthen` package and that TeX simple conditional macros are fully compatible with LATEX boolean registers. More precisely, we have the following correspondences:

TeX | LATEX
`\newif`name |  | `\newboolean{`name`}`
`\`name`true` |  | `\setboolean{`name`}{true}`
`\`name`false` |  | `\setboolean{`name`}{false}`
`\if`name text1`\else` text2`\fi` |  | `\ifthenelse{\boolean{`name`}}{`text1`}{`text2`}`

B.16.2.5 | Other TeX Macros

HEVEA implements the macros `\unskip` and `\endinput`. It also supports the `\csname`... `\endcsname` construct.

B.16.3 | Command Definition inside Command Definition

If one strictly follows the LATEX manual, only commands with no arguments can be defined inside other commands. Parameters (i.e., `#`n) occurring inside command bodies refer to the outer definition, even when they appear in nested command definitions. That is, the following source:

    \newcommand{\outercom}[1]{\newcommand{\insidecom}{#1}\insidecom}
    \outercom{outer}

yields this output:
outer
Nevertheless, nested commands with arguments are allowed. Standard parameters `#`n still refer to the outer definition, while nested parameters `##`n refer to the inner definition. That is, the source:

    \newcommand{\outercom}[1]{\newcommand{\insidecom}[1]{##1}\insidecom{inner}}
    \outercom{outer}

yields this output:
inner

B.16.4 | Date and time

Date and time support is not enabled by default, for portability and simplicity reasons.
However, HEVEA source distribution includes a simple (`sh`) shell script `xxdate.exe` that activates date and time support. The `hevea` command, should be invoked as :

    # hevea -exec xxdate.exe ...

This will execute the script `xxdate.exe`, whose output is then read by HEVEA. As a consequence, standard TeX counters `\year`, `\month`, `\day` and `\time` are defined and LATEX command `\today` works properly. Additionnally the following counters and commands are defined :

Counter `weekday` |  | day of week, 0...6 (e.g. 2)
Counter `Hour` |  | hour, 00...11 (e.g. 11)
Counter `hour` |  | hour, 00...23 (e.g. 11)
Counter `minute` |  | minute, 00...59 (e.g. 35)
Counter `second` |  | second, 00...611 (e.g. 57)
Command `\ampm` |  | AM or PM (e.g. AM)
Command `\timezone` |  | Time zone (e.g. CEST)
Command `\heveadate` |  | Output of the ```date`'' Unix command, (e.g. mar mai 21 11:35:57 CEST 2002)

Note that I choosed to add an extra option (and not an extra ```\@exec`'' primitive) for security reasons. You certainly do not want to enable HEVEA to execute silently an arbitrary program without being conscious of that fact. Moreover, the `hevea` program does not execute `xxdate.exe` by default since it is difficult to write such a script in a portable manner.
Windows users should enjoy the same features with the version of `xxdate.exe` included in the Win32 distribution.

B.16.5 | Fancy sectioning commands

Loading the `fancysection.hva` file will radically change the style of sectionnal units headers: they appear over a green backgroud, the backgrould color saturation decreases as the sectioning commands themselves do (this is the style of this manual). Additionnaly, the document background color is white.
The `fancysection.hva` file is intended to be loaded after the document base style. Thus, to use fancy section style in `doc.tex` whose base style is article you should issue the command:

    # hevea article.hva fancysection.hva doc.tex

You can also make a `doc.hva` file that contains the two lines:

    \input{article.hva}
    \input{fancysection.hva}

And then launch `hevea` as:

    # hevea doc.hva doc.tex

Sectioning command background colors can be changed by redefining the corresponding colors (`part`, `chapter`, `section`,...). For instance, you get various mixes of red and orange by:

    \input{article.hva}
    \input{fancysection.hva}
    \definecolor{part}{named}{BrickRed}
    \definecolor{section}{named}{RedOrange}
    \definecolor{subsection}{named}{BurntOrange}

(See section B.14.2 for details on the `named` color model that is used above.)
Another choice is issuing the command `\colorsection{`hue`}`, where hue is a hue value to be interpreted in the HSV model. For instance,

    \input{article.hva}
    \input{fancysection.hva}
    \colorsections{20}

will yield sectionnal headers on a red-orange background.

B.16.6 | HEVEA as a Back-End for VideoC

HEVEA is one of the back-ends of the VideoC system for producing educational CDROM to teach programming languages. VideoC author is Christian Queinnec and the documentation is available at:
`http://www-spi.lip6.fr/~queinnec/VideoC/VideoC.html`.
VideoC translates LATEX source into a variety of formats, including HTML. VideoC source may contain some special constructs for typesetting source code or to annotate text in sophisticated ways. HEVEA internal engine implements some of the core constructs needed by VideoC. The rest of VideoC constructs are implemented by the `.hva` files from VideoC distribution.

1
  According to `date` man page.