%%
%% This is a DocBook LaTeX style for Asio
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mybook}[2008/11/11 Asio DocBook Style]

% The defined options
\DeclareOption{hyperlink}{ \def\DBKhyperlink{yes} }
\DeclareOption{nohyperlink}{ \def\DBKhyperlink{no} }

% Default values
\ExecuteOptions{nohyperlink}

% If defined, process the options
\ProcessOptions\relax

% Needed packages
\usepackage[top=2cm,bottom=2cm,left=1.5cm,right=1.5cm]{geometry}
\usepackage{float}
\usepackage{dbk_core}
\usepackage{dbk_admonition}
\usepackage{fancyvrb}

% Text layout
\setlength\parskip{\medskipamount}
\setlength\parindent{0pt}
\raggedbottom

% Stuff we don't need
\def\DBKinditem#1#2{}
\newenvironment{DBKindtable}{}{}
\newenvironment{DBKrevtable}{}{}
\newenvironment{DBKlegalnotice}{}{}

% Admonitions
\floatstyle{boxed}
\newfloat{DBKadmonition}{h}{lop}
\newfloat{sidebar}{h}{lop}

% Page break before sections
\let\orig@section\section
\renewcommand\section{
  \clearpage\orig@section
}

% Ensure line break after paragraph heading
\renewcommand\paragraph{%
  \@startsection{paragraph}{4}{\z@}%
  {-2.25ex\@plus -1ex \@minus -.2ex}%
  {0.5ex \@plus .2ex}%
  {\normalfont\normalsize\bfseries}%
}

% Add page numbers to hyperlinks
%\let\orig@hyperlink\hyperlink
%\renewcommand{\hyperlink}[2]{
%  \orig@hyperlink{#1}{#2} (page \pageref{#1})
%}

% Extra indent on TOC section numbers
\renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{3.3em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{3.8em}{4.2em}}
\renewcommand*\l@paragraph{\@dottedtocline{4}{7.0em}{5.1em}}

% Title page
\renewcommand\maketitle{
  \null
  \thispagestyle{empty}
  \begin{center}
  \null\vskip 7cm
  \begin{LARGE}
  asio C++ library
  \end{LARGE}
  \null\vskip 1cm
  \begin{large}
  \DBKsubtitle{}
  \end{large}
  \null\vskip 1cm
  \begin{Large}
  Reference Manual
  \end{Large}
  \null\vskip 5cm
  \begin{small}
  \DBKcopyright{}
  \end{small}
  \end{center}
  \vfill
  \null
  \cleardoublepage
}
