%% memsty.sty    For memman
\ProvidesPackage{memsty}[2007/11/01 for memman]

%%\usepackage{layouts}[2001/04/29]
%%\usepackage{verbatim}
%%\usepackage{glossit}
\usepackage{etex}
\usepackage{layouts}[2001/04/29]
\usepackage{url}
\usepackage{fixltx2e}
\usepackage{alltt}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{latexsym}
\usepackage{memfonts}
\usepackage{pifont}
\usepackage[T1]{fontenc}

%%%%%%%%%%%%%%%%%%% kill scale change warning in layouts
\renewcommand*{\setlayoutscale}[1]{\setlength{\l@youtunitlength}{1pt}
  \l@youtunitlength= #1\l@youtunitlength
  \renewcommand*{\l@youtscale}{#1}}

%%%%%%%%%%%%%%%%%% plainmarkruled pagestyle
\makepagestyle{plainmarkruled}
  \makeheadrule{plainmarkruled}{\textwidth}{\normalrulethickness}
  \makeevenhead{plainmarkruled}{\scshape\leftmark}{}{}
  \makeoddhead{plainmarkruled}{}{}{\scshape\rightmark}
  \makeevenfoot{plainmarkruled}{\thepage}{}{}
  \makeoddfoot{plainmarkruled}{}{}{\thepage}
\makepsmarks{plainmarkruled}{\@ruledmarks}



%%%%%%%%%%%%%%%%%% index pagestyle
\makepagestyle{index}
  \makeheadrule{index}{\textwidth}{\normalrulethickness}
  \makeevenhead{index}{\rightmark}{}{\leftmark}
  \makeoddhead{index}{\rightmark}{}{\leftmark}
  \makeevenfoot{index}{\thepage}{}{}
  \makeoddfoot{index}{}{}{\thepage}

\makeindex
%\showindexmarktrue

%%%%%%%%%%%%%%%%%%%%%%% glossary
\makeglossary
\changeglossactual{?}
\changeglossnum{\@currentlabel} 
\changeglossnum{\thepage}
\changeglossnumformat{|hyperpage}
\renewcommand*{\glossaryname}{Command summary}
\renewcommand{\glossitem}[4]{%
  \sbox\@tempboxa{#1 \space #2 #3 #4}%
\par\hangindent 2em
  \ifdim\wd\@tempboxa<0.8\linewidth
    #1 \space #2 #3 \dotfill #4\relax
  \else
    #1 \dotfill #4\\
    #2 #3
  \fi}
\renewcommand*{\glossarymark}{\markboth{\glossaryname}{\glossaryname}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Short and long ToC

\newcommand*{\setupshorttoc}{%
  \renewcommand*{\contentsname}{Short contents}
  \let\oldchangetocdepth\changetocdepth
  \let\oldprecistoctext\precistoctext
  \renewcommand{\precistoctext}[1]{}
  \let\oldcftchapterfillnum\cftchapterfillnum
  \renewcommand*{\changetocdepth}[1]{}
  \setcounter{tocdepth}{0}% chapters
  \renewcommand*{\cftchapterfont}{\hfill\sffamily}
  \renewcommand*{\cftchapterpagefont}{\normalfont}
  \renewcommand*{\cftchapterleader}{ \textperiodcentered\space}
  \renewcommand*{\cftchapterafterpnum}{\cftparfillskip}
%%  \setpnumwidth{0em}
%%  \setpnumwidth{1.5em}
  \renewcommand*{\cftchapterfillnum}[1]{%
    {\cftchapterleader}\nobreak
    \hbox to 1.5em{\cftchapterpagefont ##1\hfil}\cftchapterafterpnum\par}
  \setrmarg{0.3\textwidth}
  \setlength{\unitlength}{\@tocrmarg}
  \addtolength{\unitlength}{1.5em}
  \let\oldcftpartformatpnum\cftpartformatpnum
  \renewcommand*{\cftpartformatpnum}[1]{%
    \hbox to\unitlength{{\cftpartpagefont ##1}}}
  \let\oldcftbookformatpnum\cftbookformatpnum
  \renewcommand*{\cftbookformatpnum}[1]{%
    \hbox to\unitlength{{\cftbookpagefont ##1}}}}

\newcommand*{\setupparasubsecs}{%
  \let\oldnumberline\numberline
  \renewcommand*{\cftsubsectionfont}{\itshape}
  \renewcommand*{\cftsubsectionpagefont}{\itshape}
  \renewcommand{\l@subsection}[2]{
    \ifnum\c@tocdepth > 1\relax
      \def\numberline####1{\textit{####1}~}%
      \leftskip=\cftsubsectionindent
      \rightskip=\@tocrmarg
%%      \advance\rightskip 0pt plus \hsize % uncomment this for raggedright
%%      \advance\rightskip 0pt plus 2em    % uncomment this for semi-ragged
      \parfillskip=\fill
      \ifhmode ,\ \else\noindent\fi
      \ignorespaces 
      {\cftsubsectionfont ##1}~{\cftsubsectionpagefont##2}%
       \let\numberline\oldnumberline\ignorespaces
    \fi}}

\AtEndDocument{\addtocontents{toc}{\par}}%%% OK

\newcommand*{\setupmaintoc}{%
  \renewcommand{\contentsname}{Contents}
  \let\changetocdepth\oldchangetocdepth
  \let\precistoctext\oldprecistoctext
  \let\cftchapterfillnum\oldcftchapterfillnum
  \addtodef{\cftchapterbreak}{\par}{}
  \renewcommand*{\cftchapterfont}{\normalfont\sffamily}
  \renewcommand*{\cftchapterleader}{\sffamily\cftdotfill{\cftchapterdotsep}}
  \renewcommand*{\cftchapterafterpnum}{}
  \renewcommand{\cftchapterbreak}{\par\addpenalty{-\@highpenalty}}
  \setpnumwidth{2.55em}
  \setrmarg{3.55em}
  \setcounter{tocdepth}{2}
  \let\cftpartformatpnum\oldcftpartformatpnum
  \addtodef{\cftpartbreak}{\par}{}
  \let\cftbookformatpnum\oldcftbookformatpnum
  \addtodef{\cftbookbreak}{\par}{}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ifpdf
  \usepackage[pdftex,
              plainpages=false,
              pdfpagelabels,
%%%  hyperfootnotes=false,
              bookmarksnumbered
             ]{hyperref} 
  \usepackage{graphicx}
  \DeclareGraphicsRule{*}{mps}{*}{}
\else
  \usepackage[plainpages=false,
              pdfpagelabels,
%%%  hyperfootnotes=false,
              bookmarksnumbered
             ]{hyperref} 
  \usepackage{graphicx}
  \DeclareGraphicsRule{*}{eps}{*}{}
\fi
%%%  \usepackage{memhfixc} %% now called by hyperref

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%% Logos
\providecommand*{\tx}{TeX}
\providecommand*{\txbook}{\tx book}
\providecommand*{\ltx}{La\tx}
\providecommand*{\ltxe}{\ltx2e}
\providecommand*{\pdfltx}{pdf\ltx}
\providecommand*{\ixpdfltx}{\index{pdfLaTeX?\pdfltx}}
\providecommand*{\pixpdfltx}{\pdfltx\ixpdfltx}   % print & index pdfLaTeX
\providecommand*{\etx}{\texttt{etex}}
\providecommand*{\ixetx}{\index{etex?\etx}}
\providecommand*{\pixetx}{\etx\ixetx}            % print & index etex
\providecommand*{\xetx}{Xe\tx}
\providecommand*{\ixxetx}{\index{XeTeX?\xetx}}
\providecommand*{\pixxetx}{\xetx\ixxetx}         % print & index XeTeX
\providecommand*{\TeXUG}{\tx{} Users Group}
\providecommand*{\tug}{\textsc{tug}}
\providecommand*{\ixtug}{\index{TUG?\tug}}
\providecommand*{\pixtug}{\tug\ixtug}            % print & index TUG

\providecommand*{\cTeXan}{Comprehensive \tx{} Archive Network}
\providecommand*{\ctan}{\textsc{ctan}}        % print CTAN
\providecommand*{\ixctan}{\index{CTAN?\ctan}} % index CTAN
\providecommand*{\pixctan}{\ctan\ixctan}      % print & index CTAN

\newcommand*{\ctt}{\textsc{ctt}}               % print CTT
\newcommand*{\ixctt}{\index{ctt?\ctt}}        % index CTT
\newcommand*{\pixctt}{\ctt\ixctt}             % print & index CTT
\newcommand*{\prtoc}{ToC}             % print ToC
\newcommand*{\prlof}{LoF}             % print LoF
\newcommand*{\prlot}{LoT}             % print LoT
\newcommand*{\ixtoc}{\index{ToC}}     % index ToC
\newcommand*{\ixlof}{\index{LoF}}     % index LoF
\newcommand*{\ixlot}{\index{LoT}}     % index LoT
\newcommand*{\toc}{\prtoc\ixtoc}      % print & index ToC
\newcommand*{\lof}{\prlof\ixlof}      % print & index LoF
\newcommand*{\lot}{\prlot\ixlot}      % print & index LoT
\newcommand*{\prfrontmatter}{front matter} % macros for frontmatter
\newcommand*{\prFrontmatter}{Front matter} 
\newcommand*{\ixfrontmatter}{\index{front matter?\prfrontmatter}}
\newcommand*{\pixfrontmatter}{\prfrontmatter\ixfrontmatter}
\newcommand*{\pixFrontmatter}{\prFrontmatter\ixfrontmatter}
\newcommand*{\prmainmatter}{main matter}  % macros for mainmatter
\newcommand*{\prMainmatter}{Main matter} 
\newcommand*{\ixmainmatter}{\index{main matter?\prmainmatter}}
\newcommand*{\pixmainmatter}{\prmainmatter\ixmainmatter}
\newcommand*{\pixMainmatter}{\prMainmatter\ixmainmatter}
\newcommand*{\prbackmatter}{back matter}  % macros for backmatter
\newcommand*{\prBackmatter}{Back matter} 
\newcommand*{\ixbackmatter}{\index{back matter?\prbackmatter}}
\newcommand*{\pixbackmatter}{\prbackmatter\ixbackmatter}
\newcommand*{\pixBackmatter}{\prBackmatter\ixbackmatter}

%%%%%%%% from Typo
\providecommand*{\alltx}{(La)\tx}
\providecommand*{\metafont}{Metafont}
\providecommand*{\pscript}{Post\-Script}
\providecommand*{\ixpscript}{\pscript\index{PostScript}}
\providecommand*{\pdf}{PDF}
\providecommand*{\pixpdf}{\pdf\index{PDF}}
%\providecommand*{\prog}[1]{\Prog{#1}}
%\providecommand*{\ixprog}[1]{\index{#1 program?\prog{#1} program}%
%                             \index{program!#1?\prog{#1}}}
%\providecommand*{\pixprog}[1]{\prog{#1}\ixprog{#1}}
%%\providecommand*{\ctt}{\texttt{ctt}}
%%\providecommand*{\ixtx}{\index{TeX?\tx}}
%%\providecommand*{\pixtx}{\tx\ixtx}
%%\providecommand*{\ixltx}{\index{LaTeX?\ltx}}
%%\providecommand*{\pixltx}{\ltx\ixltx}

\newcommand*{\theclass}{memoir}

%%% Print and Index macros
\newcommand*{\noidxnum}[1]{}

%% index @ in macrocode
\newcommand*{\idxatincode}{\index{@?\texttt{@}!in macro code}}
\newcommand*{\seeatincode}{see \Sref{sec:alltexcommands}}

% index marking
\newcommand{\idxmark}[1]{#1\markboth{#1}{#1}}

%%%% index pair of sup/sub items
\newcommand*{\indextwo}[2]{\index{#1!#2}\index{#2!#1}}
%%% index pair of sup/sub/sub
\newcommand*{\indexthree}[3]{\index{#1!#2!#3}\index{#2!#1!#3}}

\newcommand*{\Ppstyle}[1]{\textsl{#1}}
\newcommand*{\pstyle}[1]{\Ppstyle{#1}%
            \index{#1 pages?\Ppstyle{#1} (pagestyle)}%
            \index{pagestyle!#1?\Ppstyle{#1}}}            % pagestyle
\newcommand*{\Pcstyle}[1]{\textsl{#1}}
\newcommand*{\cstyle}[1]{\Pcstyle{#1}%
            \index{#1 chaps?\Pcstyle{#1} (chapterstyle)}%
            \index{chapterstyle!#1?\Pcstyle{#1}}}          % chapterstyle
\newcommand*{\Phstyle}[1]{\textsl{#1}}                    
\newcommand*{\hstyle}[1]{\Phstyle{#1}%
             \index{#1 heads?\Phstyle{#1} (headstyles)}%
             \index{headstyles!#1?\Phstyle{#1}}}      % headstyles
\newcommand*{\Pclass}[1]{\textsf{#1}}
\newcommand*{\Lclass}[1]{\Pclass{#1}%
            \index{#1 class?\Pclass{#1} (class)}%
            \index{class!#1?\Pclass{#1}}}                % class name
\newcommand*{\Iclasssub}[2]{\index{#1 class?\Pclass{#1} (class)!#2}}
\newcommand*{\Mname}{\Pclass{memoir}}                    % Print memoir
\newcommand*{\Ppack}[1]{\textsf{#1}}
\newcommand*{\Lpack}[1]{\Ppack{#1}%
            \index{#1 pack?\Ppack{#1} (package)}%
            \index{package!#1?\Ppack{#1}}}              % package name
\newcommand*{\Popt}[1]{\textsf{#1}}
\newcommand*{\Lopt}[1]{\Popt{#1}%
            \index{#1 opt?\Popt{#1} (option)}%
            \index{option!#1?\Popt{#1}}}               % option name
\newcommand*{\Pe}[1]{\texttt{#1}}                      % print env name
\newcommand*{\Ie}[1]{\texttt{#1}\index{#1 env?\texttt{#1} (environment)}%
                               \index{environment!#1?\texttt{#1}}}
\newcommand*{\Pcn}[1]{\texttt{#1}}                     % print counter name
\newcommand*{\Icn}[1]{\texttt{#1}\index{#1 cou?\Pcn{#1} (counter)}%
                                \index{counter!#1?\Pcn{#1}}}
\newcommand*{\Itt}[1]{\texttt{#1}\index{#1tt?\texttt{#1}}}
\newcommand*{\file}[1]{\texttt{#1}}              % print a file name
\newcommand*{\ixfile}[1]{%                       % index a file name
            \index{#1 file?\file{#1} (file)}%
            \index{file!#1?\file{#1}}}
\newcommand*{\pixfile}[1]{\file{#1}\ixfile{#1}} % print & index a file name
% print and index a length
\newcommand*{\lnc}[1]{\cmdprint{#1}%
  \index{\expandafter\@gobble\string#1len?\string\cmdprint{\string#1} (length)}%
  \index{length!\expandafter\@gobble\string#1len?\string\cmdprint{\string#1}}}

\newcommand*{\posarg}[1]{\textsf{#1}}   % print positioning argument
% index a positioning argument
\newcommand*{\ixposarg}[1]{%
             \index{#1 (position argument)?\posarg{#1} (position argument)}}
% print and index a positioning argument
\newcommand*{\pixposarg}[1]{\posarg{#1}\ixposarg{#1}} 

%     print and index a counter representation
\newcommand*{\pcrep}[1]{\texttt{#1}}
\newcommand*{\ixcrep}[1]{\index{#1 tt?\pcrep{#1}}%
                         \index{counter representation!#1 tt?\pcrep{#1}}}
\newcommand*{\Icrep}[1]{\texttt{#1}\index{#1 tt?\texttt{#1}}}%                % counter representation
\renewcommand*{\Icrep}[1]{\pcrep{#1}\ixcrep{#1}}%   % print & index counter rep
\newcommand*{\pixcrep}[1]{\pcrep{#1}\ixcrep{#1}} % print & index counter rep

% print (and index) TeX keywords                                
\newcommand*{\pkey}[1]{\texttt{#1}}       % TeX keywords
\newcommand*{\pixkey}[1]{\pkey{#1}\index{#1 key?\pkey{#1} (keyword)}%
\index{keyword!#1?\pkey{#1}}}

\newcommand*{\patexp}{@-expression}        %  print @-expression
\newcommand*{\ixatexp}{%
             \index{@-expression?\patexp}} % index @-expression
\newcommand*{\pixatexp}{\patexp\ixatexp}   % print & index @-expression

\newcommand*{\Pprog}[1]{\textsf{#1}}       % print program name
\newcommand*{\Iprog}[1]{\index{#1 prog?\Pprog{#1} (program)}%
                        \index{program!#1?\Pprog{#1}}} % index program name
\newcommand*{\Iprogsub}[2]{\index{#1 prog?\Pprog{#1} (program)!#2}}
\newcommand*{\Lprog}[1]{\Pprog{#1}\Iprog{#1}}      % print & index program name
\DeclareRobustCommand{\Pmakeindex}{\Pprog{MakeIndex}}
\DeclareRobustCommand{\Imakeindex}{\Iprog{MakeIndex}}
\DeclareRobustCommand{\Lmakeindex}{\Lprog{MakeIndex}}
\DeclareRobustCommand{\Pbibtex}{\Pprog{BibTeX}}
\DeclareRobustCommand{\Ibibtex}{\Iprog{BibTeX}}
\DeclareRobustCommand{\Lbibtex}{\Lprog{BibTeX}}

% print and index an \if... \piif{if...}
\newcommand*{\piif}[1]{\cs{#1}\index{#1?\cs{#1}}}

% index command \!
\newcommand*{\iexcl}{\index{"!?\cs{!}}}    
% print and index \!
\newcommand*{\pixabang}{\cmdprint{\!}\index{"!?\string\cs{}\texttt{"!}}}
% print and index \\!
\newcommand*{\pixslashbang}{\cmdprint{\\!}\index{"\"\"!?\string\cmdprint{\\}\texttt{"!}}}

\newcommand*{\senv}[1]{\texttt{\bs begin\{#1\}}} % print \begin{env}
\newcommand*{\eenv}[1]{\texttt{\bs end\{#1\}}}   % print \end{env}

\newcommand*{\listofx}{`List of\ldots'}

\newcommand*{\Note}{\textbf{NOTE:}}

\newcommand*{\ptrue}{\texttt{true}}   % print TRUE
\newcommand*{\pfalse}{\texttt{false}} % print FALSE
\DeclareRobustCommand{\btitle}[1]{\textit{#1}} % print a book/article/etc title


%%% numbers
\let\Mfrac\slashfrac
\newcommand*{\ratio}[2]{{\ensuremath #1 \raise0.2ex\hbox{:} #2}}% or perhaps 0.15ex
\providecommand*{\abyb}[2]{\ensuremath{#1 \times #2}}       %   e.g., 3 x 4
\providecommand*{\abybm}[3]{\ensuremath{#1 \times #2}\:#3}  % e.g., 3 x 4 cm
\providecommand*{\atob}[2]{\ensuremath{#1\!:\!#2}}          % e.g., 3:4


\DeclareRobustCommand*{\lb}{\texttt{\char`\{}}          % prints {
\DeclareRobustCommand*{\rb}{\texttt{\char`\}}}          % prints }

\newcommand*{\foredge}{fore-edge}
\newlength{\pwlayi}\setlength{\pwlayi}{0.45\textwidth} % 
\newlength{\pwlayii}\setlength{\pwlayii}{0.45\pwlayi}

\DeclareRobustCommand{\Vprint}[1]{\texttt{\string#1}}


%%%%%% stuff for new LaTeX code environment

% \zeroseps sets list before/after skips to minimum values
\newcommand*{\@zeroseps}{\setlength{\topsep}{\z@}
                        \setlength{\partopsep}{\z@}
                        \setlength{\parskip}{\z@}}
\newlength{\gparindent} \setlength{\gparindent}{\parindent}
\setlength{\gparindent}{0.5\parindent}
% now we can do the new environment. This has no extra before/after spacing.
\newenvironment{lcode}{\@zeroseps
  \renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
  \small\setlength{\baselineskip}{\onelineskip}\verbatim}%
  {\endverbatim
   \vspace{-\baselineskip}%
   \noindent}

%%%%% LaTeX syntax
%%%% control space above/below center environment
\newcommand*{\tightcenter}{%
  \topsep=0.25\onelineskip\trivlist \centering\item\relax}
\def\endtightcenter{\endtrivlist}
\newenvironment{syntax}{\begin{tightcenter}
                        \begin{tabular}{|p{0.9\linewidth}|} \hline}%
                       {\hline
                        \end{tabular}
                        \end{tightcenter}}

%%%%% for demoing chapterstyles
\newcommand*{\chaptext}[1]{The above is a demonstration of the \textit{#1} 
chapterstyle. It is one of several styles that come as part of the
\Pclass{memoir} class.}

%%%\renewcommand*{\theHchapter}{\thesheetsequence.\arabic{chapter}}

\newcount\savechapcnt
\newcount\demochapcnt
\newcount\saveseccnt
\newcount\savesubseccnt
\demochapcnt=0
%%\newcommand*{\theHc@demochapcnt}{\thefigure.\arabic{\c@demochapcnt}}
\newcount\savefigcnt
\newcommand*{\demochapcolor}{\definecolor{shadecolor}{gray}{0.75}}
\newenvironment{demochap}[2][\onelineskip]{%
  \savechapcnt=\c@chapter
  \saveseccnt=\c@section
  \savesubseccnt=\c@subsection
  \c@chapter=\demochapcnt
%%  \stepcounter{demochapcnt}
  \counterwithout*{figure}{chapter}
  \begin{figure}
%%%    \definecolor{shadecolor}{gray}{0.75}
    \demochapcolor
    \begin{shaded}
      \savefigcnt=\c@figure
      \begingroup
%%        \hrule
        \renewcommand{\theHchapter}{\thepage.\thechapter}
        \vspace*{#1}
        \chapterstyle{#2}
        \let\clearforchapter\relax
        \let\insertchapterspace\relax
        \renewcommand*{\addcontentsline}[3]{}
        \renewcommand*{\thispagestyle}[1]{}
        \renewcommand*{\markboth}[2]{}
        \chapter{Demonstration of the #2 chapter style}
        \chaptext{#2}
        \vspace{\onelineskip}
        \hrule
      \endgroup
    \end{shaded}
    \global\demochapcnt=\c@chapter
    \ifnum\demochapcnt>9\relax
      \global\demochapcnt=0\relax
    \fi
    \c@chapter=\savechapcnt
    \advance\c@chapter\m@ne
    \refstepcounter{chapter}%
%%    \stepcounter{chapter}
    \begin{center}
      \caption{The #2 chapterstyle}\label{dc#2}
    \end{center}
    \savefigcnt=\c@figure
    \global\advance\savefigcnt\m@ne
%%    \gdef\theHchapter{\thefigure.\thechapter}
    }{%\gdef\theHchapter{\thechapter}
  \end{figure}
  \counterwithin{figure}{chapter}
  \global\c@section=\saveseccnt
  \global\c@subsection=\savesubseccnt}

%%% comma separated in-line items 
\let\litemize\itemize \let\endlitemize\enditemize
\renewenvironment{litemize}{\renewcommand{\item}{\unskip, }}{}
\newenvironment{lineitems}{\litemize\renewcommand{\item}{\unskip, }}%
                          {\endlitemize\unskip }

%% typeset stuff in a box
\newdimen\showbinset
\newcommand{\showit}[1]{%
  \setlength{\showbinset}{\linewidth}%
  \addtolength{\showbinset}{-2\fboxsep}%
  \addtolength{\showbinset}{-2\fboxrule}%
  \par\vspace{0.5\onelineskip}\noindent
  \fbox{\parbox{\showbinset}{{#1}}\vspace{0.5\onelineskip}}}
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VERSALS

% Save file as: DROP.STY               Source: FILESERV@SHSU.BITNET  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  DROP.DOC <February 17, 1988>
%  Macro for dropping and enlarging the first letter(s) of a paragraph.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Macro written by David G. Cantor, and published Fri, 12 Feb 88, in
%  TeXhax, 1988 #16.  
%  Internet:  dgc@math.ucla.edu
%  UUCP:      ...!{ihnp4, randvax, sdcrdcf, ucbvax}!ucla-cs!dgc
%
%  Modified for use with LaTeX by Dominik Wujastyk, February 17, 1988
%  Internet:   dow@wjh12.harvard.edu
%  Bitnet:     dow@harvunxw.bitnet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  This LaTeX macro is for dropping and enlarging the first letter(s) of a
%  paragraph.  The argument may be one or more letters.
%
%  Here is an example of its usage:
%
%  \documentstyle[drop]{article}
%  \begin{document}
%    \drop{IN} THE beginning God created the heaven and the earth.  Now the
%    earth was unformed and void, and darkness was upon the face of the
%    deep; and the spirit of God hovered over the face of the waters.
%  \end{document}
%
%  Which will produce something along these lines:
%
%  I I\  I THE beginning God  created the heaven and  the earth.
%  I I \ I Now the earth was unformed and void, and darkness was
%  I I  \I upon the face of the deep; and the spirit of God hov-
%  ered over the face of the waters.
%
%  In the first instance the macro will pause during LaTeX processing and 
%  ask you for the font you wish to use for you drop capital.  When you
%  have something that looks good, then comment out box one in DROP.STY,
%  and comment in box two, replacing "cmr10 scaled \magstep5" with the font
%  of your choice.
%
%  In my opinion (DW) there are no fonts available in the standard
%  TeX/LaTeX set that are ideal for this use, unless you go down to 9pt or 
%  8pt for your text face, and this is too small.  If you have Metafont you
%  should consider generating a cmr17 font at a magstep of two (about 25pt)
%  or three (about 30pt), or even more, depending on the point size of your
%  main text.  Why not go the whole hog and design some really fancy 
%  capitals from scratch!
%
%%%%%%%%%%%%%%%%%%%%% BOX ONE %%%%%%%%%%%%%%%%%%%%%%%%%
%\typein[\dropinitialfont]{Font for Dropped initial:}  %
%\font\largefont \dropinitialfont                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%%%%%%%%%%%%%%%%%%%% BOX TWO %%%%%%%%%%%%%%%%%%%%%%%%%
%\font\largefont= cmr10 scaled \magstep5              %
%\font\largefont= cmbx10 scaled \magstep5              %
%\font\largefont= cmbx17 scaled \magstep3              %
\font\largefont= cmr17 scaled \magstep5              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\drop#1#2{{\noindent
    \setbox0\hbox{\largefont #1}\setbox1\hbox{#2}\setbox2\hbox{(}%
    \count0=\ht0\advance\count0 by\dp0\count1\baselineskip
    \advance\count0 by-\ht1\advance\count0by\ht2
    \dimen1=.5ex\advance\count0by\dimen1\divide\count0 by\count1
    \advance\count0 by1\dimen0\wd0
    \advance\dimen0 by.25em\dimen1=\ht0\advance\dimen1 by-\ht1
    \global\hangindent\dimen0\global\hangafter-\count0
    \hskip-\dimen0\setbox0\hbox to\dimen0{\raise-\dimen1\box0\hss}%
    \dp0=0in\ht0=0in\box0}#2}

% end of DROP.STY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\versal}[1]{{\noindent
    \setbox0\hbox{\largefont #1}%
    \count0=\ht0                   % height of versal
    \count1=\baselineskip          % baselineskip
    \divide\count0 by \count1      % versal height/baselineskip
    \dimen1 = \count0\baselineskip % distance to drop versal
    \advance\count0 by 1\relax     % no of indented lines
    \dimen0=\wd0                   % width of versal
    \global\hangindent\dimen0      % set indentation distance
    \global\hangafter-\count0      % set no of indented lines
    \hskip-\dimen0\setbox0\hbox to\dimen0{\raise-\dimen1\box0\hss}%
    \dp0=0in\ht0=0in\box0}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END VERSALS


\newlength{\gparskip} \setlength{\gparskip}{\parskip}

\typeout{Defining listeg, egsource, egresult, etc}
\newenvironment{listeg}{%
  \list{}{%
    \listparindent\z@
    \itemindent\listparindent
    \parsep\z@
    \leftmargin\gparindent
    \rightmargin\leftmargin}
    \item\relax}{\endlist}

% \begin{egsource}{label}
\newcommand*{\egsourcecolor}{\definecolor{shadecolor}{gray}{0.9}}
\newenvironment{egsource}[1]{%
  \parskip\z@ \topsep\z@% 
  \egsourcecolor
  \shaded
  \listeg\centerline{Source for example~\ref{#1}}%\label{#1}
  \vspace{\onelineskip}
  \small\setlength{\baselineskip}{\onelineskip}\nobreak\verbatim}%
  {\endverbatim\endlisteg\endshaded}%\vskip\onelineskip\noindent}

\newcommand*{\Hline}{\mbox{}\hrulefill\mbox{}} % line across the page


\newcommand*{\shadecodecolor}{\definecolor{shadecolor}{gray}{0.93}}
\newenvironment{shadecode}{\@zeroseps
  \shadecodecolor
  \renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
  \shaded
  \small\setlength{\baselineskip}{\onelineskip}\verbatim}%
  {\endverbatim
   \vspace{-\baselineskip}%
   \endshaded
   \noindent}
  
\newenvironment{typeseteg}{%
  \list{}{%
    \listparindent\gparindent
    \itemindent\listparindent
    \parsep\gparskip
    \leftmargin\gparindent
    \rightmargin\leftmargin}
    \item\relax}{\endlist}

\newcommand*{\captegresult}{Typeset example}
\newfloat[chapter]{tegresult}{loe}{\captegresult}
\newcommand*{\listegresultsname}{List of typeset examples}
\newlistof{listofegresults}{loe}{\listegresultsname}
\newlistentry[chapter]{tegresult}{loe}{0}

\newcommand*{\egresultcolor}{\definecolor{shadecolor}{gray}{0.9}}
% \begin{egresult}[caption]{label}
\newenvironment{egresult}[2][]{%
  \begin{tegresult}
  \egresultcolor
\begin{shaded}
  \caption{#1}\label{#2}
  \vspace{-0.75\onelineskip}
  \Hline
  \begin{typeseteg}}%
  {\end{typeseteg}%
   \vspace{-0.5\onelineskip}
   \Hline
\end{shaded}
\end{tegresult}}

\newenvironment{egresultplain}[2][]{%
  \begin{tegresult}
  \egresultcolor
\begin{shaded}
  \caption{#1}\label{#2}
  \begin{typeseteg}}%
  {\end{typeseteg}%
\end{shaded}
\end{tegresult}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% More stuff for showing examples

\newcommand*{\egstart}[1][0pt]{\par\begingroup
  \begin{adjustwidth}{-#1}{-#1}%
  \centering
  \begin{minipage}{0.45\linewidth}}
\newcommand*{\egmid}{%
  \end{minipage}\hfill\begin{minipage}{0.45\linewidth}}
\newcommand*{\egend}{%
  \end{minipage}\end{adjustwidth}\endgroup\par}

\newoutputstream{egout}
  \openoutputfile{\jobname.ego}{egout}

\newcommand*{\shadefigurecolor}{\definecolor{shadecolor}{gray}{0.75}}
\newenvironment{shadefigure}{%
  \begin{figure}
  \centering
  \shadefigurecolor
  \begin{shaded}}%
  {\end{shaded}\end{figure}}

\newcommand*{\shadetablecolor}{\definecolor{shadecolor}{gray}{0.75}}
\newenvironment{shadetable}{%
  \begin{table}
  \centering
  \shadetablecolor
  \begin{shaded}}%
  {\end{shaded}\end{table}}

%%%%% Option, etc description list
\newenvironment{plainlist}%
               {\list{}{\labelwidth\z@ \itemindent-\leftmargin
                        \let\makelabel\plainlistlabel}}%
               {\endlist}
\newcommand*{\plainlistlabel}[1]{\hspace\labelsep
                                 \normalfont #1}


\DeclareRobustCommand{\ls}[1]{\texttt{\char`\\#1} (length)}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% FROM TITLEPAGES.TEX

\newcommand*{\FSfont}[1]{%
  \fontfamily{#1}\selectfont}

\newcommand*{\boxminipage}{%
  \@ifnextchar [%]
    \@ibxminipage
    {\@iiibxminipage c\relax[s]}}
\def\@ibxminipage[#1]{%
  \@ifnextchar [%]
    {\@iibxminipage{#1}}%
    {\@iiibxminipage{#1}\relax[s]}}
\def\@iibxminipage#1[#2]{%
  \@ifnextchar [%]
    {\@iiibxminipage{#1}{#2}}%
    {\@iiibxminipage{#1}{#2}[#1]}}
\let\@bxminto\@empty
\def\@iiibxminipage#1#2[#3]#4{%
  \ifx\relax#2\else
    \setlength\@tempdimb{#2}%
    \def\@bxminto{to\@tempdimb}%
  \fi
  \leavevmode
  \@pboxswfalse
  \if #1b\vbox
  \else
    \if #1t\vtop
    \else
      \ifmmode \vcenter
      \else \@pboxswtrue $\vcenter
      \fi
    \fi
  \fi
%  \@bxminto
  \bgroup%          outermost vbox
    \hsize #4
    \hrule\@height\fboxrule
    \hbox\bgroup%   inner hbox
      \vrule\@width\fboxrule \hskip\fboxsep 
        \vbox \@bxminto
        \bgroup% innermost vbox
        \vskip\fboxsep
        \advance\hsize -2\fboxrule \advance\hsize -2\fboxsep
        \textwidth\hsize \columnwidth\hsize
        \@parboxrestore
        \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
        \let\@footnotetext\@mpfootnotetext
        \let\@listdepth\@mplistdepth \@mplistdepth\z@
        \@minipagerestore\@minipagetrue
        \everypar{\global\@minipagefalse\everypar{}}}

\def\endboxminipage{%
  \par\vskip-\lastskip
  \ifvoid\@mpfootins\else
    \vskip\skip\@mpfootins\footnoterule\unvbox\@mpfootins\fi
  \vskip\fboxsep
  \egroup%    end innermost vbox
  \hskip\fboxsep \vrule\@width\fboxrule
  \egroup%    end hbox
  \hrule\@height\fboxrule
  \egroup%    end outermost vbox
  \if@pboxsw $\fi}

\newlength{\tpheight}\setlength{\tpheight}{0.9\textheight}
\newlength{\txtheight}\setlength{\txtheight}{0.9\tpheight}
\newlength{\tpwidth}\setlength{\tpwidth}{0.9\textwidth}
\newlength{\txtwidth}\setlength{\txtwidth}{0.9\tpwidth}
\newlength{\tdrop} % (already defined)

\newenvironment{showtitle}{%
  \begin{boxminipage}[c][\tpheight]{\tpwidth}
  \centering\begin{vplace}\begin{minipage}[c][\txtheight]{\txtwidth}}%
{\end{minipage}\end{vplace}\end{boxminipage}}

\definecolor{Dark}{gray}{.2}
\definecolor{Medium}{gray}{.6}
\definecolor{Light}{gray}{.8}

\newcommand*{\plogo}{\fbox{$\mathcal{PL}$}}

%%%%%%%%%%%%%%%%%%


%%%%%%%%% section head designs
\newcommand*{\defaultsecheads}{
  \setsecheadstyle{\normalfont\Large\bfseries\raggedright}
    \setsecindent{0pt}
    \setbeforesecskip{-3.5ex plus -1ex minus -.2ex}
    \setaftersecskip{2.3ex plus .2ex}
  \setsubsecheadstyle{\normalfont\large\bfseries\raggedright}
    \setsubsecindent{0pt}
    \setbeforesubsecskip{-3.25ex plus -1ex minus -.2ex}
    \setaftersubsecskip{1.5ex plus .2ex}
  \setsubsubsecheadstyle{\normalfont\bfseries\raggedright}
    \setsubsubsecindent{0pt}
    \setbeforesubsubsecskip{-3.25ex plus -1ex minus -.2ex}
    \setaftersubsubsecskip{1.5ex plus .2ex}
  \setparaheadstyle{\normalfont\bfseries}
    \setparaindent{0pt}
    \setbeforeparaskip{3.25ex plus 1ex minus .2ex}
    \setafterparaskip{-1em}
  \setsubparaheadstyle{\normalfont\bfseries}
    \setsubparaindent{0pt}
    \setbeforesubparaskip{3.25ex plus 1ex minus .2ex}
    \setaftersubparaskip{-1em}
}

%%%%%%%%%%%%%% Manual layout and design elements

\newcommand*{\memmansecheads}{
  \setsecheadstyle{\normalfont\scshape\raggedright}
    \setsecindent{0pt}
    \setbeforesecskip{-1.333\onelineskip plus -0.5\onelineskip minus -0.5\onelineskip}
    \setaftersecskip{.667\onelineskip plus 0.1\onelineskip}
%%% surround = 2 lines (1.333/.667)
%%% surround = 1 line (.667/.333)
  \setsubsecheadstyle{\normalfont\sffamily\raggedright}
    \setsubsecindent{0pt}
    \setbeforesubsecskip{-.667\onelineskip plus -0.5\onelineskip minus -0.5\onelineskip}
    \setaftersubsecskip{0.333\onelineskip plus 0.1\onelineskip}
%%% surround = 1 line (.667/.333)
  \setsubsubsecheadstyle{\normalfont\itshape\raggedright}
    \setsubsubsecindent{0pt}
    \setbeforesubsubsecskip{-0.667\onelineskip plus -0.25\onelineskip minus -0.25\onelineskip}
    \setaftersubsubsecskip{0.333\onelineskip plus 0.1\onelineskip}
%%% no surround
  \setparaheadstyle{\normalfont\sffamily}
    \setparaindent{0pt}
    \setbeforeparaskip{1.0\onelineskip plus 0.5\onelineskip minus 0.25\onelineskip}
    \setafterparaskip{-1em}
  \setsubparaheadstyle{\normalfont\sffamily}
    \setsubparaindent{0pt}
    \setbeforesubparaskip{1.0\onelineskip plus 0.5\onelineskip minus 0.25\onelineskip}
    \setaftersubparaskip{-1em}
}


%%%%%% hypermarks in index
%    from email from Lars Madsen
\providecommand{\doidxbookmark}[1]{{\def\@tempa{Symbols}\def\@tempb{#1}%
  \centering\bfseries \ifx\@tempa\@tempb @ \else #1\fi\vskip\onelineskip\par}}
\renewcommand{\doidxbookmark}[1]{{\def\@tempa{Symbols}\def\@tempb{#1}%
  \centering\bfseries \ifx\@tempa\@tempb Analphabetics \else #1\fi\vskip\onelineskip\par}}
\providecommand{\hyperpage}[1]{#1}


%%% need more space for ToC page numbers
\setpnumwidth{2.55em}
\setrmarg{3.55em}

%%% need more space for ToC section numbers
\cftsetindents{section}{1.5em}{3.0em}
\cftsetindents{subsection}{4.5em}{3.9em}
\cftsetindents{subsubsection}{8.4em}{4.8em}
\cftsetindents{paragraph}{10.7em}{5.7em}
\cftsetindents{subparagraph}{12.7em}{6.7em}

%%% and for LoF and LoT numbers
\cftsetindents{figure}{0em}{3.0em}
\cftsetindents{table}{0em}{3.0em}

%%% set up the page layout
\settrimmedsize{11in}{210mm}{*}
\setlength{\trimtop}{0pt}
\setlength{\trimedge}{\stockwidth}
\addtolength{\trimedge}{-\paperwidth}
\settypeblocksize{7.75in}{33pc}{*}
\setulmargins{4cm}{*}{*}
\setlrmargins{1.25in}{*}{*}
\setmarginnotes{17pt}{51pt}{\onelineskip}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{2\onelineskip}{*}
\checkandfixthelayout

%%% empty pagestyle for Part pages
\aliaspagestyle{part}{empty}

\bibliographystyle{alpha}

%%% subfigures and tables
\newsubfloat{figure}
\newsubfloat{table}
\setcounter{lofdepth}{2}

%%% Set oldstylenums (which here are taken from CMR, not Palatino)
\DeclareRobustCommand{\Moldstyle}[1]{{\Large\oldstylenums{#1}}}

%%%%% Pavlic `fix' for index

\let\original@wrindexm@m\@wrindexm@m
\def\@wrindexm@m{\catcode`\ =10 \original@wrindexm@m}

\typeout{End memsty.sty}
\endinput

