%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tvz-hax.sty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
%%  These are some lousy hacks for typesetting the code
%%  and User's Guide  in the Seminar and PSTricks packages.
%% 
%%  Guaranteed to make these documents impossible for anyone else to modify.
%%
%%  Tim Van Zandt tvz@Princeton.EDU
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%% 2up printing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% The files are meant to be printed 2-up. There are two ways
%% to do this. One is to run the dvi file through Rokicki's dvidvi,
%% as in
%%        dvidvi '2:0,1(5.5in,0in)' infile outfile
%%
%% The other is to include the following lines *after* resolving all
%% cross references and getting the index right:
%%
%% \special{landscape} % This works with dvips.
%% \twoup
%% \pagesepwidth .5pt  % This causes problems on some printers.
%%
%% If you want to print the document as a booklet, for stapling in the
%% middle or cutting in half and putting in a small binder, use instead
%% 
%%        dvidvi '4:-1,2(5.5in,0in)' infile outfileA
%%        dvidvi '4:-3,0(5.5in,0in)' infile outfileB
%%
%% Then print outfileA.dvi, put the printed sheets back in upside down
%% and print outfileB.dvi
%%
%% You can also get a booklet by including the following line after
%% resolving all cross-references:
%%
%% \twoupbooklet
%%
%% Print the first half of the pages in landscape mode, turn them over,
%% and print the other half. This is likely to exceed the capacity of
%% your implementation of TeX.
%%
\def\twoup{\nofiles
  \input 2up
  \pageseplength 6.5in
  \pagesepoffset 1in
  \target{\magstep0}{11in}{8.5in}
  \source{\magstep0}{5.5in}{8.5in}
  \targetlayout{twosided}}
