Go to page:

Search:   Help

Edit

Links

# OptionalEnvironmentArguments

Categories: LyxTricks
<< | Page list | >>

## How to add optional arguments to environments

Many LaTeX environments accept optional arguments that influence their behavior. The theorem environment, for example, accepts an optional argument that is typeset after the theorem number, often used for the name of the theorem or to give credit to its discoverer. In LaTeX, this would be written thus: \begin{theorem}[Cohen, 1961] or \begin{theorem}[Schröder-Bernstein Theorem], with results like these:

Theorem 1.1 (Cohen, 1961).
Theorem 1.2 (Schröder-Bernstein Theorem).

LyX offers no obvious way to do this, but in fact it is quite simple. All you need to do is enter the optional argument as ERT immediately following the appearance of "Theorem 1.2", or whatever, in LyX. It works because the optional argument follows the environment declaration. A similar trick works, therefore, with enumerations. If you put "[Label]" in ERT immediately after the number, "2.", or whatever, "Label" will be used as the label.

In many instances, such as the theorem and proof environments, an even simpler technique applies. Immediately after the start of the enviroment right click and from the context menu choose "insert short title".

Page last modified on 2012-09-27 05:34 CEST