%% memsty.sty    For memman
\ProvidesPackage{memsty}[2010/02/09 for memman]

%%%%\usepackage{desc}% temporary, until code added to memoir itself

%%\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{amsmath}
\usepackage[T1]{fontenc}

\providecommand{\LMnote}[2]{}  
\providecommand{\PWnote}[2]{}  

\newcommand\Added[1]{\sidepar{\tiny Added #1}}

%%%%%%%%%%%%%%%%%%% 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 \makebox[2em]{#4}}%
\par\hangindent 2em
  \ifdim\wd\@tempboxa<0.8\linewidth
    #1 \space #2 #3 \dotfill \makebox[2em][r]{#4}\relax
  \else
    #1 \dotfill \makebox[2em][r]{#4}\\
    #2 #3
  \fi}
\renewcommand*{\glossarymark}{\markboth{\glossaryname}{\glossaryname}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%% endnotes
\makepagenote
\notepageref%      use page numbers
\newcommand*{\notemark}{\markboth{\notesname}{\notesname}}
\renewcommand*{\notedivision}{\chapter{\notesname}\notemark}
\renewcommand*{\notenumintext}[1]{}%  no number marks in main text
\renewcommand*{\notenuminnotes}[1]{}% no number marks in listing
\renewcommand*{\idtextinnotes}[1]{\vspace{-0.5\onelineskip}
                                  \par [#1]\space}
\renewcommand*{\notemark}{\markboth{{\scshape \notesname}}{{\scshape \notesname}}}
\renewcommand*{\pagenotesubhead}[3]{%
  \section{#1 #2 #3}}
%%\renewcommand*{\notemark}{\markboth{\notesname}{\notesname}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% 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}{}
}

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

\usepackage{graphicx}
\ifpdf
  \usepackage[pdftex,
              plainpages=false,
              pdfpagelabels,
%%%  hyperfootnotes=false,
              bookmarksnumbered,
%              colorlinks,
%              ocgcolorlinks, % this only works for pdflatex
             ]{hyperref} 
  \DeclareGraphicsRule{*}{mps}{*}{}
\else
  \usepackage[plainpages=false,
  pdfpagelabels,
%%%  hyperfootnotes=false,
  bookmarksnumbered,
  breaklinks,
  % colorlinks,
  ]{hyperref} 
  \usepackage{breakurl}
  \DeclareGraphicsRule{*}{eps}{*}{}
\fi
%%%  \usepackage{memhfixc} %% now called by hyperref


% this is a lillt special, using this one can change the link colors
% in the manual to blacnmk without changing any file, just use
%
% pdflatex "\def\MEMOIRblacklinks{}\input{memman.tex}"
%
\@ifundefined{MEMOIRblacklinks}{%
  \definecolor{linkcolour}{rgb}{0,0.2,0.6}
  \definecolor{citecolour}{rgb}{0,0.6,0.2}
  % \definecolor{filecolor}{rgb}{0,0.2,0.6}
  \definecolor{urlcolour} {rgb}{0.8,0,0.8}
}{%
  typeout{Asked for black links, so that is what you are going to get}
  \definecolor{linkcolour}{rgb}{0,0,0}
  \definecolor{citecolour}{rgb}{0,0,0}
  % \definecolor{filecolor}{rgb}{0,0,0}
  \definecolor{urlcolour} {rgb}{0,0,0}
  \hypersetup{colorlinks}
}
\hypersetup{
    pdftitle={The memoir class},
    pdfauthor={Peter Wilson},
    linkcolor=linkcolour,citecolor=citecolour,
    filecolor=urlcolour,urlcolor=urlcolour,
  }

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

%%%%% 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 sup/sub and sub \indexsupsubmain{main}{sub}
\newcommand*{\indexsupsubmain}[2]{\index{#1!#2}\index{#2}}
%%%% 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}}

%%% \typesubidx{sub} -> \index{type!sub} Index a type subitem
\newcommand*{\typesubidx}[1]{\index{type!#1}}
%%% \seeonceidx{main}{sub} %% index main (see sub), and index sub
\newcommand*{\seeonceidx}[2]{%
  \@ifundefined{s1#2s1}%
    {\global\@namedef{s1#2s1}{?!?}\index{#1!#2|see{#2}}\index{#2}}% %|
    {\index{#2}}}
%%% \facesubseeidx{sub} %% index typeface (see sub), and index sub
\newcommand*{\facesubseeidx}[1]{\seeonceidx{typeface}{#1}}
\newcommand*{\Pfontfam}[1]{\texttt{#1}}   % print name of a fontfamily
\newcommand*{\pfontfam}[1]{\Pfontfam{#1}%  
             \index{#1 fontfam?\Pfontfam{#1} (fontfamily)}%
             \index{fontfamily!#1?\Pfontfam{#1}}}  % print/index fontfamily

\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
%%% 2009/12/19 added \ixenv & changed \Ie to use it
\newcommand*{\ixenv}[1]{\index{#1 env?\Pe{#1} (environment)}% index env
                        \index{environment!#1?\Pe{#1}}}
\newcommand*{\Ie}[1]{\Pe{#1}\ixenv{#1}}                % print & index env
\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{"!}}}

\DeclareRobustCommand{\senv}[1]{\texttt{\bs begin\{#1\}}} % print \begin{env}
\DeclareRobustCommand{\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 }

%% A couple of shorthands
\newcommand*{\tmri}{\mathrm{i}}
\newcommand*{\tmrx}{\mathrm{x}}

\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 demoing fonts
\DeclareFontFamily{T1}{bodoni}{}
\DeclareFontShape{T1}{bodoni}{m}{n}{ <-> bodonirg9a }{}
%% \usethisfont[encoding]{size}{baselineskip}{family}{series}{shape}
\newcommand*{\usethisfont}[6][T1]{%
  \fontencoding{#1}\fontsize{#2}{#3}\fontfamily{#4}\fontseries{#5}%
  \fontshape{#6}\selectfont}
\newcommand*{\termfont}[3]{%
  \usethisfont{25}{30}{#1}{#2}{#3}}
\newcommand*{\UCalphabet}{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \&}
\newcommand*{\LCalphabet}{a b c d e f g h i j k l m n o p q r s t u v w x y z
                          1 2 3 4 5 6 7 8 9 0 ! ? fi fl}
\newcommand*{\fox}{It was a dark and stormy night. 
                   While all the good men were coming to the aid of the
                   party, the quick brown dog had jumped over the fast red fox 
                   to its great surprise. The cattle had wound slowly
                   o'er the lea and I was in the dark.}
\newcommand*{\Kafka}{`But aren't Kafka's Schlo{\ss} and {\AE}sop's
{\OE}uvres often na{\"\i}ve vis-\`a-vis the d{\ae}monic ph{\oe}nix's
official r\^ole in fluffy souffl\'es?' }
\newcommand*{\namesAZ}{ {\AA}ngel\aa\ Beatrice Claire
  Diana \'Erica Fran\c{c}oise Ginette H\'el\`ene Iris
  Jackie K\=aren {\L}au\.ra Mar{\'\i}a N\H{a}ta{\l}{\u\i}e {\O}ctave
  Pauline Qu\^eneau Roxanne Sabine 
%%  T\~a{\'\j}a 
  T\~aja 
  Ur\v{s}ula  Vivian Wendy Xanthippe Yv{\o}nne Z\"azilie }



%% sans label for labelled list
\newcommand*{\sflabel}[1]{\hspace\labelsep \normalfont\sffamily #1}
%% italic label for labelled list
\newcommand*{\itlabel}[1]{\hspace\labelsep \normalfont\itshape #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.
% \LMnote{2010/06/09}{Experimenting with a bit of space before and
% after, looks a bit better}
\newenvironment{lcode}{\@zeroseps
  \nopagebreak
  \vskip0.4em plus 0.1em minus 0.2em
  \renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
  \small\setlength{\baselineskip}{\onelineskip}\verbatim}%
  {\endverbatim
    \vspace{-\baselineskip}
  \vskip0.6em plus 0.1em minus 0.2em
   \noindent}

%%%%% LaTeX syntax
%%%% control space above/below center environment
\newcommand*{\tightcenter}{%
  \topsep=0.25\onelineskip\trivlist \centering\item\relax}
\def\endtightcenter{\endtrivlist}
\LMnote{2010/06/25}{Added a \cs{crcr} here, a bit of a trick, but now
  the last line in syntax does not longer need to end with \\}
\newenvironment{syntax}{\begin{tightcenter}
                        \begin{tabular}{|p{0.9\linewidth}|} \hline}%
                       {\crcr\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
\newcount\saveftncnt
\newcommand*{\demochapcolor}{\definecolor{shadecolor}{gray}{0.75}}
\LMnote{2011/05/25}{I've moved the demochaps to an appendix, so
  \cs{@chapapp} need a little redoing}
\newenvironment{demochap}[2][\onelineskip]{%
  \savechapcnt=\c@chapter
  \saveseccnt=\c@section
  \savesubseccnt=\c@subsection
  \saveftncnt=\c@footnote
  \c@chapter=\demochapcnt
%%  \stepcounter{demochapcnt}
  \counterwithout*{figure}{chapter}
  \begin{figure}[htbp]
%%%    \definecolor{shadecolor}{gray}{0.75}
    \demochapcolor
    \begin{shaded}
      \savefigcnt=\c@figure
      \begingroup
%%        \hrule
        \let\@chapapp\chaptername% such that appendix does not disturb
        \renewcommand{\theHchapter}{\thepage.\thechapter}
        \renewcommand\thechapter{\arabic{chapter}}
        \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
    \renewcommand{\theHchapter}{\thepage.\thechapter-\the\demochapcnt}
    \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
  \global\c@footnote=\saveftncnt}

\newenvironment{demochap*}[2][\onelineskip]{
  \let\DCcaption\caption
  \renewcommand\caption[1]{\DCcaption{##1. This style requires the
      \Lpack{graphicx} package}}
  \begin{demochap}[#1]{#2}}{\end{demochap}}
  

%%% 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}

%%% pair with egresult
% \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*{\captegsource}{Source for example}
%%\newfloat[chapter]{tegsource}{los}{\captegresult}
%%\newcommand*{\listegsourcesname}{List of source code examples}
%%\newlistof{listofegsources}{los}{\listegsourcesname}
%%\newlistentry[chapter]{tegsource}{los}{0}

%%\renewenvironment{egsource}[1]{%
%%\tegsource
%%  \parskip\z@ \topsep\z@% 
%%  \egsourcecolor
%%  \shaded
%%  \listeg\centerline{Source for example~\ref{#1}}%\
%%  \vspace{\onelineskip}
%%  \small\setlength{\baselineskip}{\onelineskip}\nobreak\verbatim}%
%%  {\endverbatim\endlisteg\endshaded%}
%%\endtegsource}


\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}}
%%% pair with egsource
% \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

%%%%%% for FontSite fonts
\newcommand*{\FSfont}[1]{%
  \fontfamily{#1}\selectfont}
%%%%% for `standard' LaTeX fonts
\newcommand*{\LXfont}[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}}
% extended to add booksmarks for each letter group.
\renewcommand{\doidxbookmark}[1]{{\def\@tempa{Symbols}\def\@tempb{#1}%
  \centering\bfseries \ifx\@tempa\@tempb %
  Analphabetics 
  \phantomsection%
  \pdfbookmark[0]{Analphabetics}{Analphabetics-idx}%
%  \label{AnalphabeticsAnalphabeticsAnalphabetics-idx}%
  \else 
  #1%
  \phantomsection%
  \pdfbookmark[0]{#1}{#1-idx}%
%  \label{#1#1#1-idx}%
  \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}{*}
\LMnote{2010/02/05}{added \cs{setsidefeet} to get 
it to use the new width for the  margin par}
\setsidefeet{\marginparsep}{9em}%
   {\onelineskip}{0pt}%
   {\normalfont\footnotesize}{\textheight}%
\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}

% for letter group bookmarks for glossary items
\newcommand\doglobookmark[1]{%
  \def\@tempa{Symbols}\def\@tempb{#1}%
  \ifx\@tempa\@tempb %
  \phantomsection\pdfbookmark[0]{Analphabetics}{Analphabetics-glo}%
  \else%
  \phantomsection\pdfbookmark[0]{#1}{#1-glo}%
  \fi%
}


%%%% SNIPLETS %%%%
\newcounter{sniplet}
\counterwithin{sniplet}{chapter}
\newcommand*\snipletname{Sniplet}
\newcommand*\snipletref[1]{\snipletname~\ref{#1} on~\pref{#1}}
\newenvironment{sniplet}[1][]{
  \refstepcounter{sniplet}
  \edef\mem@e{\@ifnotmtarg{#1}{~(#1)}}
  \section*{\snipletname~\thesniplet\mem@e}
  \phantomsection
  \addcontentsline{toc}{section}{\snipletname\ \thesniplet\mem@e}
  \renewenvironment{lcode}{%\@zeroseps
    \renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
    \small\setlength{\baselineskip}{\onelineskip}\verbatim}%
  {\endverbatim
    \vspace{-0.75\baselineskip}%
    \noindent}
}{}

\let\normalchangetocdepth\changetocdepth
\newcommand\sniplettoc{%
  \setcounter{@memmarkcntra}{\value{tocdepth}}%
  \begingroup%
  \let\changetocdepth\@gobble%
  \normalchangetocdepth{-10}%
  \cftinsertcode{start-sniplets}{\normalchangetocdepth{3}}%
  \cftinsertcode{end-sniplets}{\normalchangetocdepth{-10}}%
  \let\tocheadstart\relax%\@gobble
  % \printtoctitle\@gobble
  \renewcommand\printtoctitle[1]{\section*{Sniplet overview}}%
  \let\aftertoctitle\relax%
  \let\printtocnonum\relax%
  \let\precistoctext\@gobble%
  \setlength\cftsectionindent{0pt}%
  \tableofcontents*
  \endgroup
  \setcounter{tocdepth}{\value{@memmarkcntra}}
}



%%% CTAN links
\providecommand\CTANurl{}
\AtBeginDocument{
  \@ifpackageloaded{hyperref}{
    \renewcommand*\CTANurl[1]{\href{http://mirror.ctan.org#1}{\nolinkurl{#1}}}
  }{
    \renewcommand*\CTANurl[1]{\url{#1}}
  }
}


\newcommand\reimplemented[2]{%
  \textit{Reimplemented, #1\footnote{#2}}
  \fancybreak{}
}

\newenvironment{caveat}{\par\medskip\noindent\textbf{\textit{Caveat.}}\enskip\itshape}{\par\medskip}
\newenvironment{note}{\par\medskip\noindent\textbf{\textit{Note.}}\enskip\itshape}{\par\medskip}
\newenvironment{hint}{\par\medskip\noindent\textbf{\textit{Hint.}}\enskip\itshape}{\par\medskip}
\renewcommand{\cmdprint}[1]{\textup{\texttt{\string#1}}}



\typeout{End memsty.sty}
\endinput