\def\twoupbooklet{\nofiles
  \input 2up
  \pageseplength 6.5in
  \pagesepoffset 1in
  \target{\magstep0}{11in}{8.5in}
  \source{\magstep0}{5.5in}{8.5in}
  \targetlayout{twosided,booklet}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% %%%%%%%%%%%%%%%%% hyphenation fix   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  The next few lines are for those with a new TeX 3.0 to ensure
%%  that hyphenation etc. is done correctly.
\ifx \lefthyphenmin\undefined \else
  \lefthyphenmin=2 \righthyphenmin=3 \errorcontextlines=1
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%% LOGOS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% These are from tugboat.com:
%%
\newcount\TestCount
\def\AmS{\protect\pAmS}
\def\LaTeX{\protect\pLaTeX}
\def\pAmS{{\the\textfont2
        A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
\def\pLaTeX{\TestCount=\the\fam \leavevmode L\raise.42ex
  \hbox{$\fam\TestCount\scriptstyle\kern-.3em A$}\kern-.15em\TeX}
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%% TITLES AND SECTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Smaller fonts and less space in the title:
\def\@maketitle{\newpage
 \begin{center}
 {\Large\bf \@title \par} \vskip 1.2em {\lineskip .5em
 \begin{tabular}[t]{c}\@author 
 \end{tabular}\par} 
 \vskip .8em {\@date} \end{center}
 \par
 \vskip .5em} 
%%
%% Headings:
\def\ps@docheadings{%
  \let\@mkboth\markboth
  \def\@oddfoot{}\def\@evenfoot{}%
  \def\@evenhead{\rm \thepage\hfil {\sl \thetitle}}%
  \def\@oddhead{\hbox{}{\sl \rightmark} \hfil \rm\thepage}%
	\def\sectionmark##1{\markright {##1}}}%
\pagestyle{docheadings}
%%
%% Section lines use smaller font size.
\def\section{\@startsection{section}{1}{\z@}{-3ex plus -1ex
  minus -.2ex}{1.5ex plus .2ex}{\large\bf}}
\def\subsection{\@startsection{subsection}{2}{\z@}{-3ex plus -1ex
  minus -.2ex}{1.5ex plus .2ex}{\bf}}
\def\l@section#1#2{\addpenalty{\@secpenalty} \addvspace{0.5em plus 1pt}
  \@tempdima 1.5em \begingroup
  \parindent \z@ \rightskip \@pnumwidth 
  \parfillskip -\@pnumwidth 
  \bf \leavevmode \advance\leftskip\@tempdima \hskip -\leftskip
  #1\nobreak\hfil
  \nobreak\hbox to\@pnumwidth{\hss #2}\par
  \endgroup}
%%
\def\tableofcontents{%
  \clearpage
	\pagenumbering{roman}
  \thispagestyle{empty}
	\begin{center}\Large\bf Contents\end{center}
  \@starttoc{toc}
	\clearpage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%% dates %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This expands the date, as defined in \filedate.
\def\expanddate#1/#2/#3/{\number#3{} \month=#2 \ifcase\month\or
  January \or February \or March \or April \or May \or June \or
  July \or August \or September \or October \or November \or December \fi
  19#1}
\def\thefiledate{\expandafter\expanddate\filedate/}
\date{\thefiledate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%% code and examples %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% This is an environment for putting samples of code.
\def\Ex{%
  \list{}{}\item[]
	\leavevmode\hbox to \linewidth\bgroup
	  \def\arraystretch{1}\MacroFont
    \begin{tabular}{@{}l@{}}\ignorespaces}
\def\endEx{\end{tabular}\hfill\egroup\endlist}
%%
%%% Various things to make it easier to write code and examples:
\begingroup
  \catcode`\{=12 \catcode`\}=12
	\catcode`\(=1 \catcode`\)=2
	\catcode`\|=12
	\catcode`\+=0 \catcode`\\=12
	+gdef+@Backslash(\)           % \Backslash = character \
	+gdef+{({)                   % \{ = character {
	+gdef+}(})                   % \} = character }
	+gdef+|(|)                   % \| = character |
+endgroup
\def\Backslash{\protect\@Backslash}
\def\s#1{{\tt\string#1}}       % Writes string, in tt font.
\def\S#1{{\tt\{\s#1\}}}        % Writes string, in braces and tt font.
\def\m#1{{\rm\it #1}}          % For just putting things in italics (m="meta")
\def\M#1{{\tt\{}\m{#1}{\tt\}}} % Argument is in italic, enclosed in tt braces.
\def\t#1{{\tt}}                % For putting things in tt font.
\catcode`\"=13\def"{}          % Now we can write \LaTeX" without problem.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%% Page Parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Set page parameters for 2up printing.
%%
\onecolumn
\setlength{\parindent}{20pt}         % paragraph indent
\setlength{\parskip}{3pt plus 1pt minus 1pt}
\leftmargini 1.87em
\leftmarginii 1.6em
\leftmarginiii 1.4em
\leftmarginiv 1em
\leftmarginv .5em
\leftmarginvi .5em
\leftmargin\leftmargini
\setlength{\oddsidemargin}{-.5in}      % was 42pt
\setlength{\evensidemargin}{-.25in}     % was 84pt
\setlength{\topmargin}{-32pt}       % was 0pt
\setlength{\headheight}{12pt}        % height of running head, unchanged
\setlength{\headsep}{20pt}           % distance between header and text
\setlength{\marginparwidth}{0pt}    % 
\setlength{\marginparsep}{0pt}      %
\setlength{\textheight}{6.5in}        % height of text on page
\setlength{\textwidth}{4.25in}         % wide enough for 65 characters of code
\def\arraystretch{1.2}
\def\@listI{\leftmargin\leftmargini \parsep\parskip
\topsep 2pt plus 1pt minus 1pt
\itemsep 4.5pt plus 2pt minus 1pt}
\partopsep 1pt plus .5pt
\let\@listi\@listI
\@listi 
\sloppy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%% Special hacks for User's Guides %%%%%%%%%%%%%%%%%%%%%
%% 
%% Appendices
\def\appendix{\clearpage
  \section*{\Large\bf Appendices}
  \setcounter{section}{0}
  \setcounter{subsection}{0}
  \def\thesection{\Alph{section}}}
%%
%% Listing questions
\newcounter{faq}[section]
\def\thefaq{\arabic{faq}}
\let\l@faq\@gobbletwo
\def\faq{\@startsection{faq}{2}{\z@}{3.25ex plus 
  1ex minus .2ex}{1.5ex plus .2ex}{\normalsize\sf}}
\def\faqmark#1{}
%%
%% Listing errors
\def\error{\vskip 2ex\noindent}
%%
%% Change the font for float captions to \sf:
\long\def\@makecaption#1#2{
 \vskip 10pt 
 \setbox\@tempboxa\hbox{\sf #1: #2}
 \ifdim \wd\@tempboxa >\hsize{\sf #1: #2}\par \else
   \hbox to\hsize{\hfil\box\@tempboxa\hfil} 
 \fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%% Special indexing for User's Guides %%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Like \SpecialEnvIndex, but for options:
\def\SpecialOptionIndex#1{\@bsphack
  \index{#1\actualchar{\tt #1} (option)\encapchar usage}%
  \index{options:\levelchar{\tt #1}\encapchar usage}\@esphack}
%%
%% Change font for index page numbers
\def\usage#1{{\bf #1}}
%%
%% Some special commands for special indexing:
%% E.g., \SUI is like \SpecialUsageIndex, but also adds label.
%%       \sui is like \SUI, but also prints argument in tt font.
\def\SpecialLabel#1#2+{\label{+#2}}
\def\SUI#1{\SpecialUsageIndex{#1}\expandafter\SpecialLabel\string#1+}
\def\sui#1{{\tt\string#1}\SUI{#1}}
\def\SOI#1{\SpecialOptionIndex{#1}\label{#1}}
\def\soi#1{{\tt #1}\SOI{#1}}
\def\SEI#1{\SpecialEnvIndex{#1}\label{#1}}
\def\sei#1{{\tt #1}\SEI{#1}}
%%
%% This is for listing commands in a description environment.
\def\xitem#1{\item[\tt\string#1]\SUI{#1}}
%%
%% User Guides might need to input .aux files for code:
\def\codeaux#1{%
  \begingroup
	  \@floatplacement\@dblfloatplacement
    \makeatletter\let\@writefile\@gobbletwo
    \@input{#1-code.aux}
	\endgroup}
%%
%% User's guide and documented code have different index prologue.
\def\PrintUserIndex{%
  \def\index@prologue{%
    \section*{Index}\markboth{INDEX}{INDEX}%
    \addcontentsline{toc}{section}{Index}}%
	\PrintIndex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%% Special hacks for documented code %%%%%%%%%%%%%%%%%%%%%%%%
%%
%% For labelling the lines of code. There is probably a better way of doing
%% this built in to doc.sty:
\def\codelabel{\@ifnextchar *%
  {\count@=\c@CodelineNo\@codelabel}%
  {\count@=\c@CodelineNo\advance\count@ by 1\@codelabel*}}
\def\@codelabel*#1{\@bsphack\if@filesw
  {\let\thepage\relax\def\protect{\noexpand\noexpand\noexpand}%
    \xdef\@gtempa{\write\@auxout{\string
    \newlabel{#1}{{\number\count@}{\thepage}}}}}
  \@gtempa\if@nobreak \ifvmode\nobreak\fi\fi\fi\@esphack}
%%
%% Customize index prologue:
\def\index@prologue{\section*{Index}\markboth{INDEX}{INDEX}%
  \addcontentsline{toc}{section}{Index}%
 The {\bf bold} numbers denote the pages where the entries are defined,
  and all other numbers indicate the {\em lines of code} where
  the entries are used.}
%% Main definitions are set in bold rather than underlined.
\def\main#1{{\bf #1}}
%%
%% Definitions in code are indexed by page number, but other occurences
%% are indexed by the line of code.
\def\SpecialMainIndex#1{\@bsphack\index{\expandafter\@gobble\string#1%
    \actualchar\string\verb\quotechar*\verbatimchar
    \string#1\verbatimchar
    \encapchar main}\@esphack}
%%
%% A change to the macro environment; prints macro names within the margins
%% of the text, instead of as marginal notes. Use one \macro command,
%% with comma separated macro names.
\newif\iffirst@macroname
\newif\ifnestedmacro
\def\macro{%
  \ifnum\macro@level=\z@
    \def\next{\MakePrivateLetters \m@cro@}%
  \else
    \def\next{\@latexerr{Nested \string\begin{macro}}\@eha
    \endgroup\end{macro}\macro@level=\z@\begin{macro}}
  \fi
  \next}
\def\m@cro@#1{%
  \first@macronametrue
  \m@@cro@@#1,\@nil,}
\def\m@@cro@@#1,{%
  \def\@tempa{#1}\def\@tempb{\@nil}%
  \ifx\@tempa\@tempb
    \let\next\finishm@@cro@@
  \else
    {\advance\c@CodelineNo\@ne\SpecialMainIndex{#1}\nobreak}%
    \DoNotIndex{#1}%
    \iffirst@macroname
      \edef\saved@macronames{\string#1}%
      \first@macronamefalse
    \else
      \def\comma{\noexpand\comma}%
      \edef\saved@macronames{\saved@macronames\comma\string#1}%
    \fi
    \let\next\m@@cro@@
  \fi
  \next}
\def\finishm@@cro@@{%
  \vskip\MacroTopsep
  \advance\macro@level\@ne
  \def\comma{{\rm, }}%
  {\noindent\tt\bf\raggedright\saved@macronames\par}%
  \ignorespaces}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%% DoNot Index %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
\DoNotIndex{\ ,\!,\[,\\,\],\^,\`,\{,\},\~}
\DoNotIndex{\@warning,\active}
\DoNotIndex{\begingroup,\catcode,\char,\csname,\def,\do}
\DoNotIndex{\docdate,\dospecials,\edef,\else,\endcsname,\endgroup}
\DoNotIndex{\expandafter,\fi,\filedate,\fileversion}
\DoNotIndex{\gdef,\if,\ifcat}
\DoNotIndex{\ifx,\immediate,\lccode,\let}
\DoNotIndex{\lowercase,\next,\noexpand}
\DoNotIndex{\relax,\space,\the}
\DoNotIndex{\toks@,\typeout,\write}
\DoNotIndex{\@M,\@arabic,\@author,\@auxout,\@bsphack,\@car,\@date}
\DoNotIndex{\@dblarg,\@dblfloat,\@eha,\@empty,\@esphack,\@evenfoot}
\DoNotIndex{\@evenhead,\@float,\@gobble,\@gobbletwo,\@gtempa,\@ifnextchar}
\DoNotIndex{\@ifundefined,\@ixpt,\@latexerr,\@listI,\@listi,\@listii}
\DoNotIndex{\@listiii,\@listiv,\@listv,\@listvi,\@makefnmark,\@mkboth}
\DoNotIndex{\@namedef,\@nameuse,\@mne,\@nil,\@normalsize,\@oddfoot}
\DoNotIndex{\@oddhead,\@tempa,\@tempb,\@tempc,\@tempd}
\DoNotIndex{\@tempdima,\@testfalse,\@testtrue,\test@member}
\DoNotIndex{\@thanks,\@thefnmark,\@title}
\DoNotIndex{\@topnum,\@viiipt,\@viipt,\@vipt,\@vpt,\@xiipt}
\DoNotIndex{\@xipt,\@xpt,\@xivpt,\@xviipt,\@xxpt,\@xxvpt}
\DoNotIndex{\addcontentsline}
\DoNotIndex{\advance,\aftergroup,\baselinestretch,\begin}
\DoNotIndex{\belowdisplayshortskip,\belowdisplayskip,\bf,\bgroup}
\DoNotIndex{\box,\c@@page,\c@page,\c@secnumdepth,\clearpage,\columnsep}
\DoNotIndex{\columnwidth,\copy,\dimen@,\dimen@i,\dimen@ii,\divide}
\DoNotIndex{\dp,\ds@article,\ds@notes,\ds@notesonly}
\DoNotIndex{\ds@slidesonly,\egrou,\end,\end@dblfoloat,\end@float}
\DoNotIndex{\endinput,\fnsymbol,\footheight,\footnotesep,\footskip}
\DoNotIndex{\global,\globaldefs,\hbox,\headheight,\headsep,\hfil}
\DoNotIndex{\hrule,\hskip,\hss,\ht,\Huge,\huge}
\DoNotIndex{\if@filesw,\if@test,\if@twocolumn,\if@twoside}
\DoNotIndex{\ifcase,\ifdim,\ifvmode,\ignorespaces}
\DoNotIndex{\input,\interlinepenalty,\itemsep,\ixpt,\label}
\DoNotIndex{\labelsep,\labelwidth,\LARGE,\large,\Large}
\DoNotIndex{\leavevmode,\leftmargin,\leftmargini,\leftmarginii}
\DoNotIndex{\leftmarginiii,\leftmarginiv,\leftmarginv}
\DoNotIndex{\leftmarginvi,\leftmark,\leftskip,\lineskip}
\DoNotIndex{\magstep,\marginparsep,\marginparwidth,\markboth}
\DoNotIndex{\markright,\medbreak,\multiply,\newbox,\newcount}
\DoNotIndex{\newcounter,\newdimen,\newif,\newlabel,\newpage}
\DoNotIndex{\newtoks,\nobreak,\nointerlineskip,\normallineskip}
\DoNotIndex{\normalsize,\null,\number,\numberline,\oddsidemargin}
\DoNotIndex{\offinterlineskip,\or,\par,\parbox,\parskip,\partopsep}
\DoNotIndex{\prevdepth,\protect,\ref,\refstepcounter,\rightmrk}
\DoNotIndex{\rm,\scriptsize,\section,\sectionmark,\setbox,\setcounter}
\DoNotIndex{\sl,\small,\stepcounter,\string,\textheight,\textwidth}
\DoNotIndex{\thefootnote,\thepage,\thesection,\thesubsection}
\DoNotIndex{\thispagestyle,\tiny,\topmargin,\topsep,\uppercase}
\DoNotIndex{\vbox,\vfill,\viiipt,\viipt,\vipt,\vpt,\vskip,\vss}
\DoNotIndex{\wd,\xcommentloaded@,\xdef,\xiipt,\xipt,\xivpt,\xpt}
\DoNotIndex{\xviipt,\xxpt,\xxvpt,\z@}
\DoNotIndex{\abovedisplayskip,\abovedisplayshortskip,\@currentlabel}
\DoNotIndex{\@dottedtocline,\@ne\@setsize,\@starttoc,\@tempboxa,\@}
\DoNotIndex{\arraystretch,\centerline,\egroup,\end@dblfloat}
\DoNotIndex{\evensidemargin,\footnotesize,\ifnum,\parindent,\parsep}
\DoNotIndex{\rightmark,\@afterindenttrue,\@ne,\if@specialpage.\long}
\DoNotIndex{\fboxrule,\fboxsep,\@for,\vfil}
\DoNotIndex{\@@fortmp,\@@tempa,\@@tempb,\@ehd,\@for,\@fortmp,\@m}
\DoNotIndex{\@mparswitchfalse,\@mparswitchtrue,\@nnil,\@spaces}
\DoNotIndex{\@specialstyle,\@temptokena,\@twosidefalse,\@twosidetrue}
\DoNotIndex{\@whilenum,\alph,\arabic,\count@,\errhelp,\errmessage}
\DoNotIndex{\fbox,\index,\minipage,\newcommand,\overfullrule}
\DoNotIndex{\pagestyle,\raggedright,\ref@stepcounter,renewcommand}
\DoNotIndex{\semcolor@loaded,today,\@tempcnta,\@tempcntb,\trivlist,\t,\p}
\DoNotIndex{\today,\item,\@colht,\@currenvir,\@thefoot,\@thehead}
\DoNotIndex{\@totalleftmargin,\allowbreak,\@captype,\@footnotetext}
\DoNotIndex{\@listdepth,\@minipagefalse,\@minipagetrue,\@mpfn,\@mpfootins}
\DoNotIndex{\endtrivlist,\everypar,\hsize,\ifvoid,\lastskip}
\DoNotIndex{\linewidth,\skip,\thempfn,\thempfootnote,\topskip,\unvbox}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%% Odds and Ends %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setcounter{IndexColumns}{2}               % two column index
\renewcommand{\theCodelineNo}{{\rm\tiny\arabic{CodelineNo}}}
\DisableCrossrefs                         %Cross references not permitted
%\EnableCrossrefs
%\RecordChanges                           % Do not print changes
\CodelineIndex                            % Code lines numbered
\let\ifprintindex\iftrue
\newcommand{\SelfDocumenting}{\newpage\parindent\z@}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\endinput
