% BasicMacros.tex of January 9, 1984 9:03 pm --- Stolfi
% A set of basic TEX macros. Similar to Basic.tex, minus font
% definitions, plus some new goodies.
% Uses counters 1 thru 6
% Things to fix:
% (?) change internal absolute \*skips to ex and em instead of pt
% provide for centered figure captions (optional)?
% Fix \twoline!
% Modify \pcomm to use small and \hbox par
% Add automatic indentation to \prog
% Put penalty around \figspaces (but not \capfigs?), like math displays
% MATH SYMBOLS AND FUNCTIONS
% These macros assume CMR fonts will be used for math mode
% Empty box
\def\null{\hbox{}}
% Operator, quantifier, and relation symbols
\def\leq{\mathrel{\char'424}} % less or equal
\def\geq{\mathrel{\char'425}} % greater or equal
\def\neq{\mathrel{\not=}}
\def\iso{\mathrel{\char'430}} % single squiggle
\def\simil{\mathrel{\char'431}} % double squiggle
\def\eqv{\mathrel{\char'421}} % equivalence (triple equals)
\def\neqv{\mathrel{\not\eqv}}
\def\up{\mathrel{\char'442}} % up arrow
\def\down{\mathrel{\char'441}} % down arrow
\def\gets{\mathrel{\char'440}} % left or assignment arrow
\def\to{\mathrel{\char'441}} % right or limit arrow
\def\rslash{\mathbin{\char'404}} % reverse slash (\)
\def\and{\mathbin{\char'536}} % logical and operator (meet)
\def\or{\mathbin{\char'537}} % logical or operator (join)
\def\implies{\mathrel{\char'451}} % right implication arrow
\def\impliedby{\mathrel{\char'450}} % left implication arrow
\def\doubleimpl{\mathrel{\char'454}} % two-way implication arrow
\def\forall{\mathop{\char'470}} % universal quantifier
\def\exists{\mathop{\char'471}} % existential quantifier
\def\land{\and} % boolean and operator
\def\lor{\or} % boolean or operator
\def\lnot{\mathop{\char'472}} % boolean not operator ("bent dash")
\def\xor{\oplus } % boolean exclusive or (circle plus)
\def\inte{\mathbin{\char'534}} % infix intersection operator
\def\uni{\mathbin{\char'533}} % infix union operator
\def\empty{\char'100} % use Scandinavian crossed-O for empty set
\def\doubleint{\int\?\?\int} % double integral
\def\sectionmark{\char'570 } % section symbol
\def\paragmark{\char'573 } % paragraph mark
\def\percent{\char'045 } % percent sign (%)
\def\dollar{\char'577 } % dollar sign ($)
\def\pound{\char'561 } % pound or number sign (#)
\def\atsign{\char'574 } % "at" sign (@)
% Logical connectives in text font
\def\rmiff{\,\mathrel{\hbox{iff}}\,} % "iff" in text font
\def\rmif{\,\mathrel{\hbox{if}}\,} % "if" in text font
\def\rmand{\,\mathrel{\hbox{and}}\,} % "and" in text font
\def\rmor{\,\mathrel{\hbox{or}}\,} % "or" in text font
% Math functions and other spelled-out operators
\def\log{\mathop{\char l\char o\char g}\limitswitch}
\def\lg{\mathop{\char l\char g}\limitswitch}
\def\ln{\mathop{\char l\char n}\limitswitch}
\def\lim{\mathop{\char l\char i\char m}}
\def\limsup{\mathop{\char l\char i\char m\,\char s\char u\char p}}
\def\liminf{\mathop{\char l\char i\char m\,\char i\char n\char f}}
\def\sin{\mathop{\char s\char i\char n}\limitswitch}
\def\cos{\mathop{\char c\char o\char s}\limitswitch}
\def\tan{\mathop{\char t\char a\char n}\limitswitch}
\def\cot{\mathop{\char c\char o\char t}\limitswitch}
\def\sec{\mathop{\char s\char e\char c}\limitswitch}
\def\csc{\mathop{\char c\char s\char c}\limitswitch}
\def\max{\mathop{\char m\char a\char x}}
\def\min{\mathop{\char m\char i\char n}}
\def\sup{\mathop{\char s\char u\char p}}
\def\inf{\mathop{\char i\char n\char f}}
\def\det{\mathop{\char d\char e\char t}}
\def\exp{\mathop{\char e\char x\char p}\limitswitch}
\def\Pr{\mathop{\char P\char r}}
\def\gcd{\mathop{\char g\char c\char d}}
\def\mod{\<\,\mathbin{\char m\char o\char d}\<\,}
% Delimiters
\def\}{\~} % defines backslash-brace as equivalent to backslash-tilde
\def\lbrace{\{} % left brace
\def\rbrace{\}} % right brace
\def\lpoint{\mathbin{\hbox{\arfont s}}}
\def\rpoint{\mathbin{\hbox{\arfont h}}}
\def\choose{\comb()}
\def\sp{\mathbin{\}} % to denote continuous intervals (segs, arcs, etc)
\def\isp{\mathbin{.\.}} % to denote integer intervals (as in Pascal)
\def\set#1{{\lbrace#1\rbrace}} % set defined by enumeration
\def\rset#1{{\mathopen{\lbrace}
\, #1 \,\mathclose{\rbrace}}} % set defined by \relv
\def\seq#1{\langle #1 \rangle} % sequence
\def\abs#1{\leftv #1 \rightv} % absolute value or set size
\def\qquad{\quad\quad}
% Multiple dots
\def\ldots{{.\.\.}}
\def\cdots{{\char'401\\char'401\\char'401}} % centered dots
\def\ldotss{{.\.\.\}}
\def\cdotss{\cdots\}
\def\ldotsm{{\.\.\.\}}
\def\cdotsm{{\\cdots\}}
\def\vdots{\vcenter{\baselineskip-1pt\lineskip0pt\cmr\null
\vskip 0.25em\hbox{.}\vskip0.15em\hbox{.}\vskip0.15em\hbox{.}
\vskip 0.25em\null}}
% Special constructs
\def\pr{^\prime}
\def\prr{^{\prime\prime}}
\def\star{^\ast} % asterisk in superscript position.
\def\deg{^\circ}
\def\bar#1{{\overline{#1}}}
\def\hat#1{{\hatac #1}} % fix this!
\def\modulo#1{\penalty0\;(\char m\char o\char d\char u\char l\char o,\,#1)}
% ALIGNMENT MACROS
% Justification macros for \halign.
\def\lft#1{#1\hfill}
\def\ctr#1{\hfill#1\hfill}
\def\rt#1{\hfill#1}
% Aligned equations.
\def\eqalign#1{\baselineskip4ex\lineskip0.8ex
\vcenter{\halign{\hfill$\dispstyle{##}$$\dispstyle{\null##}$\hfill
\cr#1}}}
\def\eqalignno#1{\baselineskip4ex\lineskip0.8ex
\vbox{\tabskip 0pt plus 1000pt minus 1000pt
\halign to size{\hfill$\dispstyle{##}$\tabskip 0pt
$\dispstyle{\null##}$\hfill\tabskip 0 pt plus 1000pt minus 1000pt
\hfil$ ##$\tabskip 0pt\cr#1}}}
% Two-line formulas.
% Usage: \twoline{line1}{glue}{line2}
\def\twoline#1#2#3{\vbox{
\hbox to \textwidth pt{$ \quad\dispstyle {#1} $\hfill}
\vskip#2
\hbox to \textwidth pt{\hfill $\dispstyle {#3}\quad$}}}
% Additional inter-line spacing for \halign and co.
% Usage: \halign{ ... \cr\vsk7 ...} for 7x(0.2ex) of extra space
% (parameter range 1--9 only)
\def\vsk#1{\noalign{\vskip 0.#1ex plus0.#1ex\vskip 0.#1ex}}
% Centered vertical stacks of boxes.
\def\cpile#1{\vcenter{\halign{\hfill$## $\hfill\cr#1}}}
\def\lpile#1{\vcenter{\halign{$## $\hfill\cr#1}}}
\def\rpile#1{\vcenter{\halign{\hfill$## $\cr#1}}}
% Conditional expressions.
% Usage: \alter{x+1 if $x>0$ and $y>0$,\cr
% x-1 otherwise.\cr}
\def\alter#1{\left\{
\vcenter{\halign{
$\dispstyle \lft{##} $ \quad\quad \lft{##}\cr #1}}\right.}
% rectangular matrices
% Usage: for a matrix with 5 columns (and any number of rows), use
% \matrix5{x{11}x{12}x{13}x{14}x{15}\cr
% x{21} ... x{25}\cr
% ...
% x{m1} ... x{m5}\cr}
%
% Warning: uses counter #2
\def\matrixctrfmt{\ctr{$ ## $}}
\def\matrixcr{\cr }
\def\matrixhalign{\halign}
\def\matrixreploop{\xdef\matrixaccum{\matrixaccum\matrixctrfmt}
\advcount2 by-1
\ifpos2{\xdef\matrixaccum{\matrixaccum\hskip1em }
\matrixreploop}
\else{\xdef\matrixaccum{\matrixaccum\matrixcr}}}
\def\matrix#1#2{\setcount2 #1
\xdef\matrixaccum{}
\matrixreploop
\xdef\matrixaccum{\matrixhalign{\matrixaccum #2}}
\,\,\vcenter{\matrixaccum}\,\,}
% BOX TWIDDLING
% pretends that #2 is #1pt deep (warning: uses box 0)
\def\chop to#1pt#2{\save0\hbox{$\dispstyle{#2}$}\hbox{\lower#1pt\null
\vbox to 1ht0{\box0\vss}}} %
% Superimposes argument over next or previous box
\def\spose#1{\hbox to 0pt{#1\hss}} % over next box
\def\rspose#1{\hbox to 0pt{\hss#1\hfilneg}} % over previous box
% Macros for measuring boxes
% The macro \convert divides dimension #1 by the unit #2,
% and sets \count6 to the result (rounded down and clamped above zero).
% For example, \convert{2in}{pt} sets \count6 to 2x72=144.
\def\convert#1#2{\setcount6 0
\xdef\convdim{#1}\xdef\convunit{#2}\convloopa}
\def\convloopa{\ifdimen \convdim > \count6\convunit
{{\advcount6 by 64}\convloopa} \else {\convloopb}}
\def\convloopb{\ifdimen \convdim < \count6\convunit
{{\advcount6 by -16}\convloopb} \else {\convloopc}}
\def\convloopc{\ifdimen \convdim > \count6\convunit
{{\advcount6 by 4}\convloopc} \else{\convloopd}}
\def\convloopd{\ifdimen \convdim < \count6\convunit
{{\advcount6 by -1}\convloopd} \else{}} % (WHAT A CROCK...)
% PARAGRAPH MACROS
% Left-justified (i.e., standard), centered, and right-justified \hbox par.
% Usage:
% \lftpar 200 pt {This is the first line.\lp This is the second line.}
% \ctrpar 200 pt {This is the first line.\cp This is the second line.}
% \rtpar 200 pt {This is the first line.\rp This is the second line.}
% NOTE: DIMENSIONS MUST BE IN POINTS!
\def\lftpar#1pt#2{\hbox par #1 pt{#2}}
\def\ctrpar#1pt#2{\hbox par #1 pt{\hfil #2}}
\def\rtpar#1pt#2{\hbox par #1 pt{\hfil #2\hfilneg}}
\def\boxparskipper{\vbox to3ex{}} % for par spacing in boxed text
% Line breaks in \hbox par{...}
\def\lb{\hfil\linebreak } % line break in \lftpar (or paragraph)
\def\cb{\hfil\linebreak\hfil } % line break in \ctrpar
\def\rb{\linebreak\hfil } % line break in \rtpar
% Fake paragraph breaks in \hbox par{...}
\def\lp{\hfil\linebreak\boxparskipper } % parag. break in \lftpar
\def\cp{\hfil\linebreak\boxparskipper\hfil } % parag. break in \ctrpar
\def\rp{\linebreak\boxparskipper\hfil } % parag. break in \rtpar
% Fake display math in \hbox par{...}
% Usage: \lp\boxdisp{\pi>e}\lp
% or \lp\boxdisp{\pi>e}\boxeqno{(73)}\lp
\def\boxdisp#1{\hfil\vbox{\vskip 1ex \hbox{$\dispstyle #1 $}\vskip 1ex}}
\def\boxeqno#1{\hfil \hbox{#1}\hfilneg}
% Indented paragraphs.
% Usage:
% \indent Bla bla bla... or
% \begitems\item Foo;\item Bar;...\item Baz.\enditems OR
% \begitems\itemno{1.}Foo;\itemno{2.}Bar;...\itemno{9.}Baz.\enditems
\def\begitems{\par\vskip1ex plus0.3ex\penalty800 }
\def\enditems{\par\vskip1.1ex plus0.4ex }
\def\indent{\par\vskip 0.3ex\hangindent\textindent pt after0 }
\def\item{\itemno{$\bullet$}} % for unnumbered items
\def\itemno#1{\par\vskip-0.1ex\hangindent\itemindent pt after0
{$\rspose{#1\ } $}} % numbered items
% Digressions: small print text, indented.
% Usage: \digress{Mumble mumble.\dp More mumble.}
\def\digress#1{\vskip 0.2ex plus0.5ex \hangindent \textindent pt after0
{\small #1\par}\vskip0.2ex plus0.5ex}
\def\dp{\par\hangindent 15pt after0} % new paragraph in digression
% Page break control.
\def\opteject{\vfil\penalty0\vfilneg} % optional break w/ short page
\def\keep#1cm{\vbox to #1cm{}\vskip-#1cm} % keeps next #1 cm on same page
% FOOTNOTES
% Use \foot7{Blah Blah} for footnote number 7.
% Using \footfig3cm7{Blah Blah} leaves space at the right margin of
% the footnote for a figure 3cm high.
% Use \fp to break paragraphs in a footnote.
\def\footbox#1#2#3{{\small\hbox par #3 pt{$\null^{#1}$ #2}}}
\def\footfigbox#1{\vbox to #1cm{\hbox to 0pt{\null}}}
\def\foot#1#2{\unskip$\null^{#1}$\botinsert
{\footbox{#1}{#2}{\textwidth}}}
\def\footfig#1cm#2#3{$\null^{#2}$\botinsert
{\hbox
{$\vcenter{\footbox{#2}{#3}{\ftfigwidth}}
\vcenter{\footfigbox{#1}}$\hfil}}}
\def\fp{\lp} % \par (of sorts) in footnotes
% FIGURES
% \figspace 7.5cm -- leaves a blank space for a figure 7.5 cm high
% \capfig 5cm{Figure 2.1. Mumble mumble.} --- leaves space
% for a figure 5cm high with caption "Figure 2.2. Mumble mumble."
% \numfig 5cm{[3]} to get space for a figure 5cm high
% with equation number [3] at the right.
% Do \def\omitfigures{T} to supress figure space during development.
% NOTE: UNITS MUST BE CM!!!
\def\figspace#1cm{$$\figbox{#1}$$}
\def\capfig#1cm#2{$$\vbox{
\figbox{#1}
\ctrpar \textwidth pt{\lftpar \figcapwidth pt{#2}}
\vskip0.5ex}$$}
\def\numfig#1cm#2{$$\vcenter{\figbox{#1}}\eqno{#2}$$}
\def\figbox#1{\if T\omitfigures {\framebox{\hbox{#1 cm figure}}}
\else{\vbox to #1cm{\figmark\vfill}}}
% REFERENCES
% Usage:
% \ref [Boo] {\refauth{Boojum, C. D.}
% \reftit{Salting jubjubs in glue.}
% \refpub{J. of Beavers and Butchers V. 1 N. 357 (1999).}
% \refrem{Charming; reminds me of smiles and soap.}}
\def\ref [#1] #2{\par\penalty-400\vskip \refvskip ex
\hangindent \refindent em after1
$\hbox to \refindent em{[#1]\hss}$#2}
\def\refauth#1{\unskip {\rm #1}} % Author (s)
\def\reftit#1{\unskip\unskip, {\it #1}} % Title
\def\refpub#1{ {\rm #1}} % Publication
\def\refrem#1{\par\vskip0.5ex\hangindent \refremindent em after0
{\small $\rpoint$ #1}} % Review comments
\def\rp{\par\hangindent \refremindent em after0 } % paragraph in \refrem
% THEOREMS, DEFINITIONS, PROOFS
% Theorems, lemmas, conjectures, and definitions.
% Usage: \theorem{3.1}{P=NP.\tp Provided of course that N=1 or P=0.}
\def\lemma{\theolemma{\it}{Lemma}}
\def\theorem{\theolemma{\it}{Theorem}}
\def\corollary{\theolemma{\it}{Corollary}}
\def\conjecture{\theolemma{\it}{Conjecture}}
\def\definition{\theolemma{\rm}{Definition}}
\def\problem{\theolemma{\rm}{Problem}}
\def\theolemma#1#2#3#4{\par\penalty-300
\vskip 1.5ex plus 0.5ex minus 0.1ex
\hangindent \theostatindent pt after 1
{\bf #2 #3. }{\def\itemindent{\theoitemindent}#1 #4}\par
\vskip 1.0ex plus 0.5ex}
\def\tp{\par\hangindent
\theostatindent pt after0 } % new par in thm. or def. statement
% Proofs.
% Usage: \proof{Bla bla bla.\pp More bla bla bla.}
% (usually, but not necessarily, just after a \theorem or \lemma)
\def\proof#1{
\hangindent\proofindent pt after0\begproofmark #1\penalty1000
\endproofmark\par\vskip 1.0ex plus 1.0ex}
\def\pp{\par\hangindent \proofindent pt after0} % new par in proof
% MISCELLANEOUS
% Accent macros that work in any font
% A crock to get cmr accents in other fonts
\let\umlautac=\"
\let\tildeac=\s
\let\tieac=\t
\let\acuteac=\'
\let\graveac=\`
\let\hatac=\A
\let\cedillaac=\c
\let\breveac=\u
\let\longac=\=
\let\doubleS=\ss
\def\"#1{{\cmr\umlautac\mainfont #1}} % umlaut
\def\s#1{{\cmr\tildeac\mainfont #1}} % tilde
\def\t#1{{\cmr\tieac\mainfont #1}} % ligature (for russian IA etc)
\def\'#1{{\cmr\acuteac\mainfont #1}} % acute accent
\def\`#1{{\cmr\graveac\mainfont #1}} % grave accent
\def\A#1{{\cmr\hatac\mainfont #1}} % hat accent
\def\c#1{{\cmr\cedillaac\mainfont #1}} % cedilla accent
\def\C#1{{\spose{\cmr\char'30} #1}} % cedilla accent for capitals
\def\=#1{{\cmr\longac\mainfont #1}} % long accent
\def\u#1{{\cmr\breveac\mainfont #1}} % breve accent
\def\ss{{\cmr\doubleS}} % German double s
% Puts border around given box, 3pt away from it.
\def\framebox#1{\vbox
{\hrule
\hbox{\vrule\hskip3pt\vbox{\vskip3pt #1 \vskip3pt}\hskip3pt\vrule}
\hrule}}
% Mnemonics for TEX parameters
\def\jpar{\chpar1←}
\def\ragged{\chpar8←}
\def\jjpar{\chpar15←}
\def\loose{\chpar14←}
\def\uchyph{\chpar16←}
% DEBUGGING
% TEX trace macros
\def\trace{\chpar0←}
\def\macrotrace{\trace'355}
\def\pagetrace{\trace'347}
\def\fullpagetrace{\trace'77777747}
\def\normaltrace{\trace'345}
% Internal notes (from author to self).
% Usage:
% \note{Fix figure numbers below!}
% \move{Blah blah blah}
% \fix{We know that $\pi=\sqrt{10}$, so...}
% \junk{Blah blah}
\def\note#1{{{\bf [note:} #1{\bf ]}}} % for annotations to manuscript
\def\move#1{{{\bf [move this:} #1{\bf ]}}} % things to be moved
\def\fix#1{{{\bf [fix this:} #1{\bf ]}}} % things to be fixed
\def\junk#1{{{\bf [JUNK:} #1{\bf ]}}} % garbage, keep around just in case
% Bug mark.
% Usage: As seen in figure 3.\bug, ...
% The \bug macro is also useful for flagging TEX errors in
% the press file; just answer i\bug<CR> to error messages.
\def\bug{\hbox{\hskip1pt
\vrule width10pt height8pt depth2pt \hskip1pt}} % black block (input
% Puts thin border around box #1 on the inside (useful to debug boxes).
\def\showbox#1{\vbox
{\hrule height0.2pt\vskip-0.2pt
\hbox{\vrule width0.2pt\hskip-0.2pt #1 \hskip-0.2pt\vrule width0.2pt}
\vskip-0.2pt\hrule height0.2pt}}
% Shows a 1em by 1ex black box for the current font, and its size in pt.
% Usage: {\rm \showfontbox}
\def\showfontbox{This box is 1em by 1ex
\save7\hbox{\vrule height1ex width1em}
$(\approx\convert{10wd7}{pt}{{\count6}\over{10}}\hbox{\rm pt}\times
\convert{10ht7}{pt} {{\count6}\over{10}}\hbox{\rm pt})$:
\box7.}