%% manual.sty    For CafeOBJ manual
\ProvidesPackage{manualsty}[2010/07/08 for manual]
\usepackage[hscale=0.8,vscale=0.9]{geometry}
\usepackage{url}
\usepackage{xcolor}
\usepackage{fancybox}
%\usepackage[dvipdfm,colorlinks=true,linkcolor=blue]{hyperref} 
\usepackage[colorlinks=true,linkcolor=blue]{hyperref} 
%%%% syntax definition of body pages
\newcounter{bsyntax}
\newenvironment{bsyntax}%
 {\begin{Sbox}\begin{minipage}{0.98\textwidth}%
       {\textit{Syntax~\addtocounter{bsyntax}{1}\thebsyntax}\textit{:}}%
       \begingroup\parskip=0cm\parindent=0.5cm\lineskip=0pt%
       \obeylines\obeyspaces\textit}%
 {\endgroup\vskip\parskip\end{minipage}\end{Sbox}\fbox{\TheSbox}}
%%% mini
\newenvironment{fminipage}%
{\begin{Sbox}\begin{minipage}}%
{\end{minipage}\end{Sbox}\fbox{\TheSbox}}
%%%%%
\usepackage{graphicx}
%%%%%%%%%%%%%%%%%% 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

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

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

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

%%%%%%%%% 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 
  Keywords/Commands
  \phantomsection%
  \pdfbookmark[0]{Keywords/Commands}{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}{*}
\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]{Kyewords/Commands}{Analphabetics-glo}%
  \else%
  \phantomsection\pdfbookmark[0]{#1}{#1-glo}%
  \fi%
}


\makeatletter
%%%%% CafeOBJ code
\newcommand{\@zeroseps}{\setlength{\topsep}{\z@}%
  \setlength{\partopsep}{\z@}%
  \setlength{\parskip}{\z@}} \newlength{\gparindent} \setlength{\gparindent}{\parindent}
\setlength{\gparindent}{0.5\parindent}
% Now, the environment itself
\newenvironment{ccode}{\@zeroseps
  \renewcommand{\verbatim@startline}{%
    \verbatim@line{\hskip\gparindent}}
\small\setlength{\baselineskip}{\onelineskip}\verbatim}%
{\endverbatim \vspace{-\baselineskip}%
\noindent
}
%%%% CafeOBJ
\def\cafeobj{\textsf{CafeOBJ}}
%%%%% kbd - argument is characters typed literally.
\def\kbd#1{{\texttt{#1}\null}}
%%%%% beginexample...endexample - surrounds literal text, such a code example.
% typeset in a typewriter font with line breaks preserved.
\def\example{\leavevmode\begingroup
   \obeylines\obeyspaces\parskip0pt\small\texttt}
{\obeyspaces\global\let =\ }
\def\endexample{\endgroup}
% \newenvironment{example}%
% {\begin{framed}\begin{ccode}}
%     {\end{ccode}\end{framed}\noindent}

%%%% terminal - used for terminal symbols, argument is characters appear in sf.
\def\sym#1{\textsf{#1}\null}
%%%% nonterm - used for non terminal symbols, argument is characters typed with
%           italic face.
\def\nonterm#1{\textit{#1}\null}

%%%% syntax ... endsyntax
\def\xstrut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi}
\def\syntax{\syntaxoutnonbox\halign\bgroup
    \xstrut$\@lign##$\hfil &\hfil$\@lign{}##{}$\hfil
    &$\@lign##$\hfil &\qquad\@lign-- ##\hfil\cr}
\def\endsyntax{\crcr\egroup$$
  \global\@ignoretrue
}
\def\syntaxoutnonbox{\xleavevmode$$
    \parskip=0pt\lineskip=0pt
    \def\\{\crcr}% Must have \def and not \let for nested alignments.
    \everycr={\noalign{\penalty10000}}
    \tabskip=0pt}
\def\xleavevmode{\ifvmode\if@inlabel\indent\else\if@noskipsec\indent\else
    \if@nobreak\global\@nobreakfalse\everypar={}\fi
    {\parskip=0pt\noindent}\fi\fi\fi}
\def\@but{\noalign{\nointerlineskip}}
\def\alt{{\;|\;}}
\def\seqof#1{\mbox{\textbf{\{}}\;{#1}\;\mbox{\textbf{\}}}}
\def\optn#1{\textbf{[}\;{#1}\;\textbf{]}}
\def\synindent{\;\;\;}

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

%%%% Warning
\newenvironment{warning}%
{\begin{center}\small\textit{!!}~~~~~\begin{minipage}[c]{0.8\textwidth}\small}%
    {\end{minipage}\end{center}}

%%%%%
\definecolor{shadecolor}{gray}{0.9}
\newenvironment{vvtm}%
{\parskip=0pt\lineskip=0pt\begin{center}\begin{minipage}{0.94\textwidth}\begin{snugshade}\small}%
  {\end{snugshade}\end{minipage}\end{center}}

\makeatother
\typeout{End manual.sty}
\endinput

