%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This is typebook.sty, a LaTeX2e style file to modify the book class
% for typesetting documentation transformed from DocBook XML by the
% docbook-latex XSLT stylesheet. It is used specifically for doing
% computing documentation about typographic systems like LaTeX.
%
% GNU Copyleft 1998-2005 Silmaril Consultants
%
% Peter Flynn <peter@silmaril.ie>
%
% You modify use and distribute this file in any way you wish except
% by charging for it or claiming that you wrote it. This header and
% identity must be preserved on all copies and derivatives.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FONTS
%
% Supply default names for the fonts because my own font definitions
% store their own names in these macros, and if you're processing
% this yourself (ie without my fonts) I still want the references to
% font names in the session on fonts to work. These are defaults.
%
\newcommand{\rmfontfamilyname}{Computer Modern Roman}
\newcommand{\sffontfamilyname}{Computer Modern Sans-Serif}
\newcommand{\ttfontfamilyname}{Computer Modern Typewriter}
%
% I invoke pslatex before my private fonts so I get the benefit of the
% narrowed Courier, which is useful. If anyone knows the location of a
% free Prestige Elite (Type 1) font, which was a freebie give-away on
% some DTP CD-ROM in the late 1990s, of which I have lost my copy, I
% would be very grateful to know.
%
\usepackage{pslatex,arrus,geom415,lgoth}
% ald721 and hum521 are Bitstream's Aldine (Bembo) and Humanist (Gill)
%\usepackage{pslatex,ald721,hum521}
% carmina and inc901 are also Bitstream for Carmina and Antique Olive
%\usepackage{pslatex,carmina,inc901}
% The pslatex default is narrowed Courier, so say so:
\renewcommand{\ttfontfamilyname}{Courier Narrow}
% These redefinitions seem to be needed (is ly1enc.def faulty?)
% Comment them out if you're not using LY1 (my Bitstream fonts need them)
\renewcommand{\ae}{\char'032}
\renewcommand{\AE}{\char'035}
\renewcommand{\o}{\char'034}
\renewcommand{\O}{\char'037}
% As you won't have any of them, comment out those lines and UNcomment 
% the following FOUR lines to get Times and Helvetica (\snore):
%\renewcommand{\rmfontfamilyname}{Times}
%\renewcommand{\sffontfamilyname}{Helvetica}
%\renewcommand{\ttfontfamilyname}{Courier}
%\usepackage{pslatex}
% Alternatively you could UNcomment these four lines instead:
%\renewcommand{\rmfontfamilyname}{Palatino}
%\renewcommand{\sffontfamilyname}{Avant Garde}
%\renewcommand{\ttfontfamilyname}{Courier}
%\usepackage{pslatex,palatino,avant}
%
% And yes, I do know that pslatex is obsolete and deprecated, and when
% someone gets around to updating it to do things the way they say
% they ought to be, I'll get around to updating this style file.
%
% Anyway, in this case (for TUGboat), I fiddled with the .fd file for
% Avant Garde and decreased the size to 90% because it's a font with
% a very large x-height and it needs to be smaller to sort with
% Palatino. Ditto with the special narrow Courier in pslatex.sty: I
% grew that to 110% because it was too short. Hence there are copies
% of ot1ppl.fd and pslatex.sty in the source directory which should
% override the ones in a normal LaTeX distribution.
%
% Sample line for the font sampler to make it easier to type
%
\newcommand{\alphabet}[2][OT1]{%
	\fontencoding{#1}\fontfamily{#2}\selectfont
	The quick brown fox jumps over the lazy dog}
\newcommand{\shortalphabet}[2][OT1]{%
	\fontencoding{#1}\fontfamily{#2}\selectfont
	The quick brown fox jumps over the}
\newcommand{\dalphabet}[2][OT1]{% German
	\fontencoding{#1}\fontfamily{#2}\selectfont
	Fuch\char'215, Du hast die Gan\char'215\ gestohlen, gib sie wieder her!}
\DeclareFontFamily{OT1}{pntt}{}
\DeclareFontShape{OT1}{pntt}{m}{n}{<-> pntt9}{}
%
% Allow access to ``Light'' variant of the font if available
%
\ifx\@undefined\lite\newcommand{\lite}{\fontseries{l}\selectfont}\fi
%
% Shorthand macros for Metafont, fpTeX, and teTeX, which add
% themselves to the index
%
\newcommand{\mf}{%
	{\fontencoding{U}\fontfamily{zmf}\selectfont METAFONT}%
	\index{metafont@{\fontencoding{U}\fontfamily{zmf}%
		\selectfont METAFONT}}}
\newcommand{\fp}{fp\kern-1pt\TeX\index{fptex@fp\kern-1pt\TeX}}
\newcommand{\te}{te\kern-1pt\TeX\index{tetex@te\kern-1pt\TeX}}
\def\LyX{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\spacefactor1000}%
%
% We work in ISO 8859-1 here
%
\usepackage[latin1]{inputenc}
%
% Define the Euro more carefully than TS1 does
%
\newcommand{\euro}{{\fontencoding{TS1}\fontfamily{cmr}\selectfont\texteuro}}
%
% Smaller paragraph indentation
\setlength{\parindent}{1em}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PACKAGES
%
% You MUST have these installed for this stuff to work. You can get
% all of them from CTAN like I did. 
%
% The page geometry is no longer designed for A4. This layout is more
% like an airport book :-)
%
\usepackage{pstricks,pst-char,pst-grad,pstcol,mdwlist,soul,ragged2e}
\usepackage{graphicx,url,fancybox,fancyvrb,fancyhdr,array,paralist}
% was 396bp wide, 696bp high. This made the text area the same
% as the TUGboat version, for pageno compatibility, but I don't
% actually see the need for this, given the ToC and Index. See
% tugbook.sty for the other layout. The one commented out below
% was the original.
\usepackage[a4paper,twoside,textwidth=29pc,left=28mm,marginpar=36pt,
  textheight=43pc,headsep=30pt,headheight=20pt]{geometry}
% 28mm margin is 1" (25.4mm) plus 2.5mm (roughly) as this appeared to
% be the offset required to make the pages back up correctly on the
% LTU HPLJ4600dn two-sided printer I used (via Acrobat Reader with
% auto-shrink and auto-expand turned OFF).
%
%\usepackage[left=1in,textwidth=14cm,marginpar=3cm,marginparsep=6mm,
%            textheight=22.5cm,headheight=15pt]{geometry}%tugboat!
%\newcommand{\infofont}[1]{\textsf{\footnotesize#1}}
%\usepackage[cam,font=\footnotesize]{crop}
%
\widowpenalty=10000
\clubpenalty=10000
\parfillskip = .75\hsize plus .06\hsize minus .75\hsize
\renewcommand{\topfraction}{.9}
\renewcommand{\bottomfraction}{.75}
\renewcommand{\floatpagefraction}{.85}
\renewcommand{\textfraction}{.15}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}
\spaceskip=.5ex plus1ex 
\usepackage{multicol,color,bbding,marvosym,textcomp,type1cm,makeidx}
\usepackage[normalem]{ulem}
%
% Bibliography macros to customise jurabib
%
\usepackage[bibformat=numbered]{jurabib}
\newcommand{\titleof}[1]{\emph{\citefield{title}{#1}}}
\newcommand{\authorof}[1]{\citefield{juraauthor}{#1}}
\newcommand{\dateof}[1]{\citefield{year}{#1}}
\newcommand{\citeauthoryear}[1]{\authorof{#1} \dateof{#1}}
\newcommand{\citeauthortitleyear}[1]{\authorof{#1}, \titleof{#1} \dateof{#1}}
\newcommand{\titlecite}[1]{\titleof{#1}\footnote{\citeauthoryear{#1}}}
%
\DeclareRobustCommand{\LaTeX}{L\kern-.3em%was -.42em
        {\sbox\z@ T%
         \vbox to1.05\ht\z@{\hbox{\check@mathfonts
                              \fontsize\sf@size\z@
                              \math@fontsfalse\selectfont
                              A}%
                        \vss}%
        }%
        \kern-.15em%was -.2em
        \TeX}
\DeclareRobustCommand{\sfLaTeX}{L\kern-.24em%
        {\sbox\z@ T%
         \vbox to1.05\ht\z@{\hbox{\check@mathfonts
                              \fontsize\sf@size\z@
                              \math@fontsfalse\selectfont
                              A}%
                        \vss}%
        }%
        \kern-.15em%
        \TeX}
\newcommand{\BibTeX}{\textsc{Bib}\kern-.08em\TeX}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% COLOUR
%
% Pretty colours for the title page and examples. 
% Can't use {named} model because pdflatex can't use it (yet?).
%
\definecolor{midblue}{rgb}{0.145,0.490,0.882} 
\definecolor{myred}{cmyk}{0,1,0.13,0}
\definecolor{grey}{gray}{0.7}
\definecolor{litegrey}{gray}{0.75}
\definecolor{olivegreen}{cmyk}{0.95,0,0.95,0.75}%was {0.64,0,0.95,0.40}
\definecolor{greenyellow}{cmyk}{0.15,0,0.69,0}
\definecolor{pinegreen}{cmyk}{0.92,0,0.59,0.25}
\definecolor{bluegreen}{cmyk}{0.85,0,0.33,0}
\definecolor{lavender}{cmyk}{0,0.48,0,0}
\definecolor{orange}{cmyk}{0,.32,.52,0}%Apricot
\definecolor{purple}{cmyk}{0.40,0.80,0.20,0}%DarkOrchid
% RubineRed is #FF00CC
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% INDEXING
%
\makeindex
%
% Shorthands to allow auto-indexing of keywords
%
\newcommand{\Linux}{Linux\index{Linux}}
\newcommand{\CTAN}{CTAN\index{CTAN}}
\newcommand{\product}[2][\relax]{%
	\mbox{\textit{#2}}%
	\if#1\relax\index{#2@\string\textit{#2}}\else
		\index{#1@\string\textit{#2}}\fi
	\if#1\relax\index{Products@\string\textbf{Products}!#2@\string\textit{#2}}\else
		\index{Products@\string\textbf{Products}!#1@\string\textit{#2}}\fi}
\newcommand{\package}[1]{%
	\mbox{\textsf{\lite #1}}%
	\index{#1@\string\textsf{\lite #1}}%
	\index{Packages@\string\textbf{Packages}!#1@\string\textsf{\lite #1}}}
\newcommand{\env}[1]{%
	\mbox{\textsf{\bfseries#1}}%
	\index{#1@\string\textsf{\lite #1}}%
	\index{Environments@\string\textbf{Environments}!#1@\string\textsf{\bfseries #1}}}
\def\getfirst#1#2\sentinel{\def\firsttok{#1}}
\newcommand{\opt}[1]{\def\firsttok{\relax}%
	\mbox{\textsf{\itshape\lite#1}}%
	\getfirst#1\sentinel
	\ifthenelse{\equal{\firsttok}{1}}
	{\index{1@\string\textsf{\string\itshape\lite #1}}%
	\index{Options@\string\textbf{Options}!1@\string\textsf{\string\itshape\lite #1}}}
	{\index{#1@\string\textsf{\string\itshape\lite #1}}%
	\index{Options@\string\textbf{Options}!#1@\string\textsf{\string\itshape\lite #1}}}}
\newcommand{\counter}[1]{%
	\mbox{\texttt{\itshape #1}}%
	\index{#1@\string\texttt{\itshape #1}}%
	\index{Counters@\string\textbf{Counters}!#1@\string\texttt{\itshape #1}}}
\newcommand{\length}[1]{%
	\mbox{\texttt{\char'134 #1}}%
	\index{#1@\string\texttt{\char'134 #1}}%
	\index{Lengths@\string\textbf{Lengths (Dimensions)}!#1@\string\texttt{\char'134 #1}}}
\newcommand{\command}[1]{%
	\mbox{\texttt{\bfseries\char'134 #1}}%
	\index{#1@\string\texttt{\bfseries\char'134 #1}}%
	\index{Commands@\string\textbf{Commands}!#1@\string\texttt{\bfseries\char'134 #1}}}
\newcommand{\indexcommand}[1]{% like \command but silent (no output)
	\index{#1@\string\texttt{\bfseries\char'134 #1}}%
	\index{Control@\string\textbf{Control sequences}!#1@\string\texttt{\bfseries\char'134 #1}}}
\newcommand{\keyword}[1]{%
	\mbox{\textbf{#1}}%
	\index{#1|textbf}}
% Person-indexing is documented in the text. Read it!
\def\reindex #1 #2\sentinel{\index{#2, #1}}
\newcommand{\person}[1]{#1\reindex #1\sentinel}
\newcommand{\nameindex}[1]{#1\splitname #1\sentinel}
\def\splitname #1 #2\sentinel{\index{#2, #1}}
%
% Some hyphenation oddities :-)  US hyphenation-by-syllable really sucks.
%
\hyphenation{mark-up pro-fes-sio-nal Micro-soft Win-dows Linux
docu-ment docu-ments tabu-lar cross-referencing helico-pter
Post-Script si-mi-lar ad-ministra-tive Ameri-can dri-ver tech-ni-cal
style-sheets chan-ges analy-sis ge-ne-ric found-ries re-po-si-tory
mathe-mati-cal Gra-ti-fi-ca-tion } 
%
% Protected BackSlash needed to allow raggedright etc in tables
%
\newcommand{\pbs}[1]{\let\tmp\\#1\let\\\tmp}
%
% Number sections down to subsubsection level, 
% but show down only as far as subsections in the Table of Contents
%
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{2}
\newcounter{hold} % for tracking continued procedure steps
\def\gfdl{\renewcommand{\thesubsection}{\thechapter.\arabic{subsection}}\let\section\subsection\setcounter{subsection}{-1}\multicolsep=1.5pc}
%
% Adjust paragraph spacing, but only for use after the ToC
%
\newcommand{\textparsettings}{%
	\setlength{\parskip}{1em plus3pt minus3pt}%
	\setlength{\parindent}{0pt}%
}
%
% Reduce space above and below lists
%
\setlength{\partopsep}{0pt}
\renewcommand{\labelitemi}{\raisebox{-2pt}{\footnotesize\SquareShadowTopLeft}}
%\PencilRight\NibRight\HandRight
%
% Now the hairy stuff, redefining LaTeX internals
%
% Redefine the layout for new chapter pages
%
\@openrighttrue
%\renewcommand{\chaptername}{Session}%sessions no longer
% First, make sure we get genuinely empty pages when the chapter
% starts after a right-hand chapter-finish.
\def\cleardoublepage{%
  \clearpage
  \if@twoside 
    \ifodd
      \c@page
    \else
      \hbox{}\thispagestyle{empty}\newpage
      \if@twocolumn
        \hbox{}\newpage
      \fi
    \fi
  \fi}
% Save blank pages in TUGboat, use \clearpage
\renewcommand\chapter{\cleardoublepage
	\thispagestyle{plain}%
	\global\@topnum\z@
	\@afterindentfalse
	\secdef\@chapter\@schapter}
% Make sure \chapter causes a plain page
%\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
%	\thispagestyle{plain}%
%	\global\@topnum\z@
%	\@afterindentfalse
%	\secdef\@chapter\@schapter}
% Redesign the opening of a chapter
%\gdef\thechapter{\Roman{chapter}}
\def\@makechapterhead#1{\leavevmode\vbox to200pt{%
  \begin{tabular}{@{}>{\pbs{\raggedright}}p{\textwidth}@{}}\color{midblue}%
    \sffamily\itshape\fontsize{200}{0}\selectfont\thechapter\\[-94pt]
    \sffamily\Huge\spaceskip=.5ex #1
  \end{tabular}}\par}
%\def\@makechapterhead#1{%
%	\vspace*{1cm}%
%	{\parindent \z@ \RaggedRight \normalfont
%		\ifnum \c@secnumdepth >\m@ne
%			\Large{\scshape \@chapapp
%				\ifthenelse{\equal{\@chapapp}{\chaptername}}%
%					{\space \Roman{chapter}}%
%					{\space \thechapter}}%
%			\par\nobreak
%			\vspace*{.5in}
%		\fi
%		\interlinepenalty\@M
%		\sffamily\Huge #1\par\nobreak
%		\vspace*{36pt}}}
%
% Fix appendix switch
%
\renewcommand\appendix{\par
  \setcounter{chapter}{0}%
  \setcounter{section}{0}%
  \gdef\@chapapp{\appendixname}%
  \gdef\thechapter{\@Alph\c@chapter}}
%
% Make a new format for the title page
%
\renewcommand{\maketitle}{%
%  \smash{\raisebox{2in}{\vbox to0pt{\centering\includegraphics{doi}}}}%
  \moveright-5cm\hbox{\smash{\raisebox{2.5in}{\vbox to0pt{\rotatebox{270}{\includegraphics{doi}}}}}}%
  \begingroup
  \thispagestyle{empty}%
  \setlength{\parindent}{0pt}%
    \begin{minipage}{32pc}
      \begin{flushright}
	{\fontsize{42}{0}\selectfont\bfseries\@newtitle}
	\par\vspace*{1cm}
	    {\spaceskip=.75ex\Large
	      \sffamily\bfseries\color{purple}
%\pscharpath[fillstyle=solid,linecolor=black,fillcolor=orange,linewidth=.1pt]{%
	      \@subtitle%}%
	      \par}
	    \vspace*{2cm}
	    {\large\sffamily\textit{\@author}\par}
     \end{flushright}
   \end{minipage}
   \vfill
%\normalsize{\sffamily\textit{\@date}}
  \par\endgroup\cleardoublepage\thispagestyle{empty}%
  \null\vfill\begingroup\spaceskip=.75ex\centering
  \Huge\@title\par\vfill
  \LARGE\@subtitle\par\endgroup\vfill
  \clearpage\null\vfill{\small\noindent\ignorespaces\@legal}\thispagestyle{empty}
  \clearpage\pagenumbering{roman}}
%
% Extra macros to make the title page work
%
\def\@subtitle{\relax}
\newcommand{\subtitle}[1]{\gdef\@subtitle{#1}}
\def\@legal{\relax}
\long\def\legal#1{\gdef\@legal{#1}}
\newcommand{\csfontsetup}{%
  \color{litegrey}\fontsize{40}{40}\selectfont\lite}
\newcommand{\csbtitle}{\csfontsetup\texttt{\char'134 title\char'173}}
\newcommand{\csetitle}{\csfontsetup\texttt{\char'175}}
\newcommand{\realcsetitle}{\csfontsetup\ \
  \smash{\raisebox{-4pt}{\texttt{\char'175}}}}
\newlength{\midword}\settowidth{\midword}{\normalfont
  \fontsize{42}{0}\selectfont\bfseries format}
\def\@newtitle{%
  \pscharpath[linestyle=none,fillstyle=gradient,gradbegin=magenta,
    gradend=green,gradmidpoint=1]{%
    \begin{tabular}{@{}r@{}p{\midword}<{\vrule depth10pt width0pt}@{}l@{}}%
      \phantom{\csbtitle}&format&\phantom{ion\csetitle}\\
      \phantom{\csbtitle}&format&\phantom{ion\csetitle}\\
      \phantom{\csbtitle}&format&\phantom{ting}
    \end{tabular}\par}\\[-2pt]
    \begin{tabular}{@{}r@{}>{\leavevmode}p{\midword}@{}l@{}}%
      \hspace*{17pt}\csbtitle&\color{olivegreen}format&\color{olivegreen}ting\\[-2pt]
      \color{olivegreen}in\hspace*{1pt}&\color{olivegreen}format&
      \color{olivegreen}ion\csetitle
    \end{tabular}\\[4pt]
  \pscharpath[linestyle=none,fillstyle=gradient,gradbegin=cyan,
    gradend=green,gradmidpoint=0]{%
    \begin{tabular}{@{}r@{}p{\midword}<{\vrule depth10pt width0pt}@{}l@{}}%
      \phantom{\csbtitle}&format\\
      \phantom{in}&format&\phantom{ion\csetitle}\\
      &format&\phantom{ting}
    \end{tabular}}}
\def\@oldtitle{%
	\pscharpath[linestyle=none,fillstyle=gradient,gradbegin=white,
	gradend=black,gradmidpoint=.5]{\begin{tabular}{@{}r@{}l@{}}
		&format\\&format\\&format\\
		&\color{blue}format\rlap{ting}\\
		\color{blue}in&\color{blue}format\rlap{ion}\\
		&format\\&format\\&format\end{tabular}}}
%
% Make section/subsection/subsubsection use sans-serif type
% and less space before and after the heading line
%
\renewcommand\section{\@startsection{section}{1}{\z@}%
			{-3ex \@plus -1.5ex \@minus -1ex}%
			{2ex \@plus.2ex}%
			{\normalfont\Large\bfseries\sffamily\RaggedRight}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
			{-2ex\@plus -1ex \@minus -.5ex}%
			{1.5ex \@plus .2ex}%
			{\normalfont\large\bfseries\sffamily\RaggedRight}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
			{-1.5ex\@plus -1ex \@minus -.5ex}%
			{1ex \@plus .2ex}%
			{\normalfont\normalsize\bfseries\sffamily\RaggedRight}}
%
% Define some running heads
%
\pagestyle{fancy}
\fancyhead{}
\renewcommand{\headrulewidth}{.1pt}
\fancyhead[RO]{\scriptsize\sffamily\lite\rightmark}
\fancyhead[LE]{\scriptsize\sffamily\lite\itshape\leftmark}
\fancyfoot[C]{}
\fancyfoot[LE,RO]{\setlength{\fboxsep}{2pt}\ovalbox{\scriptsize\sffamily\thepage}}
\fancyfoot[LO,RE]{\scriptsize\sffamily\lite\itshape\@title}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[R]{\setlength{\fboxsep}{2pt}\ovalbox{\scriptsize\sffamily\thepage}}
\fancyfoot[L]{\scriptsize\sffamily\lite\@title}
\renewcommand{\headrulewidth}{0pt}}
%
% Give access to marginal notes (geometry controls the margins)
%
\newcommand{\marginal}[1]{\marginpar{\tiny\raggedright#1}}
%
% Make a `keycap' icon
%
\newlength{\keywidth}
\newlength{\keyheight}
\newlength{\keydepth}
\newcommand{\key}[1]{\begingroup\footnotesize
	\setlength{\fboxsep}{1pt}%
	\settowidth{\keywidth}{\sffamily#1}%
	\ifdim\keywidth<1em\setlength{\keywidth}{1em}\fi
	\settoheight{\keyheight}{Xfl)}%
	\settodepth{\keydepth}{)yj}%
	\raisebox{1pt}{\ovalbox{\hbox to\keywidth{\hss\sffamily#1\hss
		\vrule height\keyheight depth\keydepth width0pt}}}%
	\endgroup}%
% Also make a typewriter-font version
\newcommand{\ttkey}[1]{\begingroup\footnotesize
	\setlength{\fboxsep}{1pt}%
	\settowidth{\keywidth}{\ttfamily#1}%
	\ifdim\keywidth<1em\setlength{\keywidth}{1em}\fi
	\settoheight{\keyheight}{Xfl)}%
	\settodepth{\keydepth}{)yj}%
	\raisebox{1pt}{\ovalbox{\hbox to\keywidth{\hss\ttfamily#1\hss
		\vrule height\keyheight depth\keydepth width0pt}}}%
	\endgroup}%
% And a button-bar icon version
\newcommand{\icon}[1]{\begingroup\footnotesize
	\setlength{\fboxsep}{1pt}%
	\settowidth{\keywidth}{\sffamily#1}%
	\ifdim\keywidth<1em\setlength{\keywidth}{1em}\fi
	\settoheight{\keyheight}{Xfl)}%
	\settodepth{\keydepth}{)yj}%
	\raisebox{1pt}{\fbox{\hbox to\keywidth{\hss\sffamily#1\hss
		\vrule height\keyheight depth\keydepth width0pt}}}%
	\endgroup}%
% And some utilities to allow description of menu options
\newcommand{\with}{--}
\newcommand{\fby}{~~}
%
% Make slanted fractions for use outside math mode
%
\newcommand{\Frac}[2]{%
	\raisebox{.5ex}{\scriptsize#1}\kern-.1em/%
	\kern-.1em\raisebox{-.333ex}{\scriptsize#2}\thinspace}
%
% Redefine some front matter appearances
%
\renewenvironment{abstract}{%
      \clearpage
      \section*{\abstractname}%
      \@mkboth{\MakeUppercase\@title}{\MakeUppercase\abstractname}}%
     {\par\vfil\null}
% Add a new description for named prelims
\newcommand{\prelim}[1]{\clearpage
    \section*{#1}\addcontentsline{toc}{section}{#1}%
    \@mkboth{\MakeUppercase\@title}{\MakeUppercase{#1}}
    \thispagestyle{plain}}
%
\renewcommand\tableofcontents{\clearpage
    \section*{\contentsname}%
    \@mkboth{\MakeUppercase\@title}{\MakeUppercase\contentsname}%
    \thispagestyle{plain}\begingroup
    \fontsize{9}{11.5}\selectfont\@starttoc{toc}\par\endgroup}
% appendix numbers were getting too close to the text
\renewcommand*\l@section{\@dottedtocline{1}{2em}{2.5em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{4em}{3.5em}}
% New list of exercises
\newcommand\listofexercises{%
    \section*{Exercises}%
      \@mkboth{CONTENTS}{CONTENTS}%
    \begingroup
    \fontsize{9}{11.5}\selectfont\@starttoc{loe}\par\endgroup}
\renewcommand{\listoftables}{%
    \section*{\listtablename}%
      \@mkboth{CONTENTS}{CONTENTS}%
    \begingroup
    \fontsize{9}{11.5}\selectfont\@starttoc{lot}\par\endgroup}
%
\renewenvironment{thebibliography}[1]
     {\clearpage\section*{\bibname}%
        \@mkboth{\MakeUppercase\@title}{\MakeUppercase\bibname}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy\RaggedRight
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
%
\renewenvironment{theindex}
               {\@mkboth{\MakeUppercase\@title}%
                        {\MakeUppercase\indexname}%
		\begin{multicols}{2}%
                \parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem}
               {\end{multicols}\clearpage}
%
% Fix floating footnotes (c.t.t. 22 Oct 2001 Donald Arseneau)
% Message-ID: <yfi1yjvxnzw.fsf@triumf.ca>, thanks Don.
%
\def\footnoterule{\kern-3\p@
	\nobreak \vfill
	\hrule \@width 2in \kern 2.6\p@} % the \hrule is .4pt high
%
\newcommand{\tablefootnote}[1]{\raisebox{.667ex}{\kern.1em\scriptsize\ref{#1}}}
%
% Add a fake linebreak for illustration
%
\newcommand{\fakebreak}{\linebreak}
%
% Some artefacts of transformation from XML
%
\newcommand{\mdash}{~--- }
\newcommand{\ndash}{--}
\newcommand{\amp}{\&}
\newcommand{\dito}{\raisebox{-.5ex}{''}}
\newcommand{\guiicon}[1]{{\setlength{\fboxsep}{1pt}%
	\colorbox{grey}{\color{white}\footnotesize\textsf{#1}}}}
\newcommand{\UParrow}{\ifmmode\uparrow\else$\uparrow$\fi}
\newcommand{\DOWNarrow}{\ifmmode\downarrow\else$\downarrow$\fi}
%
% Change the name of the Abstract
%
\renewcommand{\abstractname}{Summary}
%
% Sidebars, Exercises and Warnings
\newenvironment{sidebar}{%
	\begin{Sbox}\begin{minipage}{.85\textwidth}}%
	{\end{minipage}\end{Sbox}%
		\begin{center}\setlength{\fboxsep}{6pt}%
		\shadowbox{\TheSbox}\end{center}}
\newenvironment{warning}{%
	\begin{Sbox}\begin{minipage}{.85\textwidth}\sffamily\lite\small\RaggedRight}%
	{\end{minipage}\end{Sbox}%
		\begin{center}\setlength{\fboxsep}{6pt}%
		\colorbox{litegrey}{\TheSbox}\end{center}}
% fancybox's thin double lines are too thin for Adobe Acrobat to
% render properly.
\def\@doublebox#1{%
  \begingroup
    \setbox\@fancybox\hbox{{#1}}%
    \fboxrule=.2pt% was .75\fboxrule
    \setbox\@fancybox\hbox{\fbox{\box\@fancybox}}%
    \fboxrule=2\fboxrule
    \fboxsep=\fboxrule
    \advance\fboxsep 2pt% instead of .5pt
    \fbox{\box\@fancybox}%
  \endgroup}
\newcounter{exercise}
\newenvironment{exercise}{\refstepcounter{exercise}%
	\begin{Sbox}\begin{minipage}{.85\textwidth}\sffamily\RaggedRight
		\setlength{\parindent}{1em}%
		\noindent{\scshape\small Exercise \theexercise}}%
	{\end{minipage}\end{Sbox}%
		\begin{center}\setlength{\fboxsep}{6pt}%
		  \doublebox{\TheSbox}%
	        \end{center}}
\newenvironment{example}{%
	\begin{Sbox}\begin{minipage}{.85\textwidth}}%
	{\end{minipage}\end{Sbox}%
		\begin{center}\setlength{\fboxsep}{6pt}%
		\fbox{\TheSbox}\end{center}}
\newlength{\boxedwidth}
\newcommand{\resetboxedwidth}[1]{%
	\setlength{\boxedwidth}{\columnwidth}
	\addtolength{\boxedwidth}{-2\fboxsep}
	\addtolength{\boxedwidth}{-2\fboxrule}
	\addtolength{\boxedwidth}{#1}
        \addtolength{\boxedwidth}{-\leftmargin}}
\newenvironment{sourcecode}[1][0pt]{%
	\setlength{\fboxsep}{1pc}\resetboxedwidth{#1}%
	\begin{Sbox}
	\begin{minipage}{\boxedwidth}\setlength{\spaceskip}{.375em}}
	{\end{minipage}
	\end{Sbox}
	\begin{center}
	\cornersize*{1pc}\ovalbox{\TheSbox}
	\end{center}}
\newenvironment{shiftedsourcecode}[1][0pt]{%
	\setlength{\fboxsep}{1pc}\resetboxedwidth{-#1}%
	\begin{Sbox}
	\begin{minipage}{\boxedwidth}\settowidth{\spaceskip}{\texttt{M}}}
	{\end{minipage}
	\end{Sbox}
	\begin{flushleft}
	\cornersize*{1pc}\moveleft\leftmargin\vbox{\ovalbox{\TheSbox}}
	\end{flushleft}}
%
\index{options|see{Class Options}}
\newcommand{\emstrut}{\vrule height1em width0pt}
\newcommand{\linestrut}{\vrule height.9em depth.1em width0pt}
%
% Macro for menus
%
\newlength{\menuwidth}
\newlength{\menuitemwidth}
\newlength{\menusubitemwidth}
\newlength{\menumaxwidth}
\newlength{\menumaxheight}
\newlength{\menumaxdepth}
\newlength{\menuheight}
\newcommand{\menu}[1]{\setlength{\fboxsep}{1pt}\setlength{\fboxrule}{.1pt}%
	\settowidth{\menuwidth}{\bfseries #1}%
%	\addtolength{\menuwidth}{2ex}%
	\raisebox{\fboxsep}{\fbox{\hbox to\menuwidth{\scriptsize\sffamily\bfseries
			\vphantom{()}#1\hss\tiny\HandLeftUp}}}}
\newcommand{\menuitem}[2]{\@ifnextchar[{\@menusubitem{#1}{#2}}{\@menuitem{#1}{#2}}}
\newcommand{\@menuitem}[2]{%
	\settoheight{\menumaxheight}{AhMI(l'}%
	\settodepth{\menumaxdepth}{jJ,)yp}%
	{\scriptsize\sffamily
	\setlength{\fboxsep}{1pt}\setlength{\fboxrule}{.1pt}%
	\settowidth{\menuwidth}{\bfseries #1}%
	\settoheight{\menuheight}{\bfseries\vphantom{()}#1}%
	\addtolength{\menumaxheight}{-\menuheight}%
	\settowidth{\menuitemwidth}{#2}%
	\settodepth{\menumaxdepth}{\vphantom{(yjp)}#2}%
	\ifdim\menuitemwidth>\menuwidth
		\menumaxwidth=\menuitemwidth
	\else
		\menumaxwidth=\menuwidth
	\fi
	\addtolength{\menumaxwidth}{2em}%
	\raisebox{\menumaxheight}{\colorbox{black}{\hbox 
	    to\menumaxwidth{\color{white}\bfseries\vphantom{(yjp)}#1\hss}}}%
	\kern-\menumaxwidth\kern\menuwidth
	\raisebox{-\menumaxdepth}{\fcolorbox{black}{white}{\hbox 
		to\menumaxwidth{\color{black}\vphantom{(yjp)}#2\hss\tiny\HandLeftUp}}}} }
\def\@menusubitem#1#2[#3]{%
	\settoheight{\menumaxheight}{AhMI(l'}%
	\settodepth{\menumaxdepth}{jJ,)yp}%
	{\scriptsize\sffamily
	\setlength{\fboxsep}{1pt}\setlength{\fboxrule}{.1pt}%
	\settowidth{\menuwidth}{\bfseries#1}%
	\settoheight{\menuheight}{\bfseries\vphantom{()}#1}%
	\addtolength{\menumaxheight}{-\menuheight}%
	\settowidth{\menuitemwidth}{#2}%
	\settowidth{\menusubitemwidth}{\itshape #3}%
	\settodepth{\menumaxdepth}{\itshape\vphantom{(yjp)}#3}%
	\ifdim\menuitemwidth>\menuwidth
		\ifdim\menusubitemwidth>\menuwidth
			\menumaxwidth=\menusubitemwidth
		\else
			\menumaxwidth=\menuitemwidth
		\fi
	\else
		\ifdim\menusubitemwidth>\menuwidth
			\menumaxwidth=\menusubitemwidth
		\else
			\menumaxwidth=\menuwidth
		\fi
	\fi
	\addtolength{\menumaxwidth}{2em}%
	\raisebox{\menumaxheight}{\fbox{\hbox to\menumaxwidth{\bfseries
			\vphantom{(yjp)}#1\hss}}}%
	\kern-\menumaxwidth\kern\menuwidth
	\raisebox{\fboxsep}{\fcolorbox{black}{white}{\hbox 
		to\menumaxwidth{\color{black}\vphantom{(yjp)}#2\hss}}}%
	\kern-\menumaxwidth\kern\menuitemwidth
	\raisebox{-\menumaxdepth}{\colorbox{black}{\hbox 
		to\menumaxwidth{\color{white}\itshape\vphantom{(yjp)}#3\hss
		\upshape\tiny\HandLeftUp}}}}}
\newcommand{\smiley}{%
	\smash{\raisebox{.75ex}{%
		\setlength{\tabcolsep}{0pt}\footnotesize
		\begin{tabular}c.\thinspace.\\[-1ex]%
			\texttt{\char'015}\\[-1.1em]%
			$\smile$\\[-1.5em]\large$\bigcirc$\end{tabular}}}}
%
% Macros for testing references
%\usepackage{ifthen}
\newcommand{\testpage}[2][here]{%
  \ifthenelse{\equal{\pageref{#2}}{\thepage}}{#1}{on p.\thinspace\pageref{#2}}
}
%
% Set a date and version number for this stylesheet
%
\newcounter{version}
\newcounter{issue}
% History
% v0.1 developed 1999 but never released
% v1.* rewritten 2000 as training document but incomplete
% v2.1 completed December 2001, notified to c.t.t 2001-12-14
% v2.2 finished Yuletide 2001, only minor typos
% v2.3 converted from SGML to XML started
% v3.0 XML done, front redesigned, loads of changes suggested by readers
\setcounter{version}{3}
\setcounter{issue}{4}
%\newcommand{\releasedate}{November 2001}%2.1
%\newcommand{\releasedate}{December 2001}%2.2
%\newcommand{\releasedate}{March 2002}%2.3
%\newcommand{\releasedate}{January 2003}%3.0
\newcommand{\releasedate}{November 2003}%3.4
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%