\newcommand{\progfont}{\ttfamily\mdseries\frenchspacing}

\newcommand{\itbox}[1]{%
   \ifmmode
     \mathchoice{\mbox{%\small
                       \progfont % \typeout{Font family: \f@family} 
                          #1}}%
                {\mbox{%\small
                       \progfont #1}}%
                {\mbox{\scriptsize\progfont #1}}%
                {\mbox{\tiny\progfont #1}}%
   \else
     \mbox{%\small
           \progfont #1}%
   \fi}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Program examples

% (hacked from Lamport's alltt style option)
% Defines the `progeg' environment, which is like the `verbatim'
% environment except that `\', `\{', and `\}' have their usual meanings.
% Thus, other commands and environments can appear within an `alltt'
% environment.  Here are some things you may want to do in an `alltt'
% environment:
% 
% * Change fonts--e.g., by typing `{\em emphasized text\/}'.
% 
% * Insert text from a file foo.tex by typing `input{foo}'.  Beware that
%   each <return> stars a new line, so if foo.tex ends with a <return>
%   you can wind up with an extra blank line if you're not careful.
% 
% * Insert a math formula.  Note that `$' just produces a dollar sign,
%   so you'll have to type `\(...\)' or `\[...\]'.  Also, `^' and `_'
%   just produce their characters; use `\sp' or `\sb' for super- and
%   subscripts, as in `\(x\sp{2}\)'.
\def\progegmarker{}
\def\docspecials{\do\ \do\$\do\&%
  \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~}
\def\progeg{\trivlist 
\parindent\progegindent\itemindent=\parindent
\item[] % \if@minipage\else\vskip\parskip\fi
\leftskip\@totalleftmargin\rightskip\z@
\parfillskip\@flushglue\parskip\z@
\@@par
\@tempswafalse \def\par{\if@tempswa\hbox{}\@@par\else\@tempswatrue\fi}
\obeylines \small\progfont %
\makebox[0cm][r]{\progegmarker\ }%
\catcode``=13 \@noligs \let\do\@makeother \docspecials
 \frenchspacing\@vobeyspaces \catcode``=12}

\def\endprogeg{\endtrivlist}

\def\progegindent{10pt}

\def\progegsubscr#1{$_#1$}

% -------------------------------------------------------------------------
% Examples

% \newcommand{\typecheckeroutputmarker}{%
%   \ensuremath{\scriptstyle \blacktriangleright}}
\newcommand{\typecheckeroutputmarker}{%
  \raisebox{.3ex}{\hbox{\ensuremath{\scriptstyle \blacktriangleright}}}}

\newcommand{\runeg}[1]{\input{tex/#1.tex}
                       \vspace*{-.4in}
                       {\def\progegmarker{\typecheckeroutputmarker}%
                        \input{tex/#1.out.tex}}%
                       %\medskip
                       }
\newcommand{\showeg}[1]{\input{tex/#1.tex}}
\newlength{\beforeoutputspace}
\setlength{\beforeoutputspace}{-.1in}
\newcommand{\showout}[1]{%
  {\ifdim \lastskip >\z@ 
     \vspace*{\beforeoutputspace}%
   \fi
%      \unskip
   \def\progegmarker{\typecheckeroutputmarker}%
   \input{tex/#1.out.tex}%\medskip
   }}
