File: db2latex.sty

package info (click to toggle)
dblatex 0.3.12py3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,684 kB
  • sloc: xml: 102,889; python: 8,259; makefile: 119; sh: 48
file content (492 lines) | stat: -rw-r--r-- 14,584 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
%%
%% This is the DocBook LaTeX style used by DB2LaTeX (http://db2latex.sf.net)
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{db2latex}[2003/04/11 DB2LaTeX 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{ifthen}
\usepackage{float}       
\usepackage{footmisc} 
\usepackage{appendix} 

% Workaround to avoid troubles with accents in \appendixname used as hyperref
% label: force the label prefix to 'appendix' whatever the lang is
\let\orgresetsapp=\@resets@pp
\let\orgrestoreapp=\restoreapp
\let\restoreapp\relax
\def\@resets@pp{%
  \orgresetsapp
  \if@pphyper
    \def\Hy@chapapp{appendix}%
  \fi
  \orgrestoreapp
}

\newcommand{\DBKreleaseinfo}{Working Paper}

\usepackage{dbk_fonts}
\usepackage{dbk_hyper}
\usepackage{dbk_biblio}
\usepackage{dbk_table}
\usepackage{dbk_changebar}
\usepackage{dbk_graphic}
\usepackage{dbk_cover}
\usepackage{dbk_verbatim}
\usepackage{dbk_misc}
\usepackage{dbk_callout}
\usepackage{dbk_locale}
\usepackage{dbk_annot}

% For missing options in article
\@ifundefined{if@openright}
  {\let\if@openright\iftrue}{}

% LaTeX <othercredit> commands to define
%
% #1: mapped to <contrib>
% #2: mapped to <firstname> <surname>
%
\def\DBKinditem#1#2{
  #2  & #1 \tabularnewline
  \hline
}

\newenvironment{DBKindtable}{
  \begin{tabular}{ |l|l| }
  \hline
  \emph{Collaborator} & \emph{Contribution}
  \hline
}{
  \end{tabular}
}

%
% Latex <revhistory> table
%
\newenvironment{DBKrevtable}{
  \begin{longtable}{ |l|l|l|l| }
  \hline
  Revision number & Date & Release Info & Author \tabularnewline
  \hline
  \endhead
}{
  \end{longtable}
}

\newcommand{\DBKreference}{}
\newcommand{\DBKsite}{}
\newcommand{\DBKedition}{}
\newcommand{\DBKsubtitle}{}
\newcommand{\DBKdate}{\today}
\newcommand{\DBKpubdate}{}
\newcommand{\DBKindexation}{}
\newcommand{\DBKrevhistory}{}
\newcommand{\DBKlegalblock}{}
\newcommand{\DBKlegaltitle}{}
\newcommand{\DBKcopyright}{}

% Display ``DRAFT'' as a water mark:
\usepackage{ifpdf}

\newif\ifpdfengine
\ifpdf\pdfenginetrue
\else\ifxetex\pdfenginetrue
\fi\fi

\ifpdfengine
\usepackage{pdfpages}
\usepackage{color}
\def\showwatermark#1{%
  \AddToShipoutPicture{
  \AtTextCenter{%
  \makebox(0,0)[c]{\resizebox{\textwidth}{!}{%
  \rotatebox{45}{\textsf{\textbf{\color[gray]{0.8}#1}}}}}%
  }}
}
\else
\def\showwatermark#1{}%
\fi

% --------------------------
% Title and Bookinfo display
% --------------------------
\let\stdtitle=\title
\def\title#1{
  \def\DBKtitle{#1}
  \stdtitle{\bfseries #1%
    \ifthenelse{\equal{\DBKsubtitle}{}}{}{\\[12pt]\normalsize \DBKsubtitle}}
}

\let\stdauthor=\author
\def\author#1{
  \def\DBKauthor{#1}
  \stdauthor{\begin{minipage}{10cm}\centering #1\end{minipage}}%
}

\let\stdmaketitle=\maketitle
\def\maketitle{
  \stdmaketitle
  \noindent
  \ifthenelse{\boolean{DBKIsBook}}{
    \textbf{\DBKtitle \\}
    \ifx\DBKauthor\empty\else{by \DBKauthor \\}\fi
  }{}
  \hspace{0pt}\\
  \ifthenelse{\equal{\DBKedition}{}}{}{Edition \DBKedition \\}
  \ifthenelse{\equal{\DBKpubdate}{}}{}{Published \DBKpubdate \\}
  \ifthenelse{\equal{\DBKcopyright}{}}{}{\DBKcopyright \\}
  \hspace{0pt}\\
  % Now the legalnotice block
  \DBKlegalblock
  \newpage
}

\newenvironment{DBKlegalnotice}{
  \if@twocolumn
    \noindent\small\textit{\DBKlegaltitle}
    \/\bfseries---$\!$
  \else
    \noindent\begin{center}\small\bfseries\DBKlegaltitle
    \end{center}\begin{quote}\small
  \fi
}{
  \vspace{0.6em}\par\if@twocolumn\else\end{quote}\fi
}

% --------------------------------------------
% Check for PDFLaTeX/LaTeX 
% --------------------------------------------
% Default page setup if not already done by geometry
\@ifpackageloaded{geometry}{}{
\usepackage{anysize}
\marginsize{3cm}{2cm}{1.25cm}{1.25cm}
}

\makeatletter

% Redefine paragraph to put the title on a separate line
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}

% redefine the listoffigures and listoftables so that the name of the chapter
% is printed whenever there are figures or tables from that chapter. encourage
% pagebreak prior to the name of the chapter (discourage orphans).
\let\save@@chapter\@chapter
\let\save@@l@figure\l@figure
\let\the@l@figure@leader\relax
\def\@chapter[#1]#2{\save@@chapter[{#1}]{#2}%
\addtocontents{lof}{\protect\def\the@l@figure@leader{\protect\pagebreak[0]\protect\contentsline{chapter}{\protect\numberline{\thechapter}#1}{}{\thepage}}}%
\addtocontents{lot}{\protect\def\the@l@figure@leader{\protect\pagebreak[0]\protect\contentsline{chapter}{\protect\numberline{\thechapter}#1}{}{\thepage}}}%
}
\renewcommand*\l@figure{\the@l@figure@leader\let\the@l@figure@leader\relax\save@@l@figure}
\let\l@table\l@figure
\makeatother
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
% Safeguard against long headers.
\IfFileExists{truncate.sty}{
\usepackage{truncate}
% Use an ellipsis when text would be larger than x% of the text width.
% Preserve left/right text alignment using \hfill (works for English).
\fancyhead[ol]{\truncate{0.49\textwidth}{\sl\leftmark}}
\fancyhead[er]{\truncate{0.49\textwidth}{\hfill\sl\rightmark}}
\fancyhead[el]{\truncate{0.49\textwidth}{\sl\leftmark}}
\fancyhead[or]{\truncate{0.49\textwidth}{\hfill\sl\rightmark}}
}{\typeout{WARNING: truncate.sty wasn't available and functionality was skipped.}}
\pagestyle{fancy}

% Define front/main/back matter if not available
\makeatletter
\@ifundefined{frontmatter}{
  \def\frontmatter{\cleardoublepage\pagenumbering{roman}}
}{}
\@ifundefined{mainmatter}{
  \def\mainmatter{\cleardoublepage\pagenumbering{arabic}}
}{}
\@ifundefined{backmatter}{
  \def\backmatter{\if@openright\cleardoublepage\else\clearpage\fi}
}{}


\@ifundefined{abstract}{
\newenvironment{abstract}{
  \setlength\parskip{\medskipamount}%
  \setlength\parindent{0pt}%
}{}
}{
% Redefine abstract in avoid page count reset
\def\nocount#1#2{}
\let\stdsetcounter\setcounter

\let\stdabstract\abstract
\let\endstdabstract\endabstract

\renewenvironment{abstract}{%
\let\setcounter\nocount
\stdabstract
}{%
\endstdabstract
\let\setcounter\stdsetcounter
}
}

\makeatother

% ---------------------- 
% Most Common Packages   
% ---------------------- 
\usepackage{latexsym} 
% FIXME: enumitem is expected by the stylesheets
\usepackage{enumitem}
\usepackage{fancybox} 
\usepackage{ragged2e} 
\usepackage{fancyvrb} 
\makeatletter\@namedef{FV@fontfamily@default}{\def\FV@FontScanPrep{}\def\FV@FontFamily{}}\makeatother
\fvset{obeytabs=true,tabsize=3}
\makeatletter
\let\dblatex@center\center\let\dblatex@endcenter\endcenter
\def\dblatex@nolistI{\leftmargin\leftmargini\topsep\z@ \parsep\parskip \itemsep\z@}
\def\center{\let\@listi\dblatex@nolistI\@listi\dblatex@center\let\@listi\@listI\@listi}
\def\endcenter{\dblatex@endcenter}
\makeatother
\usepackage{rotating}         
\usepackage{subfigure}         
\usepackage{tabularx}         

% --------------------------------------------
% Math support                                
% --------------------------------------------
\usepackage{amsmath,amsthm,amsfonts,amsxtra,amsopn}

% ---------------
% Document Font  
% ---------------
\ifxetex\else
\usepackage{palatino}
\fi

% ----------------------------------------------
% Define a new LaTeX environment (adminipage)
% ----------------------------------------------
\newenvironment{admminipage}%
{ % this code corresponds to the \begin{adminipage} command
  \begin{Sbox}%
  \begin{minipage}%
} %done
{ % this code corresponds to the \end{adminipage} command
  \end{minipage}
  \end{Sbox}
  \fbox{\TheSbox}
} %done

% ----------------------------------------------
% Define a new LaTeX length (admlength)
% ----------------------------------------------
\newlength{\admlength}

% ----------------------------------------------
% Define a new LaTeX environment (admonition)
% With 2 parameters:
% #1 The image (e.g. note.pdf)
% #2 The caption
% ----------------------------------------------
\newenvironment{DBKadmonition}[2] {
  % this code corresponds to the \begin{admonition} command
  \hspace{0mm}\newline\hspace*\fill\newline
  \noindent
  \setlength{\fboxsep}{5pt}
  \setlength{\admlength}{\linewidth}
  \addtolength{\admlength}{-10\fboxsep}
  \addtolength{\admlength}{-10\fboxrule}
  \admminipage{\admlength}
  {\bfseries \sc\large{#2}} \newline
  ~\\[1mm]
  \sffamily
  \ifthenelse{\equal{#1}{}}{
    \def\admgraph{false}
  }{
    \def\admgraph{true}
    \includegraphics[width=1cm]{#1}
    \addtolength{\admlength}{-1cm}
    \addtolength{\admlength}{-20pt}
    \begin{minipage}[lt]{\admlength}
  }
  \parskip=0.5\baselineskip \advance\parskip by 0pt plus 2pt
} %done
{ % this code corresponds to the \end{admonition} command
  \vspace{5mm} 
  \ifthenelse{\equal{\admgraph}{false}}{}{
    \end{minipage}
  }
  \endadmminipage
  \vspace{.5em}
  \par
}

\newenvironment{sidebar}[1][]{
  \hspace{0mm}\newline%
  \noindent\begin{Sbox}\begin{minipage}{\linewidth-2\fboxsep-2\fboxrule-\shadowsize}
}{
  \end{minipage}\end{Sbox}\shadowbox{\TheSbox}%
}

% --------------------------------------------
% Commands to manage/style/create floats      
% figures, tables, algorithms, examples, eqn  
% --------------------------------------------
\makeatletter
\floatstyle{ruled}
\restylefloat{figure}
\floatstyle{ruled}
\restylefloat{table}
\@ifundefined{chapter}{
  \floatstyle{ruled}
  \newfloat{program}{ht}{lop}[section]
  \floatstyle{ruled}
  \newfloat{example}{ht}{loe}[section]
  \floatname{example}{\examplename}
  \floatstyle{ruled}
  \newfloat{dbequation}{ht}{lom}[section]
  \def\toclevel@dbequation{0}
  \floatname{dbequation}{\dbequationname}
  \floatstyle{boxed}
  \newfloat{algorithm}{ht}{loa}[section]
  \floatname{algorithm}{Algorithm}
}{
  \floatstyle{ruled}
  \newfloat{program}{ht}{lop}[chapter]
  \floatstyle{ruled}
  \newfloat{example}{ht}{loe}[chapter]
  \floatname{example}{\examplename}
  \floatstyle{ruled}
  \newfloat{dbequation}{ht}{lom}[chapter]
  \def\toclevel@dbequation{0}
  \floatname{dbequation}{\dbequationname}
  \floatstyle{boxed}
  \newfloat{algorithm}{ht}{loa}[chapter]
  \floatname{algorithm}{Algorithm}
}
\makeatother

% --------------------------------------------
% $latex.caption.swapskip enabled for $formal.title.placement support
%\newlength{\docbooktolatextempskip}
%\newcommand{\captionswapskip}{\setlength{\docbooktolatextempskip}{\abovecaptionskip}\setlength{\abovecaptionskip}{\belowcaptionskip}\setlength{\belowcaptionskip}{\docbooktolatextempskip}}
%% Guard against a problem with old package versions.
%\makeatletter
%\AtBeginDocument{
%\DeclareRobustCommand\ref{\@refstar}
%\DeclareRobustCommand\pageref{\@pagerefstar}
%}
%\makeatother
%% --------------------------------------------
\makeatletter
\newcommand{\dbz}{\penalty \z@}
\newcommand{\docbooktolatexpipe}{\ensuremath{|}\dbz}
\newskip\docbooktolatexoldparskip
\newcommand{\docbooktolatexnoparskip}{\docbooktolatexoldparskip=\parskip\parskip=0pt plus 1pt}
\newcommand{\docbooktolatexrestoreparskip}{\parskip=\docbooktolatexoldparskip}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else\hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}

\ifx\dblatex@chaptersmark\@undefined\def\dblatex@chaptersmark#1{\markboth{\MakeUppercase{#1}}{}}\fi
\let\save@makeschapterhead\@makeschapterhead
\def\dblatex@makeschapterhead#1{\vspace*{-80pt}\save@makeschapterhead{#1}}
\def\@makeschapterhead#1{\dblatex@makeschapterhead{#1}\dblatex@chaptersmark{#1}}

			
\AtBeginDocument{\ifx\refname\@undefined\let\docbooktolatexbibname\bibname\def\docbooktolatexbibnamex{\bibname}\else\let\docbooktolatexbibname\refname\def\docbooktolatexbibnamex{\refname}\fi}
% Facilitate use of \cite with \label
\newcommand{\docbooktolatexbibaux}[2]{%
  \protected@write\@auxout{}{\string\global\string\@namedef{docbooktolatexcite@#1}{#2}}
}

%\usepackage{cite}
%\renewcommand\citeleft{(}  % parentheses around list
%\renewcommand\citeright{)} % parentheses around list
\newcommand{\docbooktolatexcite}[2]{%
  \@ifundefined{docbooktolatexcite@#1}%
  {\cite{#1}}%
  {\def\@docbooktolatextemp{#2}\ifx\@docbooktolatextemp\@empty%
   \cite{\@nameuse{docbooktolatexcite@#1}}%
   \else\cite[#2]{\@nameuse{docbooktolatexcite@#1}}%
   \fi%
  }%
}
\newcommand{\docbooktolatexbackcite}[1]{%
  \ifx\Hy@backout\@undefined\else%
    \@ifundefined{docbooktolatexcite@#1}{%
      % emit warning?
    }{%
      \ifBR@verbose%
        \PackageInfo{backref}{back cite \string`#1\string' as \string`\@nameuse{docbooktolatexcite@#1}\string'}%
      \fi%
      \Hy@backout{\@nameuse{docbooktolatexcite@#1}}%
    }%
  \fi%
}

% --------------------------------------------
% A way to honour <footnoteref>s
% Blame j-devenish (at) users.sourceforge.net
% In any other LaTeX context, this would probably go into a style file.
\newcommand{\docbooktolatexusefootnoteref}[1]{\@ifundefined{@fn@label@#1}%
  {\hbox{\@textsuperscript{\normalfont ?}}%
    \@latex@warning{Footnote label `#1' was not defined}}%
  {\@nameuse{@fn@label@#1}}}
\newcommand{\docbooktolatexmakefootnoteref}[1]{%
  \protected@write\@auxout{}%
    {\global\string\@namedef{@fn@label@#1}{\@makefnmark}}%
  \@namedef{@fn@label@#1}{\hbox{\@textsuperscript{\normalfont ?}}}%
  }

% index labeling helper
\let\dbtolatex@@theindex\theindex
\let\dbtolatex@@endtheindex\endtheindex
\renewenvironment{theindex}{
  \if@openright\cleardoublepage\else\clearpage\fi
  \dbtolatex@@theindex
  % To have the index in the TOC
  \@ifundefined{chapter}{
    \addcontentsline{toc}{section}{\numberline{}\indexname}
  }{
    \refstepcounter{chapter}
    \ifnum \value{part} >\z@
      \addcontentsline{toc}{part}{\protect\numberline{}\indexname}
    \else
      \addcontentsline{toc}{chapter}{\numberline{}\indexname}
    \fi
  }
}{
  \dbtolatex@@endtheindex%
}

\newlength\saveparskip \newlength\saveparindent
\newlength\tempparskip \newlength\tempparindent

% Prevent multiple openings of the same aux file
% (happens when backref is used with multiple bibliography environments)
\ifx\AfterBeginDocument\undefined\let\AfterBeginDocument\AtBeginDocument\fi
\AfterBeginDocument{
  \let\latex@@starttoc\@starttoc
  \def\@starttoc#1{%
    \@ifundefined{docbooktolatex@aux#1}{%
      \global\@namedef{docbooktolatex@aux#1}{}%
      \latex@@starttoc{#1}%
    }{}
  }
}