% guaspi.sty -- Macros for -gua\spi text.  OK with LaTeX, probably AMSTeX too.

\parskip=\baselineskip \divide\parskip by 2 
	\advance\parskip by 0pt plus 4pt minus 2pt
\let\guafont=\sl	% The font used in the \gua environment

% Special symbols -- these are for use outside \gua
\def\qh{\hbox{`-'}}     % Quoted hyphen
\def\!{$\backslash$}	% Backslash
\catcode`\|=\active%
\def|{$\vert$}		% Vertical bar
\catcode`\^=\active	% Wedge (caret) is printing.  Use \sp for superscript.
\def\caret{${}\sp\wedge$}    % Caret without kerns for slanted type
\newbox\tonewedge \setbox\tonewedge=\hbox{\guafont\/}
    \setbox\tonewedge=\hbox{\kern\wd\tonewedge\caret\kern-\wd\tonewedge}
\def^{\hskip0pt\copy\tonewedge}	% This caret is kerned over for slanted type. 
\newdimen\SEkern \SEkern=0.16em
\def\dotSE{.\kern\SEkern.\kern\SEkern\@.\space}

% Environment for running -gua\spi text.  It's necessary to suppress line
% breaks after a hyphen (tone symbol). 

\newbox\emgbox
\def\guaemg#1{\setbox\emgbox=\hbox{\strut #1}\hbox{\vtop{\copy\emgbox%
\vskip-0.5ex\hrule height0.25pt width\wd\emgbox}}}
\newbox\ghyphbox \setbox\ghyphbox=\hbox{\guafont -}
\def\guahyph{\discretionary{}{\copy\ghyphbox}{\copy\ghyphbox}}
\newbox\ehyphbox \setbox\ehyphbox=\hbox{-}
\def\englhyph{\discretionary{\copy\ehyphbox}{}{\copy\ehyphbox}}
\newbox\emdashbox \setbox\emdashbox=\hbox{---}  %No ligature with active hyphen
\def\emdash{\copy\emdashbox}
\let\=\-  %Since \- cannot be recognized with active hyphen

{\catcode`\-=\active%
\global\def\gua#1{%
{\guafont \hyphenchar\font=128%
\catcode`\-=\active%
\let-=\guahyph%
\let\emg=\guaemg%
#1}}
}

\def\qgua#1{\gua{``#1''\/}}             % Quoted gua\spi word
\def\guaspi{\gua{gua!spi}}              %The name of gua\spi
\def\Guaspi{\gua{Gua!spi}}              %The name of gua\spi capitalized
\def\trw-#1,#2,{``\gua{#1}-\hskip0pt#2''}	%A word with its translation

\def\emg#1{{\em #1\/}}			%A word in italics (underline in \gua)
\def\betw#1{$\langle$#1$\rangle$}       %A phrase in angle brackets < >
\def\hfilbreak{\hfil\penalty800\hfilneg}  %Allow break at awkward place
\def\afilbreak{\vfil\penalty400\vfilneg}  %Similar for vertical break
\def\vabreak{\noalign{\afilbreak}}	%Grudging break in halign

% Macros for alignments and paragraphs
\newif\ifphalign \phalignfalse
\def\phalign{\ifphalign\message{Wrongly nested phalign}\fi\phaligntrue
\begingroup\vskip\parskip\afilbreak
\everycr={\noalign{\penalty800}}\halign}
\def\endphalign{\endgroup\ifphalign\else\message{Extra endphalign}\fi
	\phalignfalse\vfil\penalty300\vfilneg}
\def\shalign{\vskip\parskip\halign}	%halign with parskip before
\def\vhalign#1{\vskip\parskip\vbox{\halign{#1}}}	%halign in a vbox
\def\littlepar#1#2{\vtop{\hsize=#1\noindent%
\tolerance=1000\finalhyphendemerits=500\adjdemerits=500\doublehyphendemerits=500%
\strut#2\strut\par}}

% 2-column examples
\newdimen\exleft   \newdimen\exright    
\newdimen\exindent \exindent=0pt \newdimen\exskew \exskew=0pt
\def\exarith{\exleft=\hsize \advance\exleft by -\exindent
	 \advance\exleft by -1.5em \divide\exleft by 2 \exright=\exleft
	 \advance\exleft by \exskew\advance \exright by -\exskew}
{\catcode`\-=\active
% \newenvironment{exii}			%A sequence of examples
\global\def\exii{\vskip\parskip\exarith\relax\catcode`\-=\active\let-=\englhyph}%
\global\def\endexii{}%
}
\def\ex#1#2{\penalty800\hbox to \hsize{\hskip\exindent %One example in a list
	\littlepar\exleft{\gua{#1}}\hfil\littlepar\exright{#2}}}
\def\pli#1#2{\begin{exii}\ex{#1}{#2}\end{exii}}  %A single 2-column example
\def\exbox#1{\vskip\parskip\vbox{\exarith#1}}	%Examples in a vbox

% Format for word lists, like this: \begin{exii} \xitemarith{wordsize, 4em}
% The items are xitem{word}{description}<NL>{-gua!spi example}{translation}
\def\xitemarith#1{
    \exindent=#1 \exarith
    \newdimen\y \y=\hsize \advance\y by -\exindent
}
\def\xitem#1#2#3#4{\vbox{ 
	\hbox{\hbox to \exindent{\gua{#1}\hfil}\littlepar\y{#2}}\ex{#3}{#4}}}

% Page style "dict" (\pagestyle{dict}).  The explicit marking is necessary
% because LaTeX uses \firstmark whereas for the dictionary it is necessary
% to use \topmark.  Also, the page number is wanted and LaTeX gives no access
% to the foot line.  The text should put out \mark{{text of left head}{right
% head}}.  
\newtoks\chaptertok \chaptertok={}
\newtoks\sectiontok \sectiontok={}
\def\dictmark#1{\mark{{\sl#1\hfil\the\chaptertok}{\sl\the\sectiontok\hfil#1}}}
\def\ps@dict{					%Activation of dict pagestyle
\def\@mkboth##1##2{}
\def\@evenhead{\expandafter\@leftmark\topmark}%
\def\@evenfoot{\rm\hfil\thepage\hfil}%
\def\@oddhead{\expandafter\@rightmark\botmark}%
\let\@oddfoot=\@evenfoot%
\def\chaptermark##1{\chaptertok={##1}\sectiontok={}\dictmark{}}
\def\sectionmark##1{}
\def\subsectionmark##1{}
\def\subsubsectionmark##1{}
}


\def\guachapter{\@startsection {chapter}{1}{\z@}{-3.5ex plus -1ex minus 
    -.2ex}{2.3ex plus .2ex}{\huge\bf}}

\hyphenation{whe-ther re-fri-ger-a-tor me-ta-phor me-ta-phors
	au-stra-lo-pi-the-cus au-stra-lo-pi-the-cine
	ne-gate ne-gated ne-gat-ive sur-prise mod-al }

