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
|
%% docutils.sty: macros for Docutils LaTeX output.
%%
%% Copyright © 2020 Günter Milde
%% Released under the terms of the `2-Clause BSD license`, in short:
%%
%% Copying and distribution of this file, with or without modification,
%% are permitted in any medium without royalty provided the copyright
%% notice and this notice are preserved.
%% This file is offered as-is, without any warranty.
% .. include:: README
%
% Implementation
% ==============
%
% ::
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{docutils}
[2020/08/28 v0.17 macros for Docutils LaTeX output]
% Helpers
% -------
%
% duclass::
% class handling for environments (block-level elements)
% \begin{DUclass}{spam} tries \DUCLASSspam and
% \end{DUclass}{spam} tries \endDUCLASSspam
\ifx\DUclass\undefined % poor man's "provideenvironment"
\newenvironment{DUclass}[1]%
{% "#1" does not work in end-part of environment.
\def\DocutilsClassFunctionName{DUCLASS#1}
\csname \DocutilsClassFunctionName \endcsname}%
{\csname end\DocutilsClassFunctionName \endcsname}%
\fi
% providelength::
% Provide a length variable and set default, if it is new
\providecommand*{\DUprovidelength}[2]{
\ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
}
% Configuration defaults
% ----------------------
%
% See `Docutils LaTeX Writer`_ for details.
%
% abstract::
\providecommand*{\DUCLASSabstract}{
\renewcommand{\DUtitle}[1]{\centerline{\textbf{##1}}}
}
% dedication::
% special topic for dedications
\providecommand*{\DUCLASSdedication}{%
\renewenvironment{quote}{\begin{center}}{\end{center}}%
}
% TODO: add \em to set dedication text in italics?
%
% docinfo::
% width of docinfo table
\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
% error::
\providecommand*{\DUCLASSerror}{\color{red}}
% highlight_rules::
% basic code highlight:
\providecommand*\DUrolecomment[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
\providecommand*\DUroledeleted[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
\providecommand*\DUrolekeyword[1]{\textbf{#1}}
\providecommand*\DUrolestring[1]{\textit{#1}}
% Elements
% --------
%
% Definitions for unknown or to-be-configured Docutils elements.
%
% admonition::
% admonition environment (specially marked topic)
\ifx\DUadmonition\undefined % poor man's "provideenvironment"
\newbox{\DUadmonitionbox}
\newenvironment{DUadmonition}%
{\begin{center}
\begin{lrbox}{\DUadmonitionbox}
\begin{minipage}{0.9\linewidth}
}%
{ \end{minipage}
\end{lrbox}
\fbox{\usebox{\DUadmonitionbox}}
\end{center}
}
\fi
% fieldlist::
% field list environment (for separate configuration of `field lists`)
\ifthenelse{\isundefined{\DUfieldlist}}{
\newenvironment{DUfieldlist}%
{\quote\description}
{\enddescription\endquote}
}{}
% footnotes::
% numerical or symbol footnotes with hyperlinks and backlinks
\providecommand*{\DUfootnotemark}[3]{%
\raisebox{1em}{\hypertarget{#1}{}}%
\hyperlink{#2}{\textsuperscript{#3}}%
}
\providecommand{\DUfootnotetext}[4]{%
\begingroup%
\renewcommand{\thefootnote}{%
\protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
\protect\hyperlink{#2}{#3}}%
\footnotetext{#4}%
\endgroup%
}
% inline::
% custom inline roles: \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
\ifcsname DUrole#1\endcsname%
\csname DUrole#1\endcsname{#2}%
\else%
#2%
\fi%
}
% legend::
% legend environment (in figures and formal tables)
\ifthenelse{\isundefined{\DUlegend}}{
\newenvironment{DUlegend}{\small}{}
}{}
% lineblock::
% line block environment
\DUprovidelength{\DUlineblockindent}{2.5em}
\ifthenelse{\isundefined{\DUlineblock}}{
\newenvironment{DUlineblock}[1]{%
\list{}{\setlength{\partopsep}{\parskip}
\addtolength{\partopsep}{\baselineskip}
\setlength{\topsep}{0pt}
\setlength{\itemsep}{0.15\baselineskip}
\setlength{\parsep}{0pt}
\setlength{\leftmargin}{#1}}
\raggedright
}
{\endlist}
}{}
% optionlist::
% list of command line options
\providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
\DUprovidelength{\DUoptionlistindent}{3cm}
\ifthenelse{\isundefined{\DUoptionlist}}{
\newenvironment{DUoptionlist}{%
\list{}{\setlength{\labelwidth}{\DUoptionlistindent}
\setlength{\rightmargin}{1cm}
\setlength{\leftmargin}{\rightmargin}
\addtolength{\leftmargin}{\labelwidth}
\addtolength{\leftmargin}{\labelsep}
\renewcommand{\makelabel}{\DUoptionlistlabel}}
}
{\endlist}
}{}
% rubric::
% informal heading
\providecommand*{\DUrubric}[1]{\subsubsection*{\emph{#1}}}
% sidebar::
% text outside the main text flow
\providecommand{\DUsidebar}[1]{%
\begin{center}
\colorbox[gray]{0.80}{\parbox{0.9\linewidth}{#1}}
\end{center}
}
% title::
% title for topics, admonitions, unsupported section levels, and sidebar
\providecommand*{\DUtitle}[1]{\subsubsection*{#1}}
% subtitle::
% subtitle (for sidebar)
\providecommand*{\DUsubtitle}[1]{\par\emph{#1}\smallskip}
% documentsubtitle::
% subtitle (in document title)
\providecommand*{\DUdocumentsubtitle}[1]{{\large #1}}
% titlereference::
% titlereference standard role
\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
% transition::
% transition (break / fancybreak / anonymous section)
\providecommand*{\DUtransition}{%
\hspace*{\fill}\hrulefill\hspace*{\fill}
\vskip 0.5\baselineskip
}
|