~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to docutils/writers/newlatex2e/base.tex

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2008-07-24 10:39:53 UTC
  • mfrom: (1.1.4 upstream) (3.1.7 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080724103953-8gh4uezg17g9ysgy
Tags: 0.5-2
* Upload docutils 0.5 to unstable
* Update rst.el to upstream Subversion r5596, which apparently fixes
  all its performance problems (17_speed_up_rst_el.dpatch, closes: #474941)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
% System stylesheet for the new LaTeX writer, newlatex2e.
 
2
 
 
3
% Major parts of the rendering are done in this stylesheet and not in the
 
4
% Python module.
 
5
 
 
6
% For development notes, see notes.txt.
 
7
 
 
8
% User documentation (in the stylesheet for now; that may change though):
 
9
 
 
10
% Naming conventions:
 
11
% All uppercase letters in macro names have a specific meaning.
 
12
% \D...: All macros introduced by the Docutils LaTeX writer start with "D".
 
13
% \DS<name>: Setup function (called at the bottom of this stylesheet).
 
14
% \DN<nodename>{<contents>}: Handler for Docutils document tree node `node`; called by
 
15
%                            the Python module.
 
16
% \DEV<name>: External variable, set by the Python module.
 
17
% \DEC<name>: External command.  It is called by the Python module and must be
 
18
%             defined in this stylesheet.
 
19
% \DN<nodename>A<attribute>{<number>}{<attribute>}{<value>}{<nodename>}{<contents>}:
 
20
%     Attribute handler for `attribute` set on nodes of type `nodename`.
 
21
%     See below for a discussion of attribute handlers.
 
22
% \DA<attribute>{<number>}{<attribute>}{<value>}{<nodename>}{<contents>}:
 
23
%     Attribute handler for all `attribute`.  Called only when no specific
 
24
%     \DN<nodename>A<attribute> handler is defined.
 
25
% \DN<nodename>C<class>{<contents>}:
 
26
%     Handler for `class`, when set on nodes of type `nodename`.
 
27
% \DC<class>{<contents>}:
 
28
%     Handler for `class`.  Called only when no specific \DN<nodename>C<class>
 
29
%     handler is defined.
 
30
% \D<name>: Generic variable or function.
 
31
 
 
32
% Attribute handlers:
 
33
% TODO
 
34
 
 
35
% ---------------------------------------------------------------------------
 
36
 
 
37
% Having to intersperse code with \makeatletter-\makeatother pairs is very
 
38
% annoying, so we call \makeatletter at the top and \makeatother at the
 
39
% bottom.   Just be aware that you cannot use "@" as a text character inside
 
40
% this stylesheet.
1
41
\makeatletter
2
42
 
3
 
% Development notes at
4
 
% http://docutils.python-hosting.com/wiki/NewLatex
5
 
 
6
 
 
 
43
% Print-mode (as opposed to online mode e.g. with Adobe Reader).
 
44
% This causes for example blue hyperlinks.
7
45
\providecommand{\Dprinting}{false}
8
46
 
9
 
 
 
47
% \DSearly is called right after \documentclass.
10
48
\providecommand{\DSearly}{}
 
49
% \DSlate is called at the end of the stylesheet (right before the document
 
50
% tree).
11
51
\providecommand{\DSlate}{}
12
52
 
 
53
% Use the KOMA script article class.
13
54
\providecommand{\Ddocumentclass}{scrartcl}
14
55
\providecommand{\Ddocumentoptions}{a4paper}
15
 
 
16
 
\documentclass[\Ddocumentoptions]{\Ddocumentclass}
17
 
 
18
 
\DSearly
19
 
 
 
56
\providecommand{\DSdocumentclass}{
 
57
  \documentclass[\Ddocumentoptions]{\Ddocumentclass} }
 
58
 
 
59
% Todo: This should be movable to the bottom, but it isn't as long as
 
60
% we use \usepackage commands at the top level of this stylesheet
 
61
% (which we shouldn't).
 
62
\DSdocumentclass
 
63
 
 
64
\providecommand{\DSpackages}{
 
65
  % Load miscellaneous packages.
 
66
  % Note 1: Many of the packages loaded here are used throughout this stylesheet.
 
67
  % If one of these packages does not work on your system or in your scenario,
 
68
  % please let us know, so we can consider making the package optional.
 
69
  % Note 2: It would appear cleaner to load packages where they are used.
 
70
  % However, since using a wrong package loading order can lead to *very*
 
71
  % subtle bugs, we centralize the loading of most packages here.
 
72
  \DSfontencoding % load font encoding packages
 
73
  \DSlanguage % load babel
 
74
  % Using \ifthenelse conditionals.
 
75
  \usepackage{ifthen} % before hyperref (really!)
 
76
  % There is not support for *not* using hyperref because it's used in many
 
77
  % places.  If this is a problem (e.g. because hyperref doesn't work on your
 
78
  % system), please let us know.
 
79
  \usepackage[colorlinks=false,pdfborder={0 0 0}]{hyperref}
 
80
  % Get color, e.g. for links and system messages.
 
81
  \usepackage{color}
 
82
  % Get \textnhtt macro (non-hyphenating type writer).
 
83
  \usepackage{hyphenat}
 
84
  % For sidebars.
 
85
  \usepackage{picins}
 
86
  % We use longtable to create tables.
 
87
  \usepackage{longtable}
 
88
  % Images.
 
89
  \usepackage{graphicx}
 
90
  % These packages might be useful (some just add magic pixie dust), so
 
91
  % evaluate them:
 
92
  %\usepackage{fixmath}
 
93
  %\usepackage{amsmath}
 
94
  % Add some missing symbols like \textonehalf.
 
95
  \usepackage{textcomp}
 
96
}
20
97
 
21
98
\providecommand{\DSfontencoding}{
22
 
  % Set up font encoding.
23
 
  % AE is a T1-emulation.  It provides most characters and features
24
 
  % as T1-encoded fonts but doesn't use ugly bitmap fonts.
 
99
  % Set up font encoding.  Called by \DSpackages.
 
100
  % AE is a T1 emulation.  It provides mostly the same characters and
 
101
  % features as T1-encoded fonts but doesn't use bitmap fonts (which are
 
102
  % unsuitable for online reading and subtle for printers).
25
103
  \usepackage{ae}
26
104
  % Provide the characters not contained in AE from EC bitmap fonts.
27
105
  \usepackage{aecompl}
29
107
  \usepackage{aeguill}
30
108
}
31
109
 
32
 
 
33
110
\providecommand{\DSsymbols}{%
34
111
  % Fix up symbols.
35
112
  % The Euro symbol in Computer Modern looks, um, funny.  Let's get a
36
113
  % proper Euro symbol.
37
 
  \RequirePackage{eurosym}%
 
114
  \usepackage{eurosym}%
38
115
  \renewcommand{\texteuro}{\euro}%
39
116
}
40
117
 
41
 
 
42
118
% Taken from
43
119
% <http://groups.google.de/groups?selm=1i0n5tgtplti420e1omp4pctlv19jpuhbb%404ax.com>
44
120
% and modified.  Used with permission.
52
128
  {}%
53
129
}
54
130
 
55
 
\providecommand{\Dprovidecounter}[1]{%
 
131
\providecommand{\Dprovidecounter}[2]{%
56
132
  % Like \newcounter except that it doesn't crash if the counter
57
133
  % already exists.
58
 
  \@ifundefined{c@#1}{\newcounter{#1}}{}
 
134
  \@ifundefined{c@#1}{\newcounter{#1}\setcounter{#1}{#2}}{}
59
135
}
60
136
 
61
137
\Dprovidelength{\Dboxparindent}{\parindent}
62
 
\providecommand{\Dmakeboxminipage}[1]{%
63
 
  % Make minipage for use in a box created by \Dmakefbox.
64
 
  \begin{minipage}[t]{0.9\linewidth}%
65
 
    \setlength{\parindent}{\Dboxparindent}%
66
 
    #1%
67
 
  \end{minipage}%
68
 
}
69
 
\providecommand{\Dmakefbox}[1]{%
70
 
  % Make a centered, framed box.  Useful e.g. for admonitions.
71
 
  \vspace{0.4\baselineskip}%
72
 
  \begin{center}%
73
 
    \fbox{\Dmakeboxminipage{#1}}%
74
 
  \end{center}%
75
 
  \vspace{0.4\baselineskip}%
76
 
}
 
138
 
77
139
\providecommand{\Dmakebox}[1]{%
78
140
  % Make a centered, frameless box.  Useful e.g. for block quotes.
79
141
  % Do not use minipages here, but create pseudo-lists to allow
86
148
  }%
87
149
}
88
150
 
 
151
\providecommand{\Dmakefbox}[1]{%
 
152
  % Make a centered, framed box.  Useful e.g. for admonitions.
 
153
  \vspace{0.4\baselineskip}%
 
154
  \begin{center}%
 
155
    \fbox{%
 
156
      \begin{minipage}[t]{0.9\linewidth}%
 
157
        \setlength{\parindent}{\Dboxparindent}%
 
158
        #1%
 
159
      \end{minipage}%
 
160
    }%
 
161
  \end{center}%
 
162
  \vspace{0.4\baselineskip}%
 
163
}
89
164
 
90
 
\RequirePackage{ifthen}
91
 
\providecommand{\Dfrenchspacing}{true}
92
 
\ifthenelse{\equal{\Dfrenchspacing}{true}}{\frenchspacing}{}
 
165
% We do not currently recognize the difference between an end-sentence and a
 
166
% mid-sentence period (".  " vs. ". " in plain text).  So \frenchspacing is
 
167
% appropriate.
 
168
\providecommand{\DSfrenchspacing}{\frenchspacing}
93
169
 
94
170
 
95
171
\Dprovidelength{\Dblocklevelvspace}{%
96
172
  % Space between block-level elements other than paragraphs.
97
173
  0.7\baselineskip plus 0.3\baselineskip minus 0.2\baselineskip%
98
174
}
99
 
\providecommand{\Dauxiliaryspace}{%
 
175
\providecommand{\DECauxiliaryspace}{%
100
176
  \ifthenelse{\equal{\Dneedvspace}{true}}{\vspace{\Dblocklevelvspace}}{}%
101
177
  \par\noindent%
102
178
}
103
 
\providecommand{\Dparagraphspace}{\par}
 
179
\providecommand{\DECparagraphspace}{\par}
104
180
\providecommand{\Dneedvspace}{true}
105
181
 
106
 
 
107
 
\providecommand{\DSlinks}{
108
 
  % Targets and references.
109
 
  \RequirePackage[colorlinks=false,pdfborder={0 0 0}]{hyperref}
110
 
 
111
 
  \providecommand{\Draisedlink}[1]{\Hy@raisedlink{##1}}
112
 
  
113
 
  % References.
114
 
  % We're assuming here that the "refid" and "refuri" attributes occur
115
 
  % only in inline context (in TextElements).
116
 
  \providecommand{\DArefid}[5]{%
117
 
    \ifthenelse{\equal{##4}{reference}}{%
118
 
      \Dexplicitreference{\###3}{##5}%
119
 
    }{%
120
 
      % If this is not a target node (targets with refids are
121
 
      % uninteresting and should be silently dropped).
122
 
      \ifthenelse{\not\equal{##4}{target}}{%
123
 
        % If this is a footnote reference, call special macro.
124
 
        \ifthenelse{\equal{##4}{footnotereference}}{%
125
 
          \Dimplicitfootnotereference{\###3}{##5}%
126
 
        }{%
127
 
          \ifthenelse{\equal{##4}{citationreference}}{%
128
 
            \Dimplicitcitationreference{\###3}{##5}%
129
 
          }{%
130
 
            \Dimplicitreference{\###3}{##5}%
131
 
          }%
132
 
        }%
133
 
      }{}%
134
 
    }%
135
 
  }
136
 
  \providecommand{\DArefuri}[5]{%
137
 
    \ifthenelse{\equal{##4}{target}}{%
138
 
      % Hyperlink targets can (and should be) ignored because they are
139
 
      % invisible.
140
 
    }{%
141
 
      % We only have explicit URI references, so one macro suffices.
142
 
      \Durireference{##3}{##5}%
143
 
    }%
144
 
  }
145
 
  % Targets.
146
 
  \providecommand{\DAids}[5]{%
147
 
    \label{##3}%
148
 
    \ifthenelse{\equal{##4}{footnotereference}}{%
149
 
      {%
150
 
        \renewcommand{\HyperRaiseLinkDefault}{%
151
 
          % Dirty hack to make backrefs to footnote references work.
152
 
          % For some reason, \baselineskip is 0pt in fn references.
153
 
          0.5\Doriginalbaselineskip%
154
 
        }%
155
 
        \Draisedlink{\hypertarget{##3}{}}##5%
156
 
      }%
157
 
    }{%
158
 
      \Draisedlink{\hypertarget{##3}{}}##5%
159
 
    }%
160
 
  }
161
 
  % Color in references.
162
 
  \RequirePackage{color}
163
 
  \providecommand{\Dimplicitreference}[2]{%
164
 
    % Create implicit reference to ID.  Implicit references occur
165
 
    % e.g. in TOC-backlinks of section titles.  Parameters:
166
 
    % 1. Target.
167
 
    % 2. Link text.
168
 
    \href{##1}{##2}%
169
 
  }
170
 
  \providecommand{\Dimplicitfootnotereference}[2]{%
171
 
    % Ditto, but for the special case of footnotes.
172
 
    % We want them to be rendered like explicit references.
173
 
    \Dexplicitreference{##1}{##2}%
174
 
  }
175
 
  \providecommand{\Dimplicitcitationreference}[2]{%
176
 
    % Ditto for citation references.
177
 
    \Dimplicitfootnotereference{##1}{##2}%
178
 
  }
179
 
  \ifthenelse{\equal{\Dprinting}{true}}{
180
 
    \providecommand{\Dexplicitreferencecolor}{black}
181
 
  }{
182
 
    \providecommand{\Dexplicitreferencecolor}{blue}
183
 
  }
184
 
  \providecommand{\Dexplicitreference}[2]{%
185
 
    % Create explicit reference to ID, e.g. created with "foo_".
186
 
    % Parameters:
187
 
    % 1. Target.
188
 
    % 2. Link text.
189
 
    \href{##1}{{\color{\Dexplicitreferencecolor}##2}}%
190
 
  }
191
 
  \providecommand{\Durireferencecolor}{\Dexplicitreferencecolor}
192
 
  \providecommand{\Durireference}[2]{%
193
 
    % Create reference to URI.  Parameters:
194
 
    % 1. Target.
195
 
    % 2. Link text.
196
 
    \href{##1}{{\color{\Durireferencecolor}##2}}%
197
 
  }
198
 
}
199
 
 
200
 
 
201
182
\providecommand{\DSlanguage}{%
202
183
  % Set up babel.
203
 
  \ifthenelse{\equal{\Dlanguagebabel}{}}{}{
204
 
    \RequirePackage[\Dlanguagebabel]{babel}
205
 
  }
 
184
  \usepackage[\DEVlanguagebabel]{babel}
206
185
}
207
186
 
208
 
 
209
 
 
210
 
 
 
187
\providecommand{\Difdefined}[3]{\@ifundefined{#1}{#3}{#2}}
 
188
 
 
189
% Handler for 'classes' attribute (called for each class attribute).
211
190
\providecommand{\DAclasses}[5]{%
 
191
  % Dispatch to \DN<nodename>C<class>.
212
192
  \Difdefined{DN#4C#3}{%
213
193
    % Pass only contents, nothing else!
214
194
    \csname DN#4C#3\endcsname{#5}%
215
195
  }{%
 
196
    % Otherwise, dispatch to \DC<class>.
216
197
    \Difdefined{DC#3}{%
217
198
      \csname DC#3\endcsname{#5}%
218
199
    }{%
221
202
  }%
222
203
}
223
204
 
224
 
\providecommand{\Difdefined}[3]{\@ifundefined{#1}{#3}{#2}}
225
 
 
226
 
\providecommand{\Dattr}[5]{%
227
 
  % Global attribute dispatcher.
 
205
\providecommand{\DECattr}[5]{%
 
206
  % Global attribute dispatcher, called inside the document tree.
228
207
  % Parameters:
229
208
  % 1. Attribute number.
230
209
  % 2. Attribute name.
231
210
  % 3. Attribute value.
232
211
  % 4. Node name.
233
212
  % 5. Node contents.
234
 
  \Difdefined{DN#4A#2V#3}{%
235
 
    \csname DN#4A#2V#3\endcsname{#1}{#2}{#3}{#4}{#5}%
236
 
  }{\Difdefined{DN#4A#2}{%
 
213
  \Difdefined{DN#4A#2}{%
 
214
    % Dispatch to \DN<nodename>A<attribute>.
237
215
    \csname DN#4A#2\endcsname{#1}{#2}{#3}{#4}{#5}%
238
 
  }{\Difdefined{DA#2V#3}{%
239
 
    \csname DA#2V#3\endcsname{#1}{#2}{#3}{#4}{#5}%
240
216
  }{\Difdefined{DA#2}{%
 
217
    % Otherwise dispatch to \DA<attribute>.
241
218
    \csname DA#2\endcsname{#1}{#2}{#3}{#4}{#5}%
242
 
  }{#5%
243
 
  }}}}%
244
 
}
 
219
  }{%
 
220
    % Otherwise simply run the contents without calling a handler.
 
221
    #5%
 
222
  }}%
 
223
}
 
224
 
 
225
% ---------- Link handling ----------
 
226
% Targets and references.
 
227
 
 
228
\providecommand{\Draisedlink}[1]{%
 
229
  % Anchors are placed on the base line by default.  This is a bad thing for
 
230
  % inline context, so we raise the anchor (normally by \baselineskip).
 
231
  \Hy@raisedlink{#1}%
 
232
}
 
233
 
 
234
% References.
 
235
% We're assuming here that the "refid" and "refuri" attributes occur
 
236
% only in inline context (in TextElements).
 
237
\providecommand{\DArefid}[5]{%
 
238
  \ifthenelse{\equal{#4}{reference}}{%
 
239
    \Dexplicitreference{\##3}{#5}%
 
240
  }{%
 
241
    % If this is not a target node (targets with refids are
 
242
    % uninteresting and should be silently dropped).
 
243
    \ifthenelse{\not\equal{#4}{target}}{%
 
244
      % If this is a footnote reference, call special macro.
 
245
      \ifthenelse{\equal{#4}{footnotereference}}{%
 
246
        \Dimplicitfootnotereference{\##3}{#5}%
 
247
      }{%
 
248
        \ifthenelse{\equal{#4}{citationreference}}{%
 
249
          \Dimplicitcitationreference{\##3}{#5}%
 
250
        }{%
 
251
          \Dimplicitreference{\##3}{#5}%
 
252
        }%
 
253
      }%
 
254
    }{}%
 
255
  }%
 
256
}
 
257
\providecommand{\DArefuri}[5]{%
 
258
  \ifthenelse{\equal{#4}{target}}{%
 
259
    % The node name is 'target', so this is a hyperlink target, like this:
 
260
    % .. _mytarget: URI
 
261
    % Hyperlink targets are ignored because they are invisible.
 
262
  }{%
 
263
    % If a non-target node has a refuri attribute, it must be an explicit URI
 
264
    % reference (i.e. node name is 'reference').
 
265
    \Durireference{#3}{#5}%
 
266
  }%
 
267
}
 
268
% Targets.
 
269
\providecommand{\DAids}[5]{%
 
270
  \label{#3}%
 
271
  \ifthenelse{\equal{#4}{footnotereference}}{%
 
272
    {%
 
273
      \renewcommand{\HyperRaiseLinkDefault}{%
 
274
        % Dirty hack to make backrefs to footnote references work.
 
275
        % For some reason, \baselineskip is 0pt in fn references.
 
276
        0.5\Doriginalbaselineskip%
 
277
      }%
 
278
      \Draisedlink{\hypertarget{#3}{}}#5%
 
279
    }%
 
280
  }{%
 
281
    \Draisedlink{\hypertarget{#3}{}}#5%
 
282
  }%
 
283
}
 
284
\providecommand{\Dimplicitreference}[2]{%
 
285
  % Create implicit reference to ID.  Implicit references occur
 
286
  % e.g. in TOC-backlinks of section titles.  Parameters:
 
287
  % 1. Target.
 
288
  % 2. Link text.
 
289
  \href{#1}{#2}%
 
290
}
 
291
\providecommand{\Dimplicitfootnotereference}[2]{%
 
292
  % Ditto, but for the special case of footnotes.
 
293
  % We want them to be rendered like explicit references.
 
294
  \Dexplicitreference{#1}{#2}%
 
295
}
 
296
\providecommand{\Dimplicitcitationreference}[2]{%
 
297
  % Ditto for citation references.
 
298
  \Dimplicitfootnotereference{#1}{#2}%
 
299
}
 
300
\providecommand{\Dcolorexplicitreference}{%
 
301
  \ifthenelse{\equal{\Dprinting}{true}}{\color{black}}{\color{blue}}%
 
302
}
 
303
\providecommand{\Dexplicitreference}[2]{%
 
304
  % Create explicit reference to ID, e.g. created with "foo_".
 
305
  % Parameters:
 
306
  % 1. Target.
 
307
  % 2. Link text.
 
308
  \href{#1}{{\Dcolorexplicitreference#2}}%
 
309
}
 
310
\providecommand{\Dcolorurireference}{\Dcolorexplicitreference}
 
311
\providecommand{\Durireference}[2]{%
 
312
  % Create reference to URI.  Parameters:
 
313
  % 1. Target.
 
314
  % 2. Link text.
 
315
  \href{#1}{{\Dcolorurireference#2}}%
 
316
}
 
317
 
 
318
\Dprovidecounter{Dpdfbookmarkid}{0}%
 
319
\providecommand{\Dpdfbookmark}[1]{%
 
320
  % Temporarily decrement Desctionlevel counter.
 
321
  \addtocounter{Dsectionlevel}{-1}%
 
322
  %\typeout{\arabic{Dsectionlevel}}%
 
323
  %\typeout{#1}%
 
324
  %\typeout{docutils\roman{Dpdfbookmarkid}}%
 
325
  %\typeout{}%
 
326
  \pdfbookmark[\arabic{Dsectionlevel}]{#1}{docutils\arabic{Dpdfbookmarkid}}%
 
327
  \addtocounter{Dsectionlevel}{1}%
 
328
  \addtocounter{Dpdfbookmarkid}{1}%
 
329
}
 
330
% ---------- End of Link Handling ----------
245
331
 
246
332
\providecommand{\DNparagraph}[1]{%
247
 
  \ifthenelse{\equal{\Dparagraphindented}{true}}{\indent}{\noindent}%
 
333
  \ifthenelse{\equal{\DEVparagraphindented}{true}}{\indent}{\noindent}%
248
334
  #1%
249
335
}
250
336
\providecommand{\Dformatboxtitle}[1]{{\Large\textbf{#1}}}
252
338
\providecommand{\Dtopictitle}[1]{%
253
339
  \Difinsidetoc{\vspace{1em}\par}{}%
254
340
  \noindent\Dformatboxtitle{#1}%
255
 
  \ifthenelse{\equal{\Dhassubtitle}{false}}{\vspace{1em}}{\vspace{0.5em}}%
 
341
  \ifthenelse{\equal{\DEVhassubtitle}{false}}{\vspace{1em}}{\vspace{0.5em}}%
256
342
  \par%
257
343
}
 
344
\providecommand{\Dadmonitiontitle}[1]{%
 
345
  \Dtopictitle{#1}%
 
346
}
258
347
\providecommand{\Dtopicsubtitle}[1]{%
259
348
  \noindent\Dformatboxsubtitle{#1}%
260
349
  \vspace{1em}%
264
353
\providecommand{\Dsidebarsubtitle}[1]{\Dtopicsubtitle{#1}}
265
354
\providecommand{\Ddocumenttitle}[1]{%
266
355
  \begin{center}{\Huge#1}\end{center}%
267
 
  \ifthenelse{\equal{\Dhassubtitle}{true}}{\vspace{0.1cm}}{\vspace{1cm}}%
 
356
  \ifthenelse{\equal{\DEVhassubtitle}{true}}{\vspace{0.1cm}}{\vspace{1cm}}%
268
357
}
269
358
\providecommand{\Ddocumentsubtitle}[1]{%
270
359
  \begin{center}{\huge#1}\end{center}%
276
365
\providecommand{\Dbookmarksectiontitle}[1]{%
277
366
  % Return text suitable for use in \section*, \subsection*, etc.,
278
367
  % containing a PDF bookmark.  Parameter:  The title (as node tree).
279
 
  \Draisedlink{\Dpdfbookmark{\Dtitleastext}}%
 
368
  \Draisedlink{\Dpdfbookmark{\DEVtitleastext}}%
280
369
  #1%
281
370
}
282
371
\providecommand{\Dsectiontitlehook}[1]{#1}
317
406
    }%
318
407
  }%
319
408
}
320
 
% Boolean variable.
321
 
\providecommand{\Dhassubtitle}{false}
322
409
\providecommand{\DNtitle}[1]{%
323
 
  \csname D\Dparent title\endcsname{#1}%
 
410
  % Dispatch to \D<parent>title.
 
411
  \csname D\DEVparent title\endcsname{#1}%
324
412
}
325
413
\providecommand{\DNsubtitle}[1]{%
326
 
  \csname D\Dparent subtitle\endcsname{#1}%
327
 
}
328
 
\newcounter{Dpdfbookmarkid}
329
 
\setcounter{Dpdfbookmarkid}{0}
330
 
\providecommand{\Dpdfbookmark}[1]{%
331
 
  % Temporarily decrement Desctionlevel counter.
332
 
  \addtocounter{Dsectionlevel}{-1}%
333
 
  %\typeout{\arabic{Dsectionlevel}}%
334
 
  %\typeout{#1}%
335
 
  %\typeout{docutils\roman{Dpdfbookmarkid}}%
336
 
  %\typeout{}%
337
 
  \pdfbookmark[\arabic{Dsectionlevel}]{#1}{docutils\arabic{Dpdfbookmarkid}}%
338
 
  \addtocounter{Dsectionlevel}{1}%
339
 
  \addtocounter{Dpdfbookmarkid}{1}%
 
414
  % Dispatch to \D<parent>subtitle.
 
415
  \csname D\DEVparent subtitle\endcsname{#1}%
340
416
}
341
417
 
342
 
%\providecommand{\DNliteralblock}[1]{\begin{quote}\ttfamily\raggedright#1\end{quote}}
343
418
\providecommand{\DNliteralblock}[1]{%
344
419
  \Dmakelistenvironment{}{%
345
420
    \ifthenelse{\equal{\Dinsidetabular}{true}}{%
350
425
    \raggedright\item\noindent\nohyphens{\textnhtt{#1\Dfinalstrut}}%
351
426
  }%
352
427
}
353
 
\providecommand{\DNdoctestblock}[1]{%
354
 
  % Treat doctest blocks the same as literal blocks.
355
 
  \DNliteralblock{#1}%
356
 
}
357
 
\RequirePackage{hyphenat}
 
428
\providecommand{\DNdoctestblock}[1]{\DNliteralblock{#1}}
358
429
\providecommand{\DNliteral}[1]{\textnhtt{#1}}
359
430
\providecommand{\DNemphasis}[1]{\emph{#1}}
360
431
\providecommand{\DNstrong}[1]{\textbf{#1}}
361
 
\providecommand{\Dvisitdocument}{\begin{document}\noindent}
362
 
\providecommand{\Ddepartdocument}{\end{document}}
 
432
\providecommand{\DECvisitdocument}{\begin{document}\noindent}
 
433
\providecommand{\DECdepartdocument}{\end{document}}
363
434
\providecommand{\DNtopic}[1]{%
364
 
  \ifthenelse{\equal{\DcurrentNtopicAcontents}{1}}{%
 
435
  \ifthenelse{\equal{\DEVcurrentNtopicAcontents}{1}}{%
365
436
    \addtocounter{Dtoclevel}{1}%
366
437
    \par\noindent%
367
438
    #1%
371
442
    \Dmakebox{#1}%
372
443
  }%
373
444
}
 
445
\providecommand{\DNadmonition}[1]{%
 
446
  \DNtopic{#1}%
 
447
}
374
448
\providecommand{\Dformatrubric}[1]{\textbf{#1}}
375
449
\Dprovidelength{\Dprerubricspace}{0.3em}
376
450
\providecommand{\DNrubric}[1]{%
378
452
}
379
453
 
380
454
\providecommand{\Dbullet}{}
381
 
\providecommand{\Dsetbullet}[1]{\renewcommand{\Dbullet}{#1}}
 
455
\providecommand{\DECsetbullet}[1]{\renewcommand{\Dbullet}{#1}}
382
456
\providecommand{\DNbulletlist}[1]{%
383
457
  \Difinsidetoc{%
384
458
    \Dtocbulletlist{#1}%
386
460
    \Dmakelistenvironment{\Dbullet}{}{#1}%
387
461
  }%
388
462
}
 
463
% Todo: So what on earth is @pnumwidth?
389
464
\renewcommand{\@pnumwidth}{2.2em}
390
465
\providecommand{\DNlistitem}[1]{%
391
466
  \Difinsidetoc{%
393
468
      {%
394
469
        \par\addvspace{1em}\noindent%
395
470
        \sectfont%
396
 
        #1\hfill\pageref{\DcurrentNlistitemAtocrefid}%
 
471
        #1\hfill\pageref{\DEVcurrentNlistitemAtocrefid}%
397
472
      }%
398
473
    }{%
399
474
      \@dottedtocline{0}{\Dtocindent}{0em}{#1}{%
400
 
        \pageref{\DcurrentNlistitemAtocrefid}%
 
475
        \pageref{\DEVcurrentNlistitemAtocrefid}%
401
476
      }%
402
477
    }%
403
478
  }{%
405
480
  }%
406
481
}
407
482
\providecommand{\DNenumeratedlist}[1]{#1}
408
 
\newcounter{Dsectionlevel}
 
483
\Dprovidecounter{Dsectionlevel}{0}
409
484
\providecommand{\Dvisitsectionhook}{}
410
485
\providecommand{\Ddepartsectionhook}{}
411
 
\providecommand{\Dvisitsection}{%
 
486
\providecommand{\DECvisitsection}{%
412
487
  \addtocounter{Dsectionlevel}{1}%
413
488
  \Dvisitsectionhook%
414
489
}
415
 
\providecommand{\Ddepartsection}{%
 
490
\providecommand{\DECdepartsection}{%
416
491
  \Ddepartsectionhook%
417
492
  \addtocounter{Dsectionlevel}{-1}%
418
493
}
420
495
% Using \_ will cause hyphenation after _ even in \textnhtt-typewriter
421
496
% because the hyphenat package redefines \_.  So we use
422
497
% \textunderscore here.
423
 
\providecommand{\Dtextunderscore}{\textunderscore}
 
498
\providecommand{\DECtextunderscore}{\textunderscore}
424
499
 
425
500
\providecommand{\Dtextinlineliteralfirstspace}{{ }}
426
501
\providecommand{\Dtextinlineliteralsecondspace}{{~}}
484
559
\providecommand{\DAlastitem}[5]{#5\Dfinalstrut}
485
560
 
486
561
\Dprovidelength{\Ditemsep}{0pt}
487
 
\providecommand{\Dmakeenumeratedlist}[6]{%
 
562
\providecommand{\DECmakeenumeratedlist}[6]{%
488
563
  % Make enumerated list.
489
564
  % Parameters:
490
565
  % - prefix
520
595
% Single quote in literal mode.  \textquotesingle from package
521
596
% textcomp has wrong width when using package ae, so we use a normal
522
597
% single curly quote here.
523
 
\providecommand{\Dtextliteralsinglequote}{'}
 
598
\providecommand{\DECtextliteralsinglequote}{'}
524
599
 
525
600
 
526
601
% "Tabular lists" are field lists and options lists (not definition
677
752
\providecommand{\Dlineblockindentation}{2.5em}
678
753
\providecommand{\DNlineblock}[1]{%
679
754
  \Dmakelistenvironment{}{%
680
 
    \ifthenelse{\equal{\Dparent}{lineblock}}{%
 
755
    \ifthenelse{\equal{\DEVparent}{lineblock}}{%
681
756
      % Parent is a line block, so indent.
682
757
      \setlength{\leftmargin}{\Dlineblockindentation}%
683
758
    }{%
692
767
}
693
768
\providecommand{\DNline}[1]{\item#1}
694
769
 
695
 
 
696
770
\providecommand{\DNtransition}{%
697
771
  \raisebox{0.25em}{\parbox{\linewidth}{\hspace*{\fill}\hrulefill\hrulefill\hspace*{\fill}}}%
698
772
}
699
773
 
700
 
 
701
774
\providecommand{\Dformatblockquote}[1]{%
702
775
  % Format contents of block quote.
703
776
  % This occurs in block-level context, so we cannot use \textsl.
716
789
 
717
790
 
718
791
% Sidebars:
719
 
\RequirePackage{picins}
720
792
% Vertical and horizontal margins.
721
793
\Dprovidelength{\Dsidebarvmargin}{0.5em}
722
794
\Dprovidelength{\Dsidebarhmargin}{1em}
780
852
  % See ltfloat.dtx for details.
781
853
  {%
782
854
    \insert\footins{%
 
855
      % BUG: This is too small if the user adds
 
856
      % \onehalfspacing or \doublespace.
783
857
      \vspace{\Dfootnotesep}%
784
858
      \Dsetfootnotespacing%
785
859
      \Dformatfootnote{#1}%
799
873
}
800
874
\providecommand{\Dthislabel}{}
801
875
\providecommand{\DNlabel}[1]{%
802
 
  \renewcommand{\Dthislabel}{#1}
803
 
  \ifthenelse{\not\equal{\Dsinglebackref}{}}{%
 
876
  % Footnote or citatation label.
 
877
  \renewcommand{\Dthislabel}{#1}%
 
878
  \ifthenelse{\not\equal{\DEVsinglebackref}{}}{%
804
879
    \let\Doriginallabel=\Dthislabel%
805
880
    \def\Dthislabel{%
806
 
      \Dsinglefootnotebacklink{\Dsinglebackref}{\Doriginallabel}%
 
881
      \Dsinglefootnotebacklink{\DEVsinglebackref}{\Doriginallabel}%
807
882
    }%
808
883
  }{}%
809
 
  \ifthenelse{\equal{\Dparent}{footnote}}{%
 
884
  \ifthenelse{\equal{\DEVparent}{footnote}}{%
810
885
    % Footnote label.
811
886
    \Dformatfootnotelabel{\Dthislabel}%
812
887
  }{%
813
 
    \ifthenelse{\equal{\Dparent}{citation}}{%
 
888
    \ifthenelse{\equal{\DEVparent}{citation}}{%
814
889
      % Citation label.
815
890
      \Dformatcitationlabel{\Dthislabel}%
816
891
    }{}%
817
892
  }%
818
893
  % If there are multiple backrefs, add them now.
819
 
  \Dformatmultiplebackrefs{\Dmultiplebackrefs}%
 
894
  \Dformatmultiplebackrefs{\DEVmultiplebackrefs}%
820
895
}
821
896
\providecommand{\Dsinglefootnotebacklink}[2]{%
822
897
  % Create normal backlink of a footnote label.  Parameters:
825
900
  % Treat like a footnote reference.
826
901
  \Dimplicitfootnotereference{\##1}{#2}%
827
902
}
828
 
\providecommand{\Dmultifootnotebacklink}[2]{%
 
903
\providecommand{\DECmultifootnotebacklink}[2]{%
829
904
  % Create generated backlink, as in (1, 2).  Parameters:
830
905
  % 1. ID.
831
906
  % 2. Link text.
833
908
  \Dimplicitfootnotereference{\##1}{#2}%
834
909
}
835
910
\providecommand{\Dsinglecitationbacklink}[2]{\Dsinglefootnotebacklink{#1}{#2}}
836
 
\providecommand{\Dmulticitationbacklink}[2]{\Dmultifootnotebacklink{#1}{#2}}
837
 
 
838
 
 
839
 
\RequirePackage{longtable}
840
 
\providecommand{\Dmaketable}[2]{%
 
911
\providecommand{\DECmulticitationbacklink}[2]{\DECmultifootnotebacklink{#1}{#2}}
 
912
 
 
913
 
 
914
\providecommand{\DECmaketable}[2]{%
841
915
  % Make table.  Parameters:
842
916
  % 1. Table spec (like "|p|p|").
843
917
  % 2. Table contents.
875
949
    }%
876
950
  }%
877
951
}
878
 
\providecommand{\Dcolspan}[2]{%
 
952
\providecommand{\DECcolspan}[2]{%
879
953
  % Take care of the morecols attribute (but incremented by 1).
880
954
  &%
881
955
  \Dcompensatingmulticol{#1}{l|}{#2}%
882
956
}
883
 
\providecommand{\Dcolspanleft}[2]{%
 
957
\providecommand{\DECcolspanleft}[2]{%
884
958
  % Like \Dmorecols, but called for the leftmost entries in a table
885
959
  % row.
886
960
  \Dcompensatingmulticol{#1}{|l|}{#2}%
887
961
}
888
 
\providecommand{\Dsubsequententry}[1]{%
 
962
\providecommand{\DECsubsequententry}[1]{%
889
963
  &#1%
890
964
}
891
965
\providecommand{\DNentry}[1]{%
896
970
    \vspace{-1em}\vspace{-\parskip}\par%
897
971
  }{}%
898
972
  #1%
899
 
  % No need to add an ampersand ("&"); that's done by \Dsubsequententry.
 
973
  % No need to add an ampersand ("&"); that's done by \DECsubsequententry.
900
974
}
901
975
\providecommand{\DAtableheaderentry}[5]{\Dformattableheaderentry{#5}}
902
976
\providecommand{\Dformattableheaderentry}[1]{{\bfseries#1}}
942
1016
}
943
1017
 
944
1018
 
945
 
\RequirePackage{graphicx}
946
1019
% Maximum width of an image.
947
1020
\providecommand{\Dimagemaxwidth}{\linewidth}
948
1021
\providecommand{\Dfloatimagemaxwidth}{0.5\linewidth}
975
1048
  % Insert image.  We treat the URI like a path here.
976
1049
  \renewcommand{\Dimagepath}{\Dimagebase#3}%
977
1050
  \Difdefined{DcurrentNimageAwidth}{%
978
 
    \Dwidthimage{\DcurrentNimageAwidth}{\Dimagepath}%
 
1051
    \Dwidthimage{\DEVcurrentNimageAwidth}{\Dimagepath}%
979
1052
  }{%
980
1053
    \Dsimpleimage{\Dimagepath}%
981
1054
  }%
1020
1093
% Figures.
1021
1094
\providecommand{\DNfigureAalign}[5]{%
1022
1095
  % Hack to make it work Right Now.
1023
 
  %\def\DcurrentNimageAwidth{\DcurrentNfigureAwidth}%
 
1096
  %\def\DEVcurrentNimageAwidth{\DEVcurrentNfigureAwidth}%
1024
1097
  %
1025
 
    %\def\DcurrentNimageAwidth{\linewidth}%
 
1098
    %\def\DEVcurrentNimageAwidth{\linewidth}%
1026
1099
    \DNimageAalign{#1}{#2}{#3}{#4}{%
1027
1100
      \begin{minipage}[b]{0.4\linewidth}#5\end{minipage}}%
1028
 
    %\let\DcurrentNimageAwidth=\relax%
 
1101
    %\let\DEVcurrentNimageAwidth=\relax%
1029
1102
  %
1030
 
  %\let\DcurrentNimageAwidth=\relax%
 
1103
  %\let\DEVcurrentNimageAwidth=\relax%
1031
1104
}
1032
1105
\providecommand{\DNcaption}[1]{\par\noindent{\slshape#1}}
1033
 
\providecommand{\DNlegend}[1]{\Dauxiliaryspace#1}
 
1106
\providecommand{\DNlegend}[1]{\DECauxiliaryspace#1}
1034
1107
 
1035
1108
\providecommand{\DCborder}[1]{\fbox{#1}}
1036
1109
% No padding between image and border.
1039
1112
 
1040
1113
% Need to replace with language-specific stuff.  Maybe look at
1041
1114
% csquotes.sty and ask the author for permission to use parts of it.
1042
 
\providecommand{\Dtextleftdblquote}{``}
1043
 
\providecommand{\Dtextrightdblquote}{''}
 
1115
\providecommand{\DECtextleftdblquote}{``}
 
1116
\providecommand{\DECtextrightdblquote}{''}
1044
1117
 
1045
1118
% Table of contents:
1046
1119
\Dprovidelength{\Dtocininitialsectnumwidth}{2.4em}
1047
1120
\Dprovidelength{\Dtocadditionalsectnumwidth}{0.7em}
1048
1121
% Level inside a table of contents.  While this is at -1, we are not
1049
1122
% inside a TOC.
1050
 
\Dprovidecounter{Dtoclevel}%
1051
 
\setcounter{Dtoclevel}{-1}
 
1123
\Dprovidecounter{Dtoclevel}{-1}%
1052
1124
\providecommand{\Dlocaltoc}{false}%
1053
1125
\providecommand{\DNtopicClocal}[1]{%
1054
1126
  \renewcommand{\Dlocaltoc}{true}%
1088
1160
}
1089
1161
 
1090
1162
 
1091
 
% For \Dpixelunit, the length value is pre-multiplied with 0.75, so by
 
1163
% For \DECpixelunit, the length value is pre-multiplied with 0.75, so by
1092
1164
% specifying "pt" we get the same notion of "pixel" as graphicx.
1093
 
\providecommand{\Dpixelunit}{pt}
 
1165
\providecommand{\DECpixelunit}{pt}
1094
1166
% Normally lengths are relative to the current linewidth.
1095
 
\providecommand{\Drelativeunit}{\linewidth}
1096
 
 
1097
 
 
1098
 
%\RequirePackage{fixmath}
1099
 
%\RequirePackage{amsmath}
1100
 
 
1101
 
 
1102
 
\DSfontencoding
1103
 
\DSlanguage
1104
 
\DSlinks
 
1167
\providecommand{\DECrelativeunit}{\linewidth}
 
1168
 
 
1169
 
 
1170
% ACTION: These commands actually *do* something.
 
1171
% Ultimately, everything should be done here, and no active content should be
 
1172
% above (not even \usepackage).
 
1173
 
 
1174
\DSearly
 
1175
\DSpackages
 
1176
\DSfrenchspacing
1105
1177
\DSsymbols
1106
1178
\DSlate
1107
1179