Debian Codegraph @

latex/contrib/db2latex/db2latex.sty

raw ◀ ▶
1 Debian patch touch this file
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 \ifthenelse{\boolean{DBKIsBook}}{
142 \textbf{\DBKtitle \\}
143 \ifx\DBKauthor\empty\else{by \DBKauthor \\}\fi
144 }{}
145 \hspace{0pt}\\
146 \ifthenelse{\equal{\DBKedition}{}}{}{Edition \DBKedition \\}
147 \ifthenelse{\equal{\DBKpubdate}{}}{}{Published \DBKpubdate \\}
148 \ifthenelse{\equal{\DBKcopyright}{}}{}{\DBKcopyright \\}
149 \hspace{0pt}\\
150 % Now the legalnotice block
151 \DBKlegalblock
152 \newpage
153 }
154
155 \newenvironment{DBKlegalnotice}{
156 \if@twocolumn
157 \noindent\small\textit{\DBKlegaltitle}
158 \/\bfseries---$\!$
159 \else
160 \noindent\begin{center}\small\bfseries\DBKlegaltitle
161 \end{center}\begin{quote}\small
162 \fi
163 }{
164 \vspace{0.6em}\par\if@twocolumn\else\end{quote}\fi
165 }
166
167 % --------------------------------------------
168 % Check for PDFLaTeX/LaTeX
169 % --------------------------------------------
170 % Default page setup if not already done by geometry
171 \@ifpackageloaded{geometry}{}{
172 \usepackage{anysize}
173 \marginsize{3cm}{2cm}{1.25cm}{1.25cm}
174 }
175
176 \makeatletter
177
178 % Redefine paragraph to put the title on a separate line
179 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
180 {-3.25ex\@plus -1ex \@minus -.2ex}%
181 {1ex \@plus .2ex}%
182 {\normalfont\normalsize\bfseries}}
183
184 % redefine the listoffigures and listoftables so that the name of the chapter
185 % is printed whenever there are figures or tables from that chapter. encourage
186 % pagebreak prior to the name of the chapter (discourage orphans).
187 \let\save@@chapter\@chapter
188 \let\save@@l@figure\l@figure
189 \let\the@l@figure@leader\relax
190 \def\@chapter[#1]#2{\save@@chapter[{#1}]{#2}%
191 \addtocontents{lof}{\protect\def\the@l@figure@leader{\protect\pagebreak[0]\protect\contentsline{chapter}{\protect\numberline{\thechapter}#1}{}{\thepage}}}%
192 \addtocontents{lot}{\protect\def\the@l@figure@leader{\protect\pagebreak[0]\protect\contentsline{chapter}{\protect\numberline{\thechapter}#1}{}{\thepage}}}%
193 }
194 \renewcommand*\l@figure{\the@l@figure@leader\let\the@l@figure@leader\relax\save@@l@figure}
195 \let\l@table\l@figure
196 \makeatother
197 \usepackage{fancyhdr}
198 \renewcommand{\headrulewidth}{0.4pt}
199 \renewcommand{\footrulewidth}{0.4pt}
200 % Safeguard against long headers.
201 \IfFileExists{truncate.sty}{
202 \usepackage{truncate}
203 % Use an ellipsis when text would be larger than x% of the text width.
204 % Preserve left/right text alignment using \hfill (works for English).
205 \fancyhead[ol]{\truncate{0.49\textwidth}{\sl\leftmark}}
206 \fancyhead[er]{\truncate{0.49\textwidth}{\hfill\sl\rightmark}}
207 \fancyhead[el]{\truncate{0.49\textwidth}{\sl\leftmark}}
208 \fancyhead[or]{\truncate{0.49\textwidth}{\hfill\sl\rightmark}}
209 }{\typeout{WARNING: truncate.sty wasn't available and functionality was skipped.}}
210 \pagestyle{fancy}
211
212 % Define front/main/back matter if not available
213 \makeatletter
214 \@ifundefined{frontmatter}{
215 \def\frontmatter{\cleardoublepage\pagenumbering{roman}}
216 }{}
217 \@ifundefined{mainmatter}{
218 \def\mainmatter{\cleardoublepage\pagenumbering{arabic}}
219 }{}
220 \@ifundefined{backmatter}{
221 \def\backmatter{\if@openright\cleardoublepage\else\clearpage\fi}
222 }{}
223
224
225 \@ifundefined{abstract}{
226 \newenvironment{abstract}{
227 \setlength\parskip{\medskipamount}%
228 \setlength\parindent{0pt}%
229 }{}
230 }{
231 % Redefine abstract in avoid page count reset
232 \def\nocount#1#2{}
233 \let\stdsetcounter\setcounter
234
235 \let\stdabstract\abstract
236 \let\endstdabstract\endabstract
237
238 \renewenvironment{abstract}{%
239 \let\setcounter\nocount
240 \stdabstract
241 }{%
242 \endstdabstract
243 \let\setcounter\stdsetcounter
244 }
245 }
246
247 \makeatother
248
249 % ----------------------
250 % Most Common Packages
251 % ----------------------
252 \usepackage{latexsym}
253 % FIXME: enumitem is expected by the stylesheets
254 \usepackage{enumitem}
255 \usepackage{fancybox}
256 \usepackage{ragged2e}
257 \usepackage{fancyvrb}
258 \makeatletter\@namedef{FV@fontfamily@default}{\def\FV@FontScanPrep{}\def\FV@FontFamily{}}\makeatother
259 \fvset{obeytabs=true,tabsize=3}
260 \makeatletter
261 \let\dblatex@center\center\let\dblatex@endcenter\endcenter
262 \def\dblatex@nolistI{\leftmargin\leftmargini\topsep\z@ \parsep\parskip \itemsep\z@}
263 \def\center{\let\@listi\dblatex@nolistI\@listi\dblatex@center\let\@listi\@listI\@listi}
264 \def\endcenter{\dblatex@endcenter}
265 \makeatother
266 \usepackage{rotating}
267 \usepackage{subfigure}
268 \usepackage{tabularx}
269
270 % --------------------------------------------
271 % Math support
272 % --------------------------------------------
273 \usepackage{amsmath,amsthm,amsfonts,amsxtra,amsopn}
274
275 % ---------------
276 % Document Font
277 % ---------------
278 \ifxetex\else
279 \usepackage{palatino}
280 \fi
281
282 % ----------------------------------------------
283 % Define a new LaTeX environment (adminipage)
284 % ----------------------------------------------
285 \newenvironment{admminipage}%
286 { % this code corresponds to the \begin{adminipage} command
287 \begin{Sbox}%
288 \begin{minipage}%
289 } %done
290 { % this code corresponds to the \end{adminipage} command
291 \end{minipage}
292 \end{Sbox}
293 \fbox{\TheSbox}
294 } %done
295
296 % ----------------------------------------------
297 % Define a new LaTeX length (admlength)
298 % ----------------------------------------------
299 \newlength{\admlength}
300
301 % ----------------------------------------------
302 % Define a new LaTeX environment (admonition)
303 % With 2 parameters:
304 % #1 The image (e.g. note.pdf)
305 % #2 The caption
306 % ----------------------------------------------
307 \newenvironment{DBKadmonition}[2] {
308 % this code corresponds to the \begin{admonition} command
309 \hspace{0mm}\newline\hspace*\fill\newline
310 \noindent
311 \setlength{\fboxsep}{5pt}
312 \setlength{\admlength}{\linewidth}
313 \addtolength{\admlength}{-10\fboxsep}
314 \addtolength{\admlength}{-10\fboxrule}
315 \admminipage{\admlength}
316 {\bfseries \sc\large{#2}} \newline
317 ~\\[1mm]
318 \sffamily
319 \ifthenelse{\equal{#1}{}}{
320 \def\admgraph{false}
321 }{
322 \def\admgraph{true}
323 \includegraphics[width=1cm]{#1}
324 \addtolength{\admlength}{-1cm}
325 \addtolength{\admlength}{-20pt}
326 \begin{minipage}[lt]{\admlength}
327 }
328 \parskip=0.5\baselineskip \advance\parskip by 0pt plus 2pt
329 } %done
330 { % this code corresponds to the \end{admonition} command
331 \vspace{5mm}
332 \ifthenelse{\equal{\admgraph}{false}}{}{
333 \end{minipage}
334 }
335 \endadmminipage
336 \vspace{.5em}
337 \par
338 }
339
340 \newenvironment{sidebar}[1][]{
341 \hspace{0mm}\newline%
342 \noindent\begin{Sbox}\begin{minipage}{\linewidth-2\fboxsep-2\fboxrule-\shadowsize}
343 }{
344 \end{minipage}\end{Sbox}\shadowbox{\TheSbox}%
345 }
346
347 % --------------------------------------------
348 % Commands to manage/style/create floats
349 % figures, tables, algorithms, examples, eqn
350 % --------------------------------------------
351 \makeatletter
352 \floatstyle{ruled}
353 \restylefloat{figure}
354 \floatstyle{ruled}
355 \restylefloat{table}
356 \@ifundefined{chapter}{
357 \floatstyle{ruled}
358 \newfloat{program}{ht}{lop}[section]
359 \floatstyle{ruled}
360 \newfloat{example}{ht}{loe}[section]
361 \floatname{example}{\examplename}
362 \floatstyle{ruled}
363 \newfloat{dbequation}{ht}{lom}[section]
364 \def\toclevel@dbequation{0}
365 \floatname{dbequation}{\dbequationname}
366 \floatstyle{boxed}
367 \newfloat{algorithm}{ht}{loa}[section]
368 \floatname{algorithm}{Algorithm}
369 }{
370 \floatstyle{ruled}
371 \newfloat{program}{ht}{lop}[chapter]
372 \floatstyle{ruled}
373 \newfloat{example}{ht}{loe}[chapter]
374 \floatname{example}{\examplename}
375 \floatstyle{ruled}
376 \newfloat{dbequation}{ht}{lom}[chapter]
377 \def\toclevel@dbequation{0}
378 \floatname{dbequation}{\dbequationname}
379 \floatstyle{boxed}
380 \newfloat{algorithm}{ht}{loa}[chapter]
381 \floatname{algorithm}{Algorithm}
382 }
383 \makeatother
384
385 % --------------------------------------------
386 % $latex.caption.swapskip enabled for $formal.title.placement support
387 %\newlength{\docbooktolatextempskip}
388 %\newcommand{\captionswapskip}{\setlength{\docbooktolatextempskip}{\abovecaptionskip}\setlength{\abovecaptionskip}{\belowcaptionskip}\setlength{\belowcaptionskip}{\docbooktolatextempskip}}
389 %% Guard against a problem with old package versions.
390 %\makeatletter
391 %\AtBeginDocument{
392 %\DeclareRobustCommand\ref{\@refstar}
393 %\DeclareRobustCommand\pageref{\@pagerefstar}
394 %}
395 %\makeatother
396 %% --------------------------------------------
397 \makeatletter
398 \newcommand{\dbz}{\penalty \z@}
399 \newcommand{\docbooktolatexpipe}{\ensuremath{|}\dbz}
400 \newskip\docbooktolatexoldparskip
401 \newcommand{\docbooktolatexnoparskip}{\docbooktolatexoldparskip=\parskip\parskip=0pt plus 1pt}
402 \newcommand{\docbooktolatexrestoreparskip}{\parskip=\docbooktolatexoldparskip}
403 \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else\hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
404
405 \ifx\dblatex@chaptersmark\@undefined\def\dblatex@chaptersmark#1{\markboth{\MakeUppercase{#1}}{}}\fi
406 \let\save@makeschapterhead\@makeschapterhead
407 \def\dblatex@makeschapterhead#1{\vspace*{-80pt}\save@makeschapterhead{#1}}
408 \def\@makeschapterhead#1{\dblatex@makeschapterhead{#1}\dblatex@chaptersmark{#1}}
409
410
411 \AtBeginDocument{\ifx\refname\@undefined\let\docbooktolatexbibname\bibname\def\docbooktolatexbibnamex{\bibname}\else\let\docbooktolatexbibname\refname\def\docbooktolatexbibnamex{\refname}\fi}
412 % Facilitate use of \cite with \label
413 \newcommand{\docbooktolatexbibaux}[2]{%
414 \protected@write\@auxout{}{\string\global\string\@namedef{docbooktolatexcite@#1}{#2}}
415 }
416
417 %\usepackage{cite}
418 %\renewcommand\citeleft{(} % parentheses around list
419 %\renewcommand\citeright{)} % parentheses around list
420 \newcommand{\docbooktolatexcite}[2]{%
421 \@ifundefined{docbooktolatexcite@#1}%
422 {\cite{#1}}%
423 {\def\@docbooktolatextemp{#2}\ifx\@docbooktolatextemp\@empty%
424 \cite{\@nameuse{docbooktolatexcite@#1}}%
425 \else\cite[#2]{\@nameuse{docbooktolatexcite@#1}}%
426 \fi%
427 }%
428 }
429 \newcommand{\docbooktolatexbackcite}[1]{%
430 \ifx\Hy@backout\@undefined\else%
431 \@ifundefined{docbooktolatexcite@#1}{%
432 % emit warning?
433 }{%
434 \ifBR@verbose%
435 \PackageInfo{backref}{back cite \string`#1\string' as \string`\@nameuse{docbooktolatexcite@#1}\string'}%
436 \fi%
437 \Hy@backout{\@nameuse{docbooktolatexcite@#1}}%
438 }%
439 \fi%
440 }
441
442 % --------------------------------------------
443 % A way to honour <footnoteref>s
444 % Blame j-devenish (at) users.sourceforge.net
445 % In any other LaTeX context, this would probably go into a style file.
446 \newcommand{\docbooktolatexusefootnoteref}[1]{\@ifundefined{@fn@label@#1}%
447 {\hbox{\@textsuperscript{\normalfont ?}}%
448 \@latex@warning{Footnote label `#1' was not defined}}%
449 {\@nameuse{@fn@label@#1}}}
450 \newcommand{\docbooktolatexmakefootnoteref}[1]{%
451 \protected@write\@auxout{}%
452 {\global\string\@namedef{@fn@label@#1}{\@makefnmark}}%
453 \@namedef{@fn@label@#1}{\hbox{\@textsuperscript{\normalfont ?}}}%
454 }
455
456 % index labeling helper
457 \let\dbtolatex@@theindex\theindex
458 \let\dbtolatex@@endtheindex\endtheindex
459 \renewenvironment{theindex}{
460 \if@openright\cleardoublepage\else\clearpage\fi
461 \dbtolatex@@theindex
462 % To have the index in the TOC
463 \@ifundefined{chapter}{
464 \addcontentsline{toc}{section}{\numberline{}\indexname}
465 }{
466 \refstepcounter{chapter}
467 \ifnum \value{part} >\z@
468 \addcontentsline{toc}{part}{\protect\numberline{}\indexname}
469 \else
470 \addcontentsline{toc}{chapter}{\numberline{}\indexname}
471 \fi
472 }
473 }{
474 \dbtolatex@@endtheindex%
475 }
476
477 \newlength\saveparskip \newlength\saveparindent
478 \newlength\tempparskip \newlength\tempparindent
479
480 % Prevent multiple openings of the same aux file
481 % (happens when backref is used with multiple bibliography environments)
482 \ifx\AfterBeginDocument\undefined\let\AfterBeginDocument\AtBeginDocument\fi
483 \AfterBeginDocument{
484 \let\latex@@starttoc\@starttoc
485 \def\@starttoc#1{%
486 \@ifundefined{docbooktolatex@aux#1}{%
487 \global\@namedef{docbooktolatex@aux#1}{}%
488 \latex@@starttoc{#1}%
489 }{}
490 }
491 }
492