1%% 2%% This is the DocBook LaTeX style used by DB2LaTeX (http://db2latex.sf.net) 3%% 4\NeedsTeXFormat{LaTeX2e} 5\ProvidesPackage{db2latex}[2003/04/11 DB2LaTeX DocBook Style] 6 7% The defined options 8\DeclareOption{hyperlink}{ \def\DBKhyperlink{yes} } 9\DeclareOption{nohyperlink}{ \def\DBKhyperlink{no} } 10 11% Default values 12\ExecuteOptions{nohyperlink} 13 14% If defined, process the options 15\ProcessOptions\relax 16 17% Needed packages 18\usepackage{ifthen} 19\usepackage{float} 20\usepackage{footmisc} 21\usepackage{appendix} 22 23% Workaround to avoid troubles with accents in \appendixname used as hyperref 24% label: force the label prefix to 'appendix' whatever the lang is 25\let\orgresetsapp=\@resets@pp 26\let\orgrestoreapp=\restoreapp 27\let\restoreapp\relax 28\def\@resets@pp{% 29 \orgresetsapp 30 \if@pphyper 31 \def\Hy@chapapp{appendix}% 32 \fi 33 \orgrestoreapp 34} 35 36\newcommand{\DBKreleaseinfo}{Working Paper} 37 38\usepackage{dbk_fonts} 39\usepackage{dbk_hyper} 40\usepackage{dbk_biblio} 41\usepackage{dbk_table} 42\usepackage{dbk_changebar} 43\usepackage{dbk_graphic} 44\usepackage{dbk_cover} 45\usepackage{dbk_verbatim} 46\usepackage{dbk_misc} 47\usepackage{dbk_callout} 48\usepackage{dbk_locale} 49\usepackage{dbk_annot} 50 51% For missing options in article 52\@ifundefined{if@openright} 53 {\let\if@openright\iftrue}{} 54 55% LaTeX <othercredit> commands to define 56% 57% #1: mapped to <contrib> 58% #2: mapped to <firstname> <surname> 59% 60\def\DBKinditem#1#2{ 61 #2 & #1 \tabularnewline 62 \hline 63} 64 65\newenvironment{DBKindtable}{ 66 \begin{tabular}{ |l|l| } 67 \hline 68 \emph{Collaborator} & \emph{Contribution} 69 \hline 70}{ 71 \end{tabular} 72} 73 74% 75% Latex <revhistory> table 76% 77\newenvironment{DBKrevtable}{ 78 \begin{longtable}{ |l|l|l|l| } 79 \hline 80 Revision number & Date & Release Info & Author \tabularnewline 81 \hline 82 \endhead 83}{ 84 \end{longtable} 85} 86 87\newcommand{\DBKreference}{} 88\newcommand{\DBKsite}{} 89\newcommand{\DBKedition}{} 90\newcommand{\DBKsubtitle}{} 91\newcommand{\DBKdate}{\today} 92\newcommand{\DBKpubdate}{} 93\newcommand{\DBKindexation}{} 94\newcommand{\DBKrevhistory}{} 95\newcommand{\DBKlegalblock}{} 96\newcommand{\DBKlegaltitle}{} 97\newcommand{\DBKcopyright}{} 98 99% Display ``DRAFT'' as a water mark: 100\usepackage{ifpdf} 101 102\newif\ifpdfengine 103\ifpdf\pdfenginetrue 104\else\ifxetex\pdfenginetrue 105\fi\fi 106 107\ifpdfengine 108\usepackage{pdfpages} 109\usepackage{color} 110\def\showwatermark#1{% 111 \AddToShipoutPicture{ 112 \AtTextCenter{% 113 \makebox(0,0)[c]{\resizebox{\textwidth}{!}{% 114 \rotatebox{45}{\textsf{\textbf{\color[gray]{0.8}#1}}}}}% 115 }} 116} 117\else 118\def\showwatermark#1{}% 119\fi 120 121% -------------------------- 122% Title and Bookinfo display 123% -------------------------- 124\let\stdtitle=\title 125\def\title#1{ 126 \def\DBKtitle{#1} 127 \stdtitle{\bfseries #1% 128 \ifthenelse{\equal{\DBKsubtitle}{}}{}{\\[12pt]\normalsize \DBKsubtitle}} 129} 130 131\let\stdauthor=\author 132\def\author#1{ 133 \def\DBKauthor{#1} 134 \stdauthor{\begin{minipage}{10cm}\centering #1\end{minipage}}% 135} 136 137\let\stdmaketitle=\maketitle 138\def\maketitle{ 139 \stdmaketitle 140 \noindent 141 \textbf{\DBKtitle \\} 142 \ifx\DBKauthor\empty\else{by \DBKauthor \\}\fi 143 \hspace{0pt}\\ 144 \ifthenelse{\equal{\DBKedition}{}}{}{Edition \DBKedition \\} 145 \ifthenelse{\equal{\DBKpubdate}{}}{}{Published \DBKpubdate \\} 146 \ifthenelse{\equal{\DBKcopyright}{}}{}{\DBKcopyright \\} 147 \hspace{0pt}\\ 148 % Now the legalnotice block 149 \DBKlegalblock 150 \newpage 151} 152 153\newenvironment{DBKlegalnotice}{ 154 \if@twocolumn 155 \noindent\small\textit{\DBKlegaltitle} 156 \/\bfseries---$\!$ 157 \else 158 \noindent\begin{center}\small\bfseries\DBKlegaltitle 159 \end{center}\begin{quote}\small 160 \fi 161}{ 162 \vspace{0.6em}\par\if@twocolumn\else\end{quote}\fi 163} 164 165% -------------------------------------------- 166% Check for PDFLaTeX/LaTeX 167% -------------------------------------------- 168% Default page setup if not already done by geometry 169\@ifpackageloaded{geometry}{}{ 170\usepackage{anysize} 171\marginsize{3cm}{2cm}{1.25cm}{1.25cm} 172} 173 174\makeatletter 175 176% Redefine paragraph to put the title on a separate line 177\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% 178 {-3.25ex\@plus -1ex \@minus -.2ex}% 179 {1ex \@plus .2ex}% 180 {\normalfont\normalsize\bfseries}} 181 182% redefine the listoffigures and listoftables so that the name of the chapter 183% is printed whenever there are figures or tables from that chapter. encourage 184% pagebreak prior to the name of the chapter (discourage orphans). 185\let\save@@chapter\@chapter 186\let\save@@l@figure\l@figure 187\let\the@l@figure@leader\relax 188\def\@chapter[#1]#2{\save@@chapter[{#1}]{#2}% 189\addtocontents{lof}{\protect\def\the@l@figure@leader{\protect\pagebreak[0]\protect\contentsline{chapter}{\protect\numberline{\thechapter}#1}{}{\thepage}}}% 190\addtocontents{lot}{\protect\def\the@l@figure@leader{\protect\pagebreak[0]\protect\contentsline{chapter}{\protect\numberline{\thechapter}#1}{}{\thepage}}}% 191} 192\renewcommand*\l@figure{\the@l@figure@leader\let\the@l@figure@leader\relax\save@@l@figure} 193\let\l@table\l@figure 194\makeatother 195\usepackage{fancyhdr} 196\renewcommand{\headrulewidth}{0.4pt} 197\renewcommand{\footrulewidth}{0.4pt} 198% Safeguard against long headers. 199\IfFileExists{truncate.sty}{ 200\usepackage{truncate} 201% Use an ellipsis when text would be larger than x% of the text width. 202% Preserve left/right text alignment using \hfill (works for English). 203\fancyhead[ol]{\truncate{0.49\textwidth}{\sl\leftmark}} 204\fancyhead[er]{\truncate{0.49\textwidth}{\hfill\sl\rightmark}} 205\fancyhead[el]{\truncate{0.49\textwidth}{\sl\leftmark}} 206\fancyhead[or]{\truncate{0.49\textwidth}{\hfill\sl\rightmark}} 207}{\typeout{WARNING: truncate.sty wasn't available and functionality was skipped.}} 208\pagestyle{fancy} 209 210% Define front/main/back matter if not available 211\makeatletter 212\@ifundefined{frontmatter}{ 213 \def\frontmatter{\cleardoublepage\pagenumbering{roman}} 214}{} 215\@ifundefined{mainmatter}{ 216 \def\mainmatter{\cleardoublepage\pagenumbering{arabic}} 217}{} 218\@ifundefined{backmatter}{ 219 \def\backmatter{\if@openright\cleardoublepage\else\clearpage\fi} 220}{} 221 222 223\@ifundefined{abstract}{ 224\newenvironment{abstract}{ 225 \setlength\parskip{\medskipamount}% 226 \setlength\parindent{0pt}% 227}{} 228}{ 229% Redefine abstract in avoid page count reset 230\def\nocount#1#2{} 231\let\stdsetcounter\setcounter 232 233\let\stdabstract\abstract 234\let\endstdabstract\endabstract 235 236\renewenvironment{abstract}{% 237\let\setcounter\nocount 238\stdabstract 239}{% 240\endstdabstract 241\let\setcounter\stdsetcounter 242} 243} 244 245\makeatother 246 247% ---------------------- 248% Most Common Packages 249% ---------------------- 250\usepackage{latexsym} 251% FIXME: enumitem is expected by the stylesheets 252\usepackage{enumitem} 253\usepackage{fancybox} 254\usepackage{ragged2e} 255\usepackage{fancyvrb} 256\makeatletter\@namedef{FV@fontfamily@default}{\def\FV@FontScanPrep{}\def\FV@FontFamily{}}\makeatother 257\fvset{obeytabs=true,tabsize=3} 258\makeatletter 259\let\dblatex@center\center\let\dblatex@endcenter\endcenter 260\def\dblatex@nolistI{\leftmargin\leftmargini\topsep\z@ \parsep\parskip \itemsep\z@} 261\def\center{\let\@listi\dblatex@nolistI\@listi\dblatex@center\let\@listi\@listI\@listi} 262\def\endcenter{\dblatex@endcenter} 263\makeatother 264\usepackage{rotating} 265\usepackage{subfigure} 266\usepackage{tabularx} 267 268% -------------------------------------------- 269% Math support 270% -------------------------------------------- 271\usepackage{amsmath,amsthm,amsfonts,amsxtra,amsopn} 272 273% --------------- 274% Document Font 275% --------------- 276\ifxetex\else 277\usepackage{palatino} 278\fi 279 280% ---------------------------------------------- 281% Define a new LaTeX environment (adminipage) 282% ---------------------------------------------- 283\newenvironment{admminipage}% 284{ % this code corresponds to the \begin{adminipage} command 285 \begin{Sbox}% 286 \begin{minipage}% 287} %done 288{ % this code corresponds to the \end{adminipage} command 289 \end{minipage} 290 \end{Sbox} 291 \fbox{\TheSbox} 292} %done 293 294% ---------------------------------------------- 295% Define a new LaTeX length (admlength) 296% ---------------------------------------------- 297\newlength{\admlength} 298 299% ---------------------------------------------- 300% Define a new LaTeX environment (admonition) 301% With 2 parameters: 302% #1 The image (e.g. note.pdf) 303% #2 The caption 304% ---------------------------------------------- 305\newenvironment{DBKadmonition}[2] { 306 % this code corresponds to the \begin{admonition} command 307 \hspace{0mm}\newline\hspace*\fill\newline 308 \noindent 309 \setlength{\fboxsep}{5pt} 310 \setlength{\admlength}{\linewidth} 311 \addtolength{\admlength}{-10\fboxsep} 312 \addtolength{\admlength}{-10\fboxrule} 313 \admminipage{\admlength} 314 {\bfseries \sc\large{#2}} \newline 315 ~\\[1mm] 316 \sffamily 317 \ifthenelse{\equal{#1}{}}{ 318 \def\admgraph{false} 319 }{ 320 \def\admgraph{true} 321 \includegraphics[width=1cm]{#1} 322 \addtolength{\admlength}{-1cm} 323 \addtolength{\admlength}{-20pt} 324 \begin{minipage}[lt]{\admlength} 325 } 326 \parskip=0.5\baselineskip \advance\parskip by 0pt plus 2pt 327} %done 328{ % this code corresponds to the \end{admonition} command 329 \vspace{5mm} 330 \ifthenelse{\equal{\admgraph}{false}}{}{ 331 \end{minipage} 332 } 333 \endadmminipage 334 \vspace{.5em} 335 \par 336} 337 338\newenvironment{sidebar}[1][]{ 339 \hspace{0mm}\newline% 340 \noindent\begin{Sbox}\begin{minipage}{\linewidth-2\fboxsep-2\fboxrule-\shadowsize} 341}{ 342 \end{minipage}\end{Sbox}\shadowbox{\TheSbox}% 343} 344 345% -------------------------------------------- 346% Commands to manage/style/create floats 347% figures, tables, algorithms, examples, eqn 348% -------------------------------------------- 349\makeatletter 350\floatstyle{ruled} 351\restylefloat{figure} 352\floatstyle{ruled} 353\restylefloat{table} 354\@ifundefined{chapter}{ 355 \floatstyle{ruled} 356 \newfloat{program}{ht}{lop}[section] 357 \floatstyle{ruled} 358 \newfloat{example}{ht}{loe}[section] 359 \floatname{example}{\examplename} 360 \floatstyle{ruled} 361 \newfloat{dbequation}{ht}{lom}[section] 362 \def\toclevel@dbequation{0} 363 \floatname{dbequation}{\dbequationname} 364 \floatstyle{boxed} 365 \newfloat{algorithm}{ht}{loa}[section] 366 \floatname{algorithm}{Algorithm} 367}{ 368 \floatstyle{ruled} 369 \newfloat{program}{ht}{lop}[chapter] 370 \floatstyle{ruled} 371 \newfloat{example}{ht}{loe}[chapter] 372 \floatname{example}{\examplename} 373 \floatstyle{ruled} 374 \newfloat{dbequation}{ht}{lom}[chapter] 375 \def\toclevel@dbequation{0} 376 \floatname{dbequation}{\dbequationname} 377 \floatstyle{boxed} 378 \newfloat{algorithm}{ht}{loa}[chapter] 379 \floatname{algorithm}{Algorithm} 380} 381\makeatother 382 383% -------------------------------------------- 384% $latex.caption.swapskip enabled for $formal.title.placement support 385%\newlength{\docbooktolatextempskip} 386%\newcommand{\captionswapskip}{\setlength{\docbooktolatextempskip}{\abovecaptionskip}\setlength{\abovecaptionskip}{\belowcaptionskip}\setlength{\belowcaptionskip}{\docbooktolatextempskip}} 387%% Guard against a problem with old package versions. 388%\makeatletter 389%\AtBeginDocument{ 390%\DeclareRobustCommand\ref{\@refstar} 391%\DeclareRobustCommand\pageref{\@pagerefstar} 392%} 393%\makeatother 394%% -------------------------------------------- 395\makeatletter 396\newcommand{\dbz}{\penalty \z@} 397\newcommand{\docbooktolatexpipe}{\ensuremath{|}\dbz} 398\newskip\docbooktolatexoldparskip 399\newcommand{\docbooktolatexnoparskip}{\docbooktolatexoldparskip=\parskip\parskip=0pt plus 1pt} 400\newcommand{\docbooktolatexrestoreparskip}{\parskip=\docbooktolatexoldparskip} 401\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else\hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi} 402 403\ifx\dblatex@chaptersmark\@undefined\def\dblatex@chaptersmark#1{\markboth{\MakeUppercase{#1}}{}}\fi 404\let\save@makeschapterhead\@makeschapterhead 405\def\dblatex@makeschapterhead#1{\vspace*{-80pt}\save@makeschapterhead{#1}} 406\def\@makeschapterhead#1{\dblatex@makeschapterhead{#1}\dblatex@chaptersmark{#1}} 407 408 409\AtBeginDocument{\ifx\refname\@undefined\let\docbooktolatexbibname\bibname\def\docbooktolatexbibnamex{\bibname}\else\let\docbooktolatexbibname\refname\def\docbooktolatexbibnamex{\refname}\fi} 410% Facilitate use of \cite with \label 411\newcommand{\docbooktolatexbibaux}[2]{% 412 \protected@write\@auxout{}{\string\global\string\@namedef{docbooktolatexcite@#1}{#2}} 413} 414 415%\usepackage{cite} 416%\renewcommand\citeleft{(} % parentheses around list 417%\renewcommand\citeright{)} % parentheses around list 418\newcommand{\docbooktolatexcite}[2]{% 419 \@ifundefined{docbooktolatexcite@#1}% 420 {\cite{#1}}% 421 {\def\@docbooktolatextemp{#2}\ifx\@docbooktolatextemp\@empty% 422 \cite{\@nameuse{docbooktolatexcite@#1}}% 423 \else\cite[#2]{\@nameuse{docbooktolatexcite@#1}}% 424 \fi% 425 }% 426} 427\newcommand{\docbooktolatexbackcite}[1]{% 428 \ifx\Hy@backout\@undefined\else% 429 \@ifundefined{docbooktolatexcite@#1}{% 430 % emit warning? 431 }{% 432 \ifBR@verbose% 433 \PackageInfo{backref}{back cite \string`#1\string' as \string`\@nameuse{docbooktolatexcite@#1}\string'}% 434 \fi% 435 \Hy@backout{\@nameuse{docbooktolatexcite@#1}}% 436 }% 437 \fi% 438} 439 440% -------------------------------------------- 441% A way to honour <footnoteref>s 442% Blame j-devenish (at) users.sourceforge.net 443% In any other LaTeX context, this would probably go into a style file. 444\newcommand{\docbooktolatexusefootnoteref}[1]{\@ifundefined{@fn@label@#1}% 445 {\hbox{\@textsuperscript{\normalfont ?}}% 446 \@latex@warning{Footnote label `#1' was not defined}}% 447 {\@nameuse{@fn@label@#1}}} 448\newcommand{\docbooktolatexmakefootnoteref}[1]{% 449 \protected@write\@auxout{}% 450 {\global\string\@namedef{@fn@label@#1}{\@makefnmark}}% 451 \@namedef{@fn@label@#1}{\hbox{\@textsuperscript{\normalfont ?}}}% 452 } 453 454% index labeling helper 455\let\dbtolatex@@theindex\theindex 456\let\dbtolatex@@endtheindex\endtheindex 457\renewenvironment{theindex}{ 458 \if@openright\cleardoublepage\else\clearpage\fi 459 \dbtolatex@@theindex 460 % To have the index in the TOC 461 \@ifundefined{chapter}{ 462 \addcontentsline{toc}{section}{\numberline{}\indexname} 463 }{ 464 \refstepcounter{chapter} 465 \ifnum \value{part} >\z@ 466 \addcontentsline{toc}{part}{\protect\numberline{}\indexname} 467 \else 468 \addcontentsline{toc}{chapter}{\numberline{}\indexname} 469 \fi 470 } 471}{ 472 \dbtolatex@@endtheindex% 473} 474 475\newlength\saveparskip \newlength\saveparindent 476\newlength\tempparskip \newlength\tempparindent 477 478% Prevent multiple openings of the same aux file 479% (happens when backref is used with multiple bibliography environments) 480\ifx\AfterBeginDocument\undefined\let\AfterBeginDocument\AtBeginDocument\fi 481\AfterBeginDocument{ 482 \let\latex@@starttoc\@starttoc 483 \def\@starttoc#1{% 484 \@ifundefined{docbooktolatex@aux#1}{% 485 \global\@namedef{docbooktolatex@aux#1}{}% 486 \latex@@starttoc{#1}% 487 }{} 488 } 489} 490 491