\defcmd

Command in package userctrl.

Synopsis

\defcmd{name}[num-args][num-opt-args{default-1}{default-2}...]{code}

Description

Defines a new command. name is the name of the command (must start with
a backslash). code is the Mmtex code to execute when the command is called.
num-args is the total number of arguments (mandatory and optional ones).
num-opt-args is the number of optional arguments. The {...} blocks following
the number of optional arguments specify the defaults for the optional arguments.
The n-th {...} block contains the default for the n-th optional argument. Some
or all of these blocks may be omitted. Whitespaces between, before, and after the
blocks are ignored.

Example 1

\defcmd{\mycmd}{Hello World!}

My command says: \mycmd

Result, as rendered by your browser

My command says: Hello World!

Example 2

\defcmd{\mycmd}[1]{Hello #1!}

\mycmd{World} \mycmd{everybody}

Result, as rendered by your browser

Hello World! Hello everybody!

Example 3

\defcmd{\mycmd}[3][2{foo}{bar}]{arg1: #1, arg2: #2, arg3: #3}

\mycmd{test}

\mycmd[aaa]{test}

\mycmd[aaa][bbb]{test}

Result, as rendered by your browser

arg1: foo, arg2: bar, arg3: test

arg1: aaa, arg2: bar, arg3: test

arg1: aaa, arg2: bbb, arg3: test


This page is generated automatically and each change here will be replaced on a next update.

Add picture from clipboard (Maximum size: 500 MB)