%  trbook.sty
%
%  Copyright: Andrew R. Conn, Nicholas I. M. Gould and Philippe L. Toint
%
%  book style file for CGT book on Trust Region Methods
%  this version: 20 IX 1999

\newcommand{\PART}{PART}
\newcommand{\Part}{Part}
\newcommand{\Parts}{Parts}
\renewcommand{\part}{part}
\newcommand{\parts}{parts}

% Formatting instructions

\textwidth  13.2cm
\textheight 21.5cm
\oddsidemargin -0.2mm                      % -4.2 mm
%\evensidemargin -0.2mm                     % -4.2 mm
\evensidemargin 2.8cm
\topmargin -8.4mm                          % 2.64 cm

\textwidth  15.2cm 
\textheight 21.5cm
\oddsidemargin 0.0mm                      % -4.2 mm
\evensidemargin 0.0cm
\topmargin -8.4mm                          % 2.64 cm

\def\baselinestretch{1.2}

\renewcommand{\textfraction}{0.05}

% Unit length for figures

\setlength{\unitlength}{1mm}

\renewcommand{\divider}{%
  \addtolength{\fboxsep}{-0.5mm}
\centerline{\psfig{figure=waterline.ps,width=\textwidth,height=1.0mm,silent=}}
%  \centerline{\fbox{\rule{151mm}{0.25mm}}}
  \addtolength{\fboxsep}{0.5mm}
}

\newcommand{\dividerb}{%
  \addtolength{\fboxsep}{-0.5mm}
\centerline{\psfig{figure=waterline.ps,width=\textwidth,angle=180,height=1.0mm,silent=}}
%  \centerline{\fbox{\rule{151mm}{0.25mm}}}
  \addtolength{\fboxsep}{0.5mm}
}

%  Modifications to standard book style to get correct spacings
%  in tables of contents as well as headers for chapter/part pages

\def\@chapter[#1]#2#3{\ifnum \c@secnumdepth >-2\relax
        \refstepcounter{chapter}%

        \addcontentsline{toc}{chapter}{\thechapter
        \hspace{1em}#1}\else

        \addcontentsline{toc}{chapter}{#1}\fi
   \markboth{}{}%
   {\centering
    \interlinepenalty \@M
    \ifnum \c@secnumdepth >-2\relax
     \huge\bf \MakeUppercase{\chaptername}~\thechapter
    \par
    \vskip 30\p@\fi
    \divider
    \vskip 10\p@
    \Huge \bf
    #2\par}
    \vskip 20\p@
    \normalsize
    \noindent #3\par
    \vskip 20\p@
    \dividerb
    \@endchapter}

\def\@endchapter{\vfil\newpage
   \if@twoside
       \hbox{}%
       \thispagestyle{empty}%
       \newpage
   \fi
   \if@tempswa
     \twocolumn
   \fi
   \vfil}

\renewcommand\chapter{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \thispagestyle{empty}%
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@chapter\@schapter}

\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.8em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{4.3em}{3.2em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.5em}{4.1em}}
\renewcommand\@pnumwidth{2.55em}
\renewcommand\@tocrmarg{3.55em}
\renewcommand\@dotsep{4.5}

%  New chapter headings

\newcommand{\chapmark}{\mbox{\raisebox{1.25pt}{$-\diamond-$}}}
\def\@makechapterhead#1{%
  \vspace*{-15\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \vskip 25\p@
        \center \LARGE\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 10\p@
      \fi
    \fi
    \divider
    \vskip 2\p@
    \interlinepenalty\@M
    \center \huge \bfseries #1\par\nobreak
    \vskip 2\p@
    \dividerb
    \vskip 35\p@
  }}

\def\@nochapter[#1]#2#3{\ifnum \c@secnumdepth >-2\relax
        \addcontentsline{toc}{chapter}{\hspace{1.5em}#1}\else
        \addcontentsline{toc}{chapter}{#1}\fi
   \markboth{}{}%
   {\centering
    \interlinepenalty \@M
    \par
    \divider
    \vskip 10\p@
    \Huge \bf
    #2\par}
    \vskip 20\p@
    \normalsize
    \noindent #3\par
    \vskip 20\p@
    \dividerb
    \@endnochapter}

\def\@endnochapter{\vfil\newpage
   \if@twoside
       \hbox{}%
       \thispagestyle{empty}%
       \newpage
   \fi
   \if@tempswa
     \twocolumn
   \fi
   \vfil}

\newcommand\nochapter{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \thispagestyle{empty}%
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@nochapter\@snochapter}

\def\@apdx[#1]#2#3#4{\ifnum \c@secnumdepth >-3\relax
        \addcontentsline{toc}{chapter}{\hspace{1.5em}APPENDIX #4 --- #2}\else
        \addcontentsline{toc}{chapter}{#4}\fi
   \markboth{}{}%
   {\centering
    \interlinepenalty \@M
    \ifnum \c@secnumdepth >-2\relax
     \huge\bf APPENDIX #4
    \par
    \vskip 30\p@\fi
    \divider
    \vskip 10\p@
    \Huge \bf
    #2\par}
    \vskip 20\p@
    \normalsize
    \noindent #3\par
    \vskip 20\p@
    \dividerb
    \@endapdx}

\def\@endapdx{\vfil\newpage
   \if@twoside
       \hbox{}%
       \thispagestyle{empty}%
       \newpage
   \fi
   \if@tempswa
     \twocolumn
   \fi
   \vfil}

\newcommand\apdx{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \thispagestyle{empty}%
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@apdx\@sapdx}







% Equations, tables and figures numbered by chapter and section

\renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
\@addtoreset{figure}{chapter}

\newcommand{\currentchapter}{}
\newcommand{\currentsection}{}
\newcommand{\currentsubsection}{}

\newcommand{\newchapter}[2]{
\renewcommand{\currentchapter}{#1}
\chapter{#1}{#2}
%\markboth{\PART~\arabic{chapter}. \currentchapter}
%{\arabic{chapter}.1. \currentsection}
}

\newcommand{\newsection}[1]{
\renewcommand{\currentsection}{#1}
\section{#1}
\markboth{\PART~\arabic{chapter}. \uppercase{\currentchapter}}
{\arabic{chapter}.\arabic{section}. \uppercase{\currentsection}}
}

\newcommand{\newsubsection}[1]{
\subsection{#1}
\markboth{PART~\arabic{chapter}. \uppercase{\currentchapter}}
{\arabic{chapter}.\arabic{section}. \uppercase{\currentsection}}
}

\newcommand{\newisection}[1]{
\renewcommand{\currentsection}{#1}
\section{#1}
\markboth{\PART~\arabic{chapter}. \uppercase{\currentchapter}}
{\arabic{chapter}.\arabic{section}. \uppercase{\currentsection}}
}

