<!DOCTYPE article SYSTEM "gellmu.dtd"><article stem="newcom">
<nul/>
<nul/>
<nul/>
<nul/>
<nul/>
<nul/>
<surtitle>The <abbr>GELLMU</abbr> Archive</surtitle>
<title>The Use of <emph>newcommand</emph> in <abbr>GELLMU</abbr></title>
<nobanner>
<body>

<section>Introduction</section>
<parb>
In <abbr>GELLMU</abbr> the command <emph>newcommand</emph> is a meta<hyp/>command that is
handled by macro<hyp/>like pre<hyp/>processing in the <abbr>GELLMU</abbr> syntactic translator<eos/>  This pre<hyp/>processing
takes place very early after the processing of the required meta<hyp/>command
<emph>documenttype</emph> and after the insertion of any (relatively rare)
internal <abbr>SGML</abbr> declaration subset<eos/>

<section>First Examples</section>
<parb>
The markup for the field <tmath><regch><bold>Q</bold></regch></tmath> of rational numbers is a <emph>newcommand</emph>
invocation <qquostr><bsl/>Q</qquostr> without arguments that expands to
<qquostr><bsl/>regch<lbr/><bsl/>bold<lbr/>Q<rbr/><rbr/></qquostr>.<footnote>The command <emph>regch</emph>
is an alternative form of <emph>mbox</emph> in the didactic <abbr>GELLMU</abbr> document
type definition that differs from the latter in that it is permitted as
the content of an <quophrase>accent</quophrase> tag as in the example <tmath><ovbar><regch><bold>Q</bold></regch></ovbar></tmath><aoc>
which is written in the <abbr>GELLMU</abbr> source here with
<quostr><bsl/>ovbar<lbr/><bsl/>Q<rbr/></quostr><eos/></footnote>
Newcommand names are case<hyp/>sensitive<eos/>  Here the newcommand invocation
<qquostr><bsl/>q</qquostr> expands to <qquostr><bsl/>regch<lbr/><bsl/>slnt<lbr/>Q<rbr/><rbr/></qquostr>,
which yields the ad<hyp/>hoc math symbol <tmath><regch><slnt>Q</slnt></regch></tmath><aos>
<parb>
Markup to represent the general linear group may be a <emph>newcommand</emph>
with definition
<display>
<verb><bsl/>newcommand<lbr/><bsl/>gl<rbr/>[2][2]<lbr/><bsl/>mbox<lbr/>GL<rbr/><und/><lbr/><hsh/>1<rbr/>(<hsh/>2)<rbr/></verb> <eos/>
</display>
When invoked with <qquostr><bsl/>gl<lbr/>3<rbr/><lbr/>F<rbr/></qquostr>, it yields
<tmath><mbox>GL</mbox><sub>3</sub>(F)</tmath><aos>
<parb>
Mention of the group <tmath><mbox>GL</mbox><sub>2</sub>(F)</tmath> is obtained alternatively here with the
minimized markup invocation <qquostr><bsl/>gl<lbr/>F<rbr/></qquostr> relying on the
default value of the first argument given in the definition of
<qquostr><bsl/>gl</qquostr><eos/>

<section>Some Details</section>
<parb>
With the <emph>newcommand</emph> definition
<display>
<verb><bsl/>newcommand<lbr/><bsl/>Q<rbr/><lbr/><bsl/>regch<lbr/><bsl/>bold<lbr/>Q<rbr/><rbr/><rbr/></verb>
</display>
the markup <verb><bsl/>Q;</verb> may always be used instead of <verb><bsl/>Q</verb>
and must be used if the <tmath><regch><bold>Q</bold></regch></tmath> is followed immediately by characters
that could have the effect of making the <quochar>Q</quochar> in the markup
look simply like the first character in a larger string<eos/>  However, the
markup <verb><bsl/>Q;<lbr/><rbr/></verb> is incorrect unless <emph>regch</emph> is a
command that takes two arguments<eos/>  For it expands to
<display>
<verb><bsl/>regch<lbr/><bsl/>bold<lbr/>Q<rbr/><rbr/><lbr/><rbr/></verb> <eos>
</display>

