Commands and Environments
Author: Luc Maranget

## B.1 Commands and Environments

- Command Names and Arguments
- Environments
- Fragile Commands
- Declarations
- Invisible Commands
- The \\ Command

### B.1.1 Command Names and Arguments

LATEX comments that start with “`%`” and end at end of line are ignored and produce no output. Usually, HEVEA ignore such comments. However, HEVEA processes text that follows “`%HEVEA`” and some other comments have a specific meaning to it (see section 5.3).

Command names follow strict LATEX syntax. That is, apart from `#`, `$`, `~`, `_` and `^`, they either are “`\`” followed by a single non-letter character or “`\`” followed by a sequence of letters. Additionally, the letter sequence may be preceded by “`@`” (and this is the case of many of HEVEA internal commands), or terminated by “`*`” (starred variants are implemented as plain commands).

Users are strongly advised to follow strict LATEX syntax for arguments. That is, mandatory arguments are enclosed in curly braces `{`… `}` and braces inside arguments must be properly balanced. Optional arguments are enclosed in square brackets `[`… `]`. However, HEVEA does its best to read arguments even when they are not enclosed in curly braces. Such arguments are a single, different from “`\`”, “`{`” and “`` ”, character or a command name. Thus, constructs such as `\'ecole`, `$a_1$` or `$a_\Gamma$` are recognized and processed as école a1 and aΓ. By contrast, `a^\mbox{...}` is not recognized and must be written `a^{\mbox{...}}`.

Also note that, by contrast with LATEX, comments are parsed during argument scanning, as an important consequence brace nesting is also checked inside comments.

With respect to previous versions, HEVEA has been improved as regards emulation of complicated argument passing. That is, commands and their arguments can now appear in different static text bodies. As a consequence, HEVEA correctly processes the following source:

    \newcommand{\boite}{\textbf}
    \boite{In bold}

The definition of `\boite` makes it reduces as `\textbf` and HEVEA succeeds in fetching the argument “`{In bold}`”. We get

> In bold

The above example arguably is no “legal” LATEX, but HEVEA handles it. Of course, there remains numerous “clever” LATEX tricks that exploits TEX internal behaviour, which HEVEA does not handle. For instance consider the following source:

    \newcommand{\boite}[1]{\textbf#1}
    \boite{{In bold}, Not in Bold.}

LATEX typesets the text “In bold” using bold font, leaving the rest of the text alone. While HEVEA typesets everything using bold font. Here is HEVEA output:

> In bold, Not in Bold.

Note that, in most similar situations, HEVEA will likely crash.

As a conclusion of this important section, Users are strongly advised to use ordinary command names and curly braces and not to think too much the TEX way.

### B.1.2 Environments

Environment opening and closing is performed like in LATEX, with `\begin{`env`}` and `\end{`env`}`. The `*`-form of an environment is a plain environment.

It is not advised to use `\`env and `\end`env in place of `\begin{`env`}` and `\end{`env`}`.

### B.1.3 Fragile Commands

Fragile commands are not relevant to HEVEA and `\protect` is defined as a null command.

### B.1.4 Declarations

Scope rules are the same as in LATEX.

### B.1.5 Invisible Commands

I am a bit lost here. However spaces in the output should correspond to users expectations. Note that, to HEVEA being invisible commands is a static property attached to command name.

### B.1.6 The \\ Command

The `\\` and `\\*` commands are the same, they perform a line break, except inside arrays where they end the current row. Optional arguments to `\\` and `\\*` are ignored.