Macro invocation

Back to Macros

This section introduces macro invocation.

Explicit macro-invocation

A macro can be invoked explicitly in four ways:

To introduce invocation, we shall take the Comment macro as an example.

Invoking with no parameters

[[Comment]]

Invoking with an inline parameter

[[Comment: This is an inline parameter.]]

Invoking with a one-line parameter

[[Comment]]: This is a one-line parameter.

Invoking with a multi-line parameter

[[Comment]]:
    This is a multi-line parameter
    which can use as many rows as needed.

The parameter is multi-line if and only if

Implicit macro-invocation

A macro is invoked implicitly if and only if

The invoked macro, called the indentation macro, is specified by the indent variable. This variable may also contain expansion specifiers. By default, indent is set to Verbatim, to invoke the Verbatim macro. However, depending on the field of study, it may be more useful to set the indentation macro to the Code macro or the EquationSet macro.

[[set indent]]: EquationSet

The solution of the quadratic equation

    ax^2 + bx + c = 0

is given by

    x = (-b +- sqrt(b^2 - 4ac)) / (2a)

The solution of the quadratic equation

is given by

Range of a multi-line parameter

The range of a multi-line parameter extends downwards until there is a line which contains non-white-space characters and which has indentation (counted in tabs) equal to or less than the indentation of the macro invocation.

[[Comment]]:
    This is a multi-line parameter
    which can use as many rows as needed.

    This is still part of the multi-line parameter.

This is not part of the Comment parameter.

This is not part of the Comment parameter.

Equivalence of invocation styles

All styles of invocation are equivalent by the following rules: