%%% File: mfpdoc.sty
%%% A part of mfpic 0.9 2006/05/26
%%%
\ProvidesPackage{mfpdoc}[2006/05/26 v0.9 macros for mfpic documentation]

\newif\if@chapters
\@chaptersfalse
\DeclareOption{chapters}{\@chapterstrue}

\newif\if@stupidlogos
\@stupidlogostrue
\DeclareOption{nologos}{\@stupidlogosfalse}
\ProcessOptions

\IfFileExists{ifpdf.sty}{\RequirePackage{ifpdf}}
  {\csname newif\expandafter\endcsname\csname ifpdf\endcsname \pdffalse
   \ifx\pdfoutput\undefined
   \else\ifx\pdfoutput\relax
   \else\ifnum0=\pdfoutput
   \else
     \pdftrue
   \fi\fi\fi}

\newcommand\mfpversion{0.9}
\newcommand\mfpdate   {2006/05/26}

%% Text size:

\textwidth 5.5 in
\textheight7.5 in
\oddsidemargin  .5in
\evensidemargin\oddsidemargin
\topmargin .75in
  \advance\topmargin-\headheight
  \advance\topmargin-\headsep

\ifpdf
  \pdfpageheight\paperheight
  \pdfpagewidth\paperwidth
  \def\mfpHyOpts{%
    pdftex,colorlinks,pdfpagemode=none,%
    pdfstartview={XYZ null null null},%
    plainpages=false,hypertexnames=true}
  \def\mfpHyDisable{%
    \def\cs##1{\otherbackslash##1}\let\opt\@firstofone\let\prog\@firstofone}
\else
  \ifx\mfpdvipdfm\UndEfInEd
    \special{papersize=\the\paperwidth,\the\paperheight}
  \else
    \special{pdf: pagesize width \the\paperwidth\space height \the\paperheight}
  \fi
\fi
\renewcommand\section{\@startsection{section}{1}{\z@}%
                                   {-2.4ex \@plus -.5ex \@minus -.1ex}%
                                   {1.0ex \@plus.1ex}%
                                   {\normalfont\large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-1.8ex\@plus -.4ex \@minus -.1ex}%
                                     {.75ex \@plus .1ex}%
                                     {\normalfont\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-1.5ex\@plus -.3ex \@minus -.1ex}%
                                     {.5ex \@plus .1ex}%
                                     {\normalfont\scshape\raggedright}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                     {-1ex\@plus -.2ex \@minus -.1ex}%
                                     {.4ex \@plus .1ex}%
                                     {\normalfont\itshape\raggedright}}

\if@chapters
  \let\chapter\section
  \let\section\subsection
  \let\subsection\subsubsection
  \let\subsubsection\paragraph
\fi

\def\mfpicversiontext{\prog{Mfpic} version:  \mfpversion.}

\def\@maketitle{%
  \newpage\vspace*{-2\baselineskip}
  \ifx\mfpicversiontext\relax
  \else
    {\let\p@footnote\relax\let\@thempfn\relax
    \footnotetext{\mfpicversiontext}}%
  \fi
  {\centering%
    {\Large \@title \par}%
    \vskip 1em%
    {\large \lineskip .5em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
    \vskip .7em%
    {\normalsize \@date}%
    \par
  }%
  \vskip 1em\relax}

\def\mfpindexheading{}
\def\mfpindexpagemarks{}

\def\@listi{\leftmargin\leftmargini
  \parsep \z@ \@plus\p@ \@minus\z@
  \topsep 1ex \@plus.2ex \@minus 1ex
  \itemsep\parsep}
\let\@listI\@listi \@listi
\renewcommand\labelitemi{\normalfont\bfseries \textendash}
\renewcommand\labelitemii{\textasteriskcentered}
\renewcommand\labelitemiii{\textperiodcentered}
\leftmargini 1.5\parindent

\renewenvironment{theindex}
               {%
                \@restonecoltrue
                \columnseprule \z@
                \columnsep 35\p@
                \twocolumn[\mfpindexheading%
                \vspace{1ex}]%
                \mfpindexpagemarks
                \parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem
                }
               {\clearpage}


%% Because \pageref doesn't link to the actual page:
\newcommand\pagelabel{\ifpdf \phantomsection \fi\label}

%% Displays %%%%%%%%%%%
%% command descriptions:
\newenvironment{cd}
  {\par\addvspace{1.75ex plus .3ex minus .1ex}
   \parindent0pt
   \vbox\bgroup\hsize\textwidth
     \def\ {\leavevmode\null\quad}% small space at beginning of line
  }
  {\unskip\strut\egroup\@ignoretrue
   \aftergroup\@afterindenttrue\aftergroup\@afterheading
   \nobreak\vskip.75ex plus .3ex minus .1ex}

%% examples:
\newenvironment{ex}
 {\par\addvspace{1ex plus.2ex minus.1ex}%
   \parindent0pt
   \vbox\bgroup\hsize\textwidth
     \leftskip\leftmargini
     \def\ {\leavevmode\null\quad}}
 {\unskip \strut \egroup \vskip 1ex plus.2ex minus.1ex
  \@ignoretrue\@endpetrue}

%% verbatim:
\RequirePackage{verbatim}
\def\verbatim@processline{\hspace{\leftmargini}\the\verbatim@line\par}

%% other:
\newenvironment{display}{\list{}{}\item[]}{\endlist}
%% end displays %%%%%%%

%% Logos %%%%%%%%%%%%%%
\if@stupidlogos
  \def\TeX{T\kern-.1667em\lower.4ex\hbox{E}\kern-.125emX}
  \def\pdfTeX{pdf\kern.04em\TeX}
  \def\pdfLaTeX{pdf\kern.06em\LaTeX}
  \def\ConTeXt{Con\kern-.16em \TeX \kern-0.06em t}
  \def\eTeX{e\kern-.10em \TeX}
  \def\CMcal{\fontencoding{OMS}\fontfamily{cmsy}\selectfont}
  \def\AmSTeX{{\CMcal A\kern-.1667em\lower.5ex\hbox{M}\kern-.125em S}-\TeX}
%  \def\PiCTeX{P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC\kern-.11em\TeX}
  \def\PiCTeX{P\kern-.06em\lower.4ex\hbox{I}\kern-.075emC\kern-.06em\TeX}
\else
  \def\TeX     {\textsc{TeX}}
  \def\LaTeX   {\textsc{LaTeX}}
  \def\pdfTeX  {\textsc{pdfTeX}}
  \def\pdfLaTeX{\textsc{pdfLaTeX}}
  \def\ConTeXt {\textsc{ConTeXt}}
  \def\eTeX    {\textsc{eTeX}}
  \def\AmSTeX  {\textsc{$AMS$-TeX}}
  \def\PiCTeX  {\textsc{PiCTeX}}
\fi
%% end Logos %%%%%%%%%%

\hyphenation{meta-font meta-post Post-Script Ghost-script}

%% Special words %%%%%%
\def\MF{\prog{metafont}}
\def\CMF{\prog{Metafont}}
\def\MP{\prog{metapost}}
\def\CMP{\prog{Metapost}}
\def\PS{\prog{PostScript}}
\def\GS{\prog{Ghostscript}}
\def\EPS{\prog{EPS}\null}
\def\mfp{\prog{mfpic}}
\def\Mfp{\prog{Mfpic}}
\def\grafbase{\prog{grafbase}}
\def\Grafbase{\prog{Grafbase}}

%% font commands
\def\mytt#1{\relax
    \ifmmode \mathtt{#1}
    \else {\upshape\ttfamily#1}\fi}
\def\mfc{\begingroup\ttfamily\catcode`\_=12 \grabit}
\def\grabit#1{#1\endgroup}
\def\_{{\upshape\ttfamily\char`\_}}
\def\prog#1{{\mdseries\scshape#1}}      % programs, packages
\let\file\mytt                          % filenames
\def\opt#1{{\upshape\sffamily#1}}       % LaTeX option names
\let\gbc  \mfc                          % grafbase code
\let\env  \file                         % LaTeX environment names
\let\email\file
\let\mail \file
\let\dim  \file                         % TeX and Metafont dimensions

\edef\otherbackslash{\expandafter\@gobble\string\\}
\DeclareRobustCommand\cs[1]{\mytt{\char`\\#1}}
\def\bbsl{\cs{}\cs{}}% prints "\\"
\DeclareRobustCommand\meta[1]{%
     \ensuremath{\langle\mbox{\rmfamily\itshape#1\/}\rangle}}
\providecommand\marg[1]{\mytt{\char`\{#1\char`\}}}
\providecommand\oarg[1]{\mytt{[#1]}}
\providecommand\parg[1]{\mytt{(#1)}}

\def\ps@mfpdoc{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@oddhead{\small{\scshape\rightmark}\hfil\thepage}%
      \let\@evenhead\@oddhead
      \let\@mkboth\markboth
    \def\sectionmark##1{\thispagestyle{plain}}
    \def\subsectionmark##1{%
      \markright {\thesection\quad##1}}%
    \def\subsubsectionmark##1{}}

\if@chapters
\renewcommand\tableofcontents{\pagenumbering{roman}%
    \chapter*{\contentsname
        \@mkboth{\scshape\contentsname}{\scshape\contentsname}}%
    \@starttoc{toc}\clearpage\pagenumbering{arabic}}
\fi

%% figures:
\@fptop=-\@fpsep
\@addtoreset{figure}{section}

%% misc:
\def\tallstrut{\vbox to 10pt{}}
\def\deepstrut{\vtop to 5pt{}}

\frenchspacing
\endinput
