% ttquot.sty
%
% This style is intended to make it easier to write text on technical
% subjects, so that the text is readable even when it is TeX source.
%
% One of the most common problems is switching conveniently into the
% typewriter font and back. This style file makes the ordinary double
% quotation mark (") serve this function.
%
% It also makes underscore characters (_) switch into emphasized mode
% and back, unless inside " quotes or in math mode. This makes ordinary
% variable names easier to type in typewriter font, and makes emphasized
% mode obey a common ASCII text convention.
%
% Finally, the asterisk character may be used as a substitute for the
% \item macro, except inside quotes.
%
% The following potentially useful macros are defined:
%
% \ttquot@activate       Turn on ttquot processing. On by default.
% \ttquot@deactivate     Turn off ttquot processing.
% \ttquot@ttmode         Expand to 1 if the text is inside quotation marks,
%                        0 otherwise.
% \ttquot@mark           Always represents the plain character (")
% \ttquot@ttfont         The commands that are emitted in the environment that
%                        is bracketed by the quotation marks. By default, \tt
% \ttquot@us             Represents the original meaning of (_)
% \ttquot@emfont         The commands that are emitted in the _ environment.
%                        By default, \em
% \ttquot@emmode         Expand to 1 if the text is inside underscores,
%                        0 otherwise.
% \ttquot@ast            The plain asterisk character
%
% This style file is maintained by Andrew Myers (andru@lcs.mit.edu)
%
% Change log:
%  Fri Nov  6 14:35:49 EST 1992         Added this documentation        andru
%  Tue Nov 10 23:05:44 EST 1992         Changed underscore to do \em    andru
%  Wed Nov 11 17:00:00 EST 1992         Fixed various bugs, added *     andru
%  Tue Feb 16 23:48:20 EST 1993         Fixed "number" bug, added \*    andru
%  Tue Mar 23 13:39:39 EST 1993         Got rid of a little cruft       andru
%  Tue Apr 26 16:07:18 EDT 1994         Made _ work in other fonts      andru
%  Wed Oct 12 17:39:49 EDT 1994         Made activate/deactivate work   andru
%  Wed Feb 08 15:00:31 EST 1995         Made * work again               andru
%  Wed Jun  7 18:08:23 EDT 1995         Got rid of *			andru
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Save original definitions, install activate/deactivate
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\ttquot@mark="% Catch original definition of quotation mark
\let\ttquot@us=_% Catch original definition of underscore
% \let\ttquot@ast=*% Catch original definition of asterisk

\catcode`\"=\active%
\catcode`\_=\active%
% \catcode`\*=\active%


\gdef\ttquot@deactivate{%
\def"{\ttquot@mark}%
\def_{\ttquot@us}%
% \def*{\ttquot@ast}%
\catcode`\"=12%
\catcode`\_=8%
% \catcode`\*=12%
}

% \ttquot@activate %%% Turn it on!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Change " to place its contents inside {\ttquot@ttfont ... }
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gdef\ttquot@ttmode{0}
\gdef\ttquot@ttfont{\tt}
\gdef\ttquot@newmark{%
\ifnum\ttquot@ttmode=0 %
\begingroup\ttquot@ttfont\gdef\ttquot@ttmode{1}%
\def_{\_}%
% \catcode`\*=12\relax%
\else\endgroup\gdef\ttquot@ttmode{0}%
% \catcode`\*=\active\relax%
\fi%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Change _ to place its contents inside {\ttquot@emfont ... }
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gdef\ttquot@emmode{0}
\gdef\ttquot@emfont{\em}
\gdef\ttquot@newus{%
\ifmmode%
\ttquot@us%
\else
\ttquot@myus%
\fi%
}
\gdef\ttquot@myus{%
\ifnum\ttquot@emmode=0 %
\begingroup\ttquot@emfont\gdef\ttquot@emmode{1}%
\else\endgroup\gdef\ttquot@emmode{0}\fi%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Change LaTeX's verbatim mode to use \ttquot@ttfont
% instead of \tt; also, do right thing with _
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\@verbatim{\trivlist \item[]\if@minipage\else\vskip\parskip\fi
\leftskip\@totalleftmargin\rightskip\z@
\parindent\z@\parfillskip\@flushglue\parskip\z@
\@tempswafalse \def\par{\if@tempswa\hbox{}\fi\@tempswatrue\@@par}
\obeylines \ttquot@ttfont
\@noligs \let\do\@makeother \dospecials
\catcode`\_=13%
\def_{\_}
\catcode``=13%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Change * to emit an \item
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \gdef\ttquot@newast{\protect\item}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Add ", * to specials list so verbatim modes zap them out
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\ttquot@oldspecials=\dospecials
% \def\dospecials{\ttquot@oldspecials\do\"\do\*}
\def\dospecials{\ttquot@oldspecials\do\"}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Make \* do what * used to
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \gdef\*{\ttquot@ast}


\gdef\ttquot@activate{%
\def"{\ttquot@newmark}%
\def_{\ttquot@newus}%
% \def*{\ttquot@newast}%
}

\ttquot@activate
