Next: \DeclareTextCommandDefault & \ProvideTextCommandDefault, Previous: \DeclareTextAccentDefault, Up: fontenc package [Contents][Index]
\DeclareTextCommand
& \ProvideTextCommand
Synopsis, one of:
\DeclareTextCommand{cmd}{encoding}{defn} \DeclareTextCommand{cmd}{encoding}[nargs]{defn} \DeclareTextCommand{cmd}{encoding}[nargs][optargdefault]{defn}
or one of:
\ProvideTextCommand{cmd}{encoding}{defn} \ProvideTextCommand{cmd}{encoding}[nargs]{defn} \ProvideTextCommand{cmd}{encoding}[nargs][optargdefault]{defn}
Define the command cmd, which will be specific to one encoding.
The command name cmd must begin with a backslash, \. These
commands can only appear in the preamble. Redefining cmd
does
not cause an error. The defined command will be robust even if the code
in defn is fragile (see \protect).
For example, the file t1enc.def contains this line.
\DeclareTextCommand{\textperthousand}{T1}{\%\char 24 }
With that, you can express parts per thousand.
\usepackage[T1]{fontenc} % in preamble ... Legal limit is \( 0.8 \)\textperthousand.
If you change the font encoding to OT1
then you get an error like
‘LaTeX Error: Command \textperthousand unavailable in encoding
OT1’.
The \ProvideTextCommand
variant does the same, except that it
does nothing if cmd is already defined. The
\DeclareTextSymbol
command is faster than this one for simple
slot-to-glyph association (see \DeclareTextSymbol)
The optional nargs and optargsdefault arguments play the
same role here as in \newcommand
(see \newcommand & \renewcommand). Briefly, nargs is an integer from 0 to 9
specifying the number of arguments that the defined command cmd
takes. This number includes any optional argument. Omitting this
argument is the same as specifying 0, meaning that cmd will have
no arguments. And, if optargsdefault is present then the first
argument of \cmd
is optional, with default value
optargdefault (which may be the empty string). If
optargsdefault is not present then \cmd
does not take
an optional argument.