Previous: , Up: Special Characters   [Contents][Index]


12.1.6 Inserting ‘&’ with @& and @ampchar{}

Ordinarily, an ampersand ‘&’ is a normal character in Texinfo that can be simply typed in your input where you need it. The result is to typeset the ampersand character.

However, the ampersand character has a special meaning in Texinfo in just one restricted context. In the argument to a definition command (see Definition Commands), Emacs Lisp keywords beginning with ampersands are recognized and typeset specially. See A Sample Function Description in GNU Emacs Lisp Reference Manual. For example:

@defun foo integer1 &optional integer2 &rest integers
@code{foo} described here.
@end defun

leads to the output

Function: foo integer1 &optional integer2 &rest integers

foo described here.

So, in order to typeset an ampersand in such a context (for example, in documentation of a C++ function taking a reference as a parameter), it’s necessary to use @& or some other construct. Here’s an example:

@deftypefn Function int foo (@code{const std::vector<int>@&} bar)
Documentation of @code{foo}.
@end deftypefn

This gives the output

Function: int foo (const std::vector<int>& bar)

Documentation of foo.

Although ‘@&’ and ‘@ampchar{}’ can be used nearly anywhere, there is no need for them anywhere except this unusual case.