<subsection>What Markup Can Follow a <emph>newcommand</emph><eoq></subsection>
<parb>
What characters can safely follow the name of a <emph>newcommand</emph><eoq/>
Of course, a following <quochar><lbr/></quochar> can only mean the beginning of
an argument to the command<eos/>  On the other hand the <quochar><lbr/></quochar> can
be escaped<eos/>
<parb>
Some examples:
<tablec><ag0>ll</ag0>
<tr><td><bold>Markup</bold><nbs/><nbs/><nbs/><nbs/></td><td><bold>Yield</bold></td>
<tr><td><verb><dol/><bsl/>Q<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch></tmath></td>
<tr><td><verb><dol/><bsl/>Q;xy<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch>xy</tmath></td>
<tr><td><verb><dol/><bsl/>Q;<dol/>xy</verb></td><td><tmath><regch><bold>Q</bold></regch></tmath>xy</td>
<tr><td><verb><dol/><bsl/>Q;;<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch>;</tmath></td>
<tr><td><verb><dol/><bsl/>Q;<dol/>;</verb></td><td><tmath><regch><bold>Q</bold></regch></tmath>;</td>
<tr><td><verb><dol/><bsl/>Q<bsl/>bsl;<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><bsl/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<bsl/><lbr/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><lbr/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<bsl/><rbr/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><rbr/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<bsl/>lsb;<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><lsb/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<bsl/>rsb;<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><rsb/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<exc/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><exc/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<atc/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><atc/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<bsl/><hsh/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><hsh/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<bsl/><pct/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><pct/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<crt/>5<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><sup>5</sup></tmath></td>
<tr><td><verb><dol/><bsl/>Q<und/>p<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><sub>p</sub></tmath></td>
<tr><td><verb><dol/><bsl/>Q<bsl/>und;<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><und/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<bsl/>crt;<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><crt/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<ast/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><ast/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<hyp/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><hyp/></tmath></td>
<tr><td><verb><dol/><bsl/>Q(t)<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch>(t)</tmath></td>
<tr><td><verb><dol/><bsl/>Q<plu/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><plu/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<eqs/><dol/></verb></td><td><tmath><regch><bold>Q</bold></regch><eqs/></tmath></td>
<tr><td><verb><dol/><bsl/>Q<dol/></verb><eqs/></td><td><tmath><regch><bold>Q</bold></regch></tmath><eqs/></td>
<tr><td><verb><dol/><bsl/>Q,<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch>,</tmath></td>
<tr><td><verb><dol/><bsl/>Q.<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch>.</tmath></td>
<tr><td><verb><dol/><bsl/>Q?<dol/></verb></td><td><tmath><regch><bold>Q</bold></regch>?</tmath></td>
</tablec>

<subsection>Comments in newcommand definitions</subsection>
<parb>
It is useful here to comment on <abbr>GELLMU</abbr>, which is a bridge from
<latex/> to <abbr>SGML</abbr>, as it compares to <latex/><eos/>
<latex/> usage of <emph>newcommand</emph> sometimes takes the form
<nul/>
<nul/>
<nul/>
<nul/>
<tablec><ag0>l</ag0>
<tr><td><verb><bsl/>newcommand<lbr/><bsl/>foo<rbr/>[2]<lbr/><pct/></verb>
<tr><td><verb>This is an instance of the <bsl/>emph<lbr/>newcommand<rbr/> <lsq/><lsq/>foo<rsq/><rsq/> <pct/></verb>
<tr><td><verb>with first argument `<hsh/>1' and<pct/>  Space following a newline is swallowed</verb>
<tr><td><verb><spc/>second argument `<hsh/>2'.<rbr/></verb>
</tablec>
<parb>
This usage is useful in that it gives the author a way, especially with
empty comments, to make the source document more readable<eos/>
<parb>
With <abbr>GELLMU</abbr> as a general matter such use of comments in regular
command arguments may have side effects if the author is not careful<eos/>
Because <emph>newcommand</emph> is a meta<hyp/>command handled by the <abbr>GELLMU</abbr> syntactic translator, this
use of comments will not have side effects<eos/>
<parb>
Since <emph>newcommand</emph> in <abbr>GELLMU</abbr> is a meta<hyp/>command, it is <bold>not</bold>
necessary to restrict an instance of <emph>newcommand</emph> to a document
preamble<eos/>  However, any invocation of a command defined with
<emph>newcommand</emph> must be preceded by the definition<eos/>
<parb>
The definition of <quostr><bsl/>foo</quostr> appears in this
document just before the display of its definition, and the next
sentence is the invocation <qquostr><bsl/>foo<lbr/>cat<rbr/><lbr/>dog<rbr/></qquostr><eos/>
This is an instance of the <emph>newcommand</emph> <lsq/><lsq/>foo<rsq/><rsq/> with first argument `cat' andsecond argument `dog'<eos/>
<parb>
Note that the comment <quophrase>Space following <ldots></quophrase> on the second
line of the value string absorbs the space at the beginning of the
third line with the result that the words <emph>and</emph> and <emph>second</emph>
are run together<eos/>  This phenomenon mimics <latex/>; however, such
comment <quophrase>overrun</quophrase> is the behavior of the <abbr>GELLMU</abbr> syntactic translator
only inside a <emph>newcommand</emph> value string<eos/>  In all other contexts
there is no comment overrun in <abbr>GELLMU</abbr>, and space at the beginning of
a line following a comment is significant<eos/>

<subsection>Newlines in newcommand definitions</subsection>
<parb>
It is important to note, however, that <emph>anything</emph> inside the
value argument of a <emph>newcommand</emph> definition is propogated by the
<abbr>GELLMU</abbr> syntactic translator to every invocation<eos/>  With basic <abbr>GELLMU</abbr> newlines inside a
newcommand value string are removed since <abbr>SGML</abbr> does not acknowledge a
newline as a special form of white space and since newlines in a value
string, when propogated to all invocations cause extra lines in the
<abbr>GELLMU</abbr> syntactic translator output, thereby blocking the goal of line number alignment
between <abbr>GELLMU</abbr> source and the <abbr>SGML</abbr> output, which is important for
the interpretation of <abbr>SGML</abbr> parser error messages<eos/>
<parb>
In regular <abbr>GELLMU</abbr>, newlines can be significant<eos/>  For this reason
newlines in newcommand definitions are not removed<eos/>  However, the use
of newlines inside value strings is deprecated since they break line
number alignment between the <abbr>GELLMU</abbr> source and the output of the
<abbr>GELLMU</abbr> syntactic translator<eos/>  There are other ways to achieve the effect of a newline inside
a newcommand value string<eos/>

</body>
</article><!-- GELLMU version 0.7.4.2 (05-Jan-2006) -->

