<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/css"
   href="/~hammond/gellmu/gellmuart.css"?>
<!DOCTYPE article
  PUBLIC "-//GNU GPL: William F. Hammond//DTD GELLMU XML 0.7.5U//EN"
  "http://www.albany.edu/~hammond/gellmu/xml/uxgellmu.dtd" [
<!ENTITY TableOfContentsFile SYSTEM "newcom.xcn">
<!ENTITY % ComputedEntitiesFile SYSTEM "newcom.xet">
%ComputedEntitiesFile;
]>
<article stem="newcom"
><nul
/><nul
/><nul
/><nul
/><nul
/><nul
/><preamble
><surtitle
>The <abbr
>GELLMU</abbr> Archive</surtitle><title
>The Use of <emph
>newcommand</emph> in <abbr
>GELLMU</abbr></title><nobanner
/></preamble><body
><Section depth="1" seq = "1" sid="1"
><sunit>&SecRef-1;</sunit
><shead
><label lseq="1">SU-1</label
>Introduction</shead><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
/>
</parb></Section
><Section depth="1" seq = "2" sid="2"
><sunit>&SecRef-2;</sunit
><shead
><label lseq="2">SU-2</label
>First Examples</shead><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><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><msub
>3</msub>(F)</tmath><aos
/></parb><parb
>Mention of the group <tmath
><mbox
>GL</mbox><msub
>2</msub>(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
/>
</parb></Section
><Section depth="1" seq = "3" sid="3"
><sunit>&SecRef-3;</sunit
><shead
><label lseq="3">SU-3</label
>Some Details</shead><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>
</parb><Subsection depth="2" seq = "1" sid="3.1"
><sunit>&SecRef-4;</sunit
><shead
><label lseq="4">SU-3.1</label
>What Markup Can Follow a <emph
>newcommand</emph><eoq
/></shead><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><parb
>Some examples:
<tablec
><tabarg
>ll</tabarg><tr
><tdr><bold
>Markup</bold><nbs
/><nbs
/><nbs
/><nbs
/></tdr><tdr><bold
>Yield</bold></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q;xy<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch>xy</tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q;<dol
/>xy</verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch></tmath>xy</tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q;;<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch>;</tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q;<dol
/>;</verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch></tmath>;</tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<bsl
/>bsl;<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><bsl
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<bsl
/><lbr
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><lbr
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<bsl
/><rbr
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><rbr
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<bsl
/>lsb;<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><lsb
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<bsl
/>rsb;<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><rsb
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<exc
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><exc
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<atc
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><atc
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<bsl
/><hsh
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><hsh
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<bsl
/><pct
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><pct
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<crt
/>5<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><pow
>5</pow></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<und
/>p<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><msub
>p</msub></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<bsl
/>und;<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><und
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<bsl
/>crt;<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><crt
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<ast
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><ast
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<hyp
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><minus
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q(t)<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch>(t)</tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<plu
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><plus
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<eqc
/><dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch><equals
/></tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q<dol
/></verb><eqc
/></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch></tmath><eqc
/></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q,<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch>,</tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q.<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch>.</tmath></tdr></tr><tr
><tdr><verb
><dol
/><bsl
/>Q?<dol
/></verb></tdr><tdr><tmath
><regch
><bold
>Q</bold></regch>?</tmath></tdr></tr></tablec>
</parb></Subsection
><Subsection depth="2" seq = "2" sid="3.2"
><sunit>&SecRef-5;</sunit
><shead
><label lseq="5">SU-3.2</label
>Comments in newcommand definitions</shead><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
><tabarg
>l</tabarg><tr
><tdr><verb
><bsl
/>newcommand<lbr
/><bsl
/>foo<rbr
/>[2]<lbr
/><pct
/></verb></tdr></tr><tr
><tdr><verb
>This is an instance of the <bsl
/>emph<lbr
/>newcommand<rbr
/> <lsq
/><lsq
/>foo<rsq
/><rsq
/> <pct
/></verb></tdr></tr><tr
><tdr><verb
>with first argument `<hsh
/>1' and<pct
/>  Space following a newline is swallowed</verb></tdr></tr><tr
><tdr><verb
><spc
/>second argument `<hsh
/>2'.<rbr
/></verb></tdr></tr></tablec></parb><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><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><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><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><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
/>
</parb></Subsection
><Subsection depth="2" seq = "3" sid="3.3"
><sunit>&SecRef-6;</sunit
><shead
><label lseq="6">SU-3.3</label
>Newlines in newcommand definitions</shead><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><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
/>
</parb></Subsection
></Section
></body
></article>
