% Macros for basic text.
% Gary Houston.

% Ensure that line breaking will always occur if necessary, since
% underful hboxes usually look better than text sticking out into the
% margin. \emergencystretch needs TeX 3.0 or higher.
\emergencystretch=\hsize

% Highlighted phrases.
% Set up bold face italic font.
\ifnum\@ptsize=0\newfont{\bfit}{cmbxti10}\else
\ifnum\@ptsize=1\newfont{\bfit}{cmbxti10 at 11pt}\else
\ifnum\@ptsize=2\newfont{\bfit}{cmbxti10 at 12pt}\fi\fi\fi

% Automatic italic correction (from a TEI document and texinfo.tex).
\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}

\def\hpone#1{\protect\@hpone{#1}}
\def\hptwo#1{\protect\@hptwo{#1}}
\def\hpthree#1{\protect\@hpthree{#1}}
\def\hpzero#1{\protect\@hpzero{#1}}
\def\@hpone#1{{\it#1}\futurelet\next\smartitalicx}
\def\@hptwo#1{{\bf#1}}
\def\@hpthree#1{{\bfit#1}\futurelet\next\smartitalicx}
\def\@hpzero#1{{\rm#1}}

% Phrase architectural form.
% #1 gives element name (in capitals), #2 gives text.

\def\phrase#1#2{{\protect\@phrase{#1}{#2}}}
\def\@phrase#1#2{%
  \def\el@ment{EM}\def\@arg{#1}%
  \ifx\el@ment\@arg
    \em#2\futurelet\next\smartitalicx
  \else
    \em#2\futurelet\next\smartitalicx
  \fi
}

% Code architectural form.  #1 gives the name of the element, 
% #2 gives the text.
\def\code#1#2{\protect\@code{#1}{#2}}
\def\@code#1#2{{\tt\frenchspacing#2}}


% Abbreviations (assumes a single abbreviated word).
% Put the argument in an hbox, to get the spacing right in case it ends
% with a capital letter and is followed by a period.  Then check whether a
% period follows: if not, add a normal space (rather than a sentence-ending
% stretchable space).
\def\abbr#1{\hbox{#1}\futurelet\next\abbrx}
\def\abbrx{\ifx\next.\else.\ \ignorespaces\fi}

% A macro which turns off a special property of capital letters: a capital
% followed by a period is assumed to be an abbreviation. Don't wan't this
% behaviour in Snafu, since abbreviations can be marked explicitly.
\def\regularspacing {
  \sfcode`A=1000 \sfcode`B=1000 \sfcode`C=1000 \sfcode`D=1000
  \sfcode`E=1000 \sfcode`F=1000 \sfcode`G=1000 \sfcode`H=1000
  \sfcode`I=1000 \sfcode`J=1000 \sfcode`K=1000 \sfcode`L=1000
  \sfcode`M=1000 \sfcode`N=1000 \sfcode`O=1000 \sfcode`P=1000
  \sfcode`Q=1000 \sfcode`R=1000 \sfcode`S=1000 \sfcode`T=1000
  \sfcode`U=1000 \sfcode`V=1000 \sfcode`W=1000 \sfcode`X=1000
  \sfcode`Y=1000 \sfcode`Z=1000
}

% Address components.
\def\org#1{#1}
\def\street#1{#1}
\def\city#1{#1}
\def\region#1{#1}
\def\country#1{#1}
\def\postcode#1{#1}
\def\postbox#1{#1}

% Small fractions, from the texbook.
\def\sfrac#1/#2{\leavevmode\kern.1em
  \raise.5ex\hbox{\the\scriptfont0 #1}\kern-.1em
  /\kern-.15em\lower.25ex\hbox{\the\scriptfont0 #2}}

% International quotation marks 
% (see Johannes Braams, TeX and TUG NEWS, Vol 2, No 3, July 1993).

% Utility: put a string in a low box.
\def\set_low_box#1{\setbox2\hbox{,}\setbox0\hbox{#1}%
  \dimen0\ht0 \advance\dimen0 -\ht2%
  \setbox0\hbox{\lower\dimen0 \box0}\ht0\ht2 \dp0\dp2}

% Utility: preserve the current spacefactor.
\def\save_sf_q#1{{\ifhmode
  \edef\@SF{\spacefactor\the\spacefactor}\else
  \let\@SF\empty \fi \leavevmode #1\@SF}}

% Should have (I think):
%
%    ldquo  `` ___ '' rdquor        lsquo  ` ___ ' rsquor
%             |   |'' rdquo 		    |   |' rsquo
%             |   | 			    |   |
%             |___|			    |___|
%    ldquor ''			    lsquor '

% Low left rising double quote.
\def\quotedblbase{\protect\@ldquor}
\def\@ldquor{\save_sf_q{\set_low_box{''}\box0\kern-.04em}}

% Low left rising single quote.
\def\quotesinglbase{\protect\@lsquor}
\def\@lsquor{\save_sf_q{\set_low_box{'}\box0\kern-.04em}}

% High right double quote, reversed.
% Not currently used.
\def\rdquox{\protect\@rdquo}
\def\@rdquox{\save_sf_q{\kern-.07em``\kern.07em}}

% High right single quote, reversed.
% Not currently used.
\def\rsquox{\protect\@rsquo}
\def\@rsquox{\save_sf_q{\kern-.07em`\kern.07em}}

% Guillemets.
% Apparently NFSS needs the following:
\ifx\undefined\selectfont
\else
  \def\ly{\fontfamily{lasy}\fontseries{m}
	  \fontshape{n}\selectfont}
\fi
\chardef\lg='050
\chardef\rg='051
% <<
\def\guillemotleft{\protect\@laquo}
\def\@laquo{\hbox{\ly\lg\kern-0.2em\lg\kern+0.2em}}
% >>
\def\guillemotright{\protect\@raquo}
\def\@raquo{\hbox{\ly\kern+0.2em\rg\kern-0.2em\rg}}

% &thorn; and &THORN;.
% This is not a very good definition.
\def\th{th}
\def\TH{Th}

% &eth; and &ETH;
% This is not a very good definition.
\def\dh{$\partial$}
\def\DH{\mbox{\rlap{\raise.3ex\hbox{--}}D}}

% Circled r symbol, stolen from Peter Mutsaers and modified.
\def\rcircle{%
\begin{picture}(8,10)
\put (.9,4.4){\tiny R}
\put (3,6){\circle{6.5}}
\end{picture}}

% Filled square and hyphen bullet symbols.  The catcode of the space character
% must be set since otherwise the macros fail in the listing environment.
\def\squf{{\catcode`\ =10\vrule height .9ex width .8ex depth -.1ex}}
\def\hybull{{\catcode`\ =10\vrule height .6ex width .8ex depth -.4ex}}

% Male and female symbols (poor).
\def\male{$\bigcirc^{\mkern-5.5mu\raise.5ex\hbox{$\nearrow$}}$}
\def\female{$\bigcirc\mkern-15.64mu\lower1.75ex\hbox{+}$}

\newcommand{\cent}{{\rm\rlap/c}}
