Debian Codegraph @

test/functional/expected/standalone_rst_latex.tex

raw
1 \documentclass[a4paper]{article}
2 % generated by Docutils <https://docutils.sourceforge.io/>
3 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
4 \usepackage[T1]{fontenc}
5 \usepackage{alltt}
6 \usepackage{amsmath}
7 \usepackage[british,french,ngerman,main=english]{babel}
8 % Prevent side-effects if French hyphenation patterns are not loaded:
9 \frenchbsetup{StandardLayout}
10 \AtBeginDocument{\selectlanguage{english}\noextrasfrench}
11 \usepackage{color}
12 \usepackage{float} % extended float configuration
13 \floatplacement{figure}{H} % place figures here definitely
14 \usepackage{graphicx}
15 \usepackage{multirow}
16 \usepackage{pifont}
17 \setcounter{secnumdepth}{0}
18 \usepackage{longtable,ltcaption,array}
19 \setlength{\extrarowheight}{2pt}
20 \newlength{\DUtablewidth} % internal use in tables
21 \usepackage{tabularx}
22
23 %%% Custom LaTeX preamble
24 % PDF Standard Fonts
25 \usepackage{mathptmx} % Times
26 \usepackage[scaled=.90]{helvet}
27 \usepackage{courier}
28
29 %%% User specified packages and stylesheets
30
31 %%% Fallback definitions for Docutils-specific commands
32
33 % class handling for environments (block-level elements)
34 % \begin{DUclass}{spam} tries \DUCLASSspam and
35 % \end{DUclass}{spam} tries \endDUCLASSspam
36 \ifdefined\DUclass
37 \else % poor man's "provideenvironment"
38 \newenvironment{DUclass}[1]%
39 {% "#1" does not work in end-part of environment.
40 \def\DocutilsClassFunctionName{DUCLASS#1}
41 \csname \DocutilsClassFunctionName \endcsname}%
42 {\csname end\DocutilsClassFunctionName \endcsname}%
43 \fi
44
45 % Provide a length variable and set default, if it is new
46 \providecommand*{\DUprovidelength}[2]{%
47 \ifdefined#1
48 \else
49 \newlength{#1}\setlength{#1}{#2}%
50 \fi
51 }
52
53 \providecommand*{\DUCLASSabstract}{
54 \renewcommand{\DUtitle}[1]{\centerline{\textbf{##1}}}
55 }
56
57 % admonition environment (specially marked topic)
58 \ifdefined\DUadmonition
59 \else % poor man's "provideenvironment"
60 \newbox{\DUadmonitionbox}
61 \newenvironment{DUadmonition}%
62 {\begin{center}
63 \begin{lrbox}{\DUadmonitionbox}
64 \begin{minipage}{0.9\linewidth}
65 }%
66 { \end{minipage}
67 \end{lrbox}
68 \fbox{\usebox{\DUadmonitionbox}}
69 \end{center}
70 }
71 \fi
72
73 % special topic for dedications
74 \providecommand*{\DUCLASSdedication}{%
75 \renewenvironment{quote}{\begin{center}}{\end{center}}%
76 }
77
78 % width of docinfo table
79 \DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
80
81 % subtitle (in document title)
82 \providecommand*{\DUdocumentsubtitle}[1]{{\large #1}}
83 \newcounter{enumv}
84
85 \providecommand*{\DUCLASSerror}{\color{red}}
86
87 % field list environment (for separate configuration of `field lists`)
88 \ifdefined\DUfieldlist
89 \else
90 \newenvironment{DUfieldlist}%
91 {\quote\description}
92 {\enddescription\endquote}
93 \fi
94
95 % numbered or symbol footnotes with hyperlinks and backlinks
96 \providecommand*{\DUfootnotemark}[3]{%
97 \raisebox{1em}{\hypertarget{#1}{}}%
98 \hyperref[#2]{\textsuperscript{#3}}%
99 }
100 \providecommand{\DUfootnotetext}[4]{%
101 \begingroup%
102 \renewcommand{\thefootnote}{%
103 \protect\phantomsection\protect\label{#1}
104 \protect\hyperlink{#2}{#3}}%
105 \footnotetext{#4}%
106 \endgroup%
107 }
108
109 % custom inline roles: \DUrole{#1}{#2} tries \DUrole#1{#2}
110 \providecommand*{\DUrole}[2]{%
111 \ifcsname DUrole#1\endcsname%
112 \csname DUrole#1\endcsname{#2}%
113 \else%
114 #2%
115 \fi%
116 }
117
118 % legend environment (in figures and formal tables)
119 \ifdefined\DUlegend
120 \else
121 \newenvironment{DUlegend}{\small}{}
122 \fi
123
124 % line block environment
125 \DUprovidelength{\DUlineblockindent}{2.5em}
126 \ifdefined\DUlineblock
127 \else
128 \newenvironment{DUlineblock}[1]{%
129 \list{}{\setlength{\partopsep}{\parskip}
130 \addtolength{\partopsep}{\baselineskip}
131 \setlength{\topsep}{0pt}
132 \setlength{\itemsep}{0.15\baselineskip}
133 \setlength{\parsep}{0pt}
134 \setlength{\leftmargin}{#1}}
135 \raggedright
136 }
137 {\endlist}
138 \fi
139
140 % list of command line options
141 \providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
142 \DUprovidelength{\DUoptionlistindent}{3cm}
143 \ifdefined\DUoptionlist
144 \else
145 \newenvironment{DUoptionlist}{%
146 \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
147 \setlength{\rightmargin}{1cm}
148 \setlength{\leftmargin}{\rightmargin}
149 \addtolength{\leftmargin}{\labelwidth}
150 \addtolength{\leftmargin}{\labelsep}
151 \renewcommand{\makelabel}{\DUoptionlistlabel}}
152 }
153 {\endlist}
154 \fi
155
156 % informal heading
157 \providecommand*{\DUrubric}[1]{\subsubsection*{\emph{#1}}}
158
159 % text outside the main text flow
160 \providecommand{\DUsidebar}[1]{%
161 \begin{center}
162 \colorbox[gray]{0.80}{\parbox{0.9\linewidth}{#1}}
163 \end{center}
164 }
165
166 % subtitle (for sidebar)
167 \providecommand*{\DUsubtitle}[1]{\par\emph{#1}\smallskip}
168
169 % title for topics, admonitions, unsupported section levels, and sidebar
170 \providecommand*{\DUtitle}[1]{%
171 \smallskip\noindent\textbf{#1}\smallskip}
172
173 % titlereference standard role
174 \providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
175
176 % transition (break / fancybreak / anonymous section)
177 \providecommand*{\DUtransition}{%
178 \hspace*{\fill}\hrulefill\hspace*{\fill}
179 \vskip 0.5\baselineskip
180 }
181
182 % hyperlinks:
183 \ifdefined\hypersetup
184 \else
185 \usepackage[hyperfootnotes=false,
186 colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
187 \usepackage{bookmark}
188 \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
189 \fi
190 \hypersetup{
191 pdftitle={reStructuredText Test Document},
192 pdfkeywords={reStructuredText, test, parser},
193 pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
194 pdfauthor={David Goodger; Me; Myself; I}
195 }
196
197 %%% Body
198 \begin{document}
199 \title{reStructuredText Test Document%
200 \label{doctitle}%
201 \\%
202 \DUdocumentsubtitle{Examples of Syntax Constructs}%
203 \label{subtitle}}
204 \author{}
205 \date{}
206 \maketitle
207
208 % Docinfo
209 \begin{center}
210 \begin{tabularx}{\DUdocinfowidth}{lX}
211 \textbf{Author}: & David Goodger \\
212 \textbf{Address}: & {\raggedright
213 123 Example Street\\
214 Example, EX Canada\\
215 A1B 2C3} \\
216 \textbf{Contact}: & \href{mailto:[email protected]}{[email protected]} \\
217 \textbf{Authors}: & Me, Myself, I \\
218 \textbf{Organization}: & humankind \\
219 \textbf{Date}: & Now, or yesterday. Or maybe even \emph{before} yesterday. \\
220 \textbf{Status}: & This is a “work in progress” \\
221 \textbf{Revision}: & is managed by a version control system. \\
222 \textbf{Version}: & 1 \\
223 \textbf{Copyright}: &
224 This document has been placed in the public domain. You
225 may do with it as you wish. You may copy, modify,
226 redistribute, reattribute, sell, buy, rent, lease,
227 destroy, or improve it, quote it at length, excerpt,
228 incorporate, collate, fold, staple, or mutilate it, or do
229 anything else to it that your or anyone else’s heart
230 desires. \\
231 \textbf{field name}: &
232 This is a “generic bibliographic field”.
233 \\
234 \textbf{field name “2”}: &
235 Generic bibliographic fields may contain multiple body elements.
236
237 Like this.
238 \\
239 \end{tabularx}
240 \end{center}
241
242 \begin{DUclass}{dedication}
243 \begin{quote}
244 \DUtitle{Dedication}
245
246 For Docutils users \& co-developers.
247 \end{quote}
248 \end{DUclass}
249
250 \begin{DUclass}{abstract}
251 \begin{quote}
252 \DUtitle{Abstract}
253
254 This is a test document, containing at least one example of each
255 reStructuredText construct.
256 \end{quote}
257 \end{DUclass}
258
259 % This is a comment. Note how any initial comments are moved by
260 % transforms to after the document title, subtitle, and docinfo.
261
262 % Above is the document title, and below is the subtitle.
263 % They are transformed from section titles after parsing.
264
265 % bibliographic fields (which also require a transform):
266
267 \pagebreak[4] % start ToC on new page
268
269 \phantomsection\label{table-of-contents}
270 \pdfbookmark[1]{Table of Contents}{table-of-contents}
271 \renewcommand{\contentsname}{Table of Contents}
272 \tableofcontents
273
274
275 \section{1   Structural Elements}
276
277
278 \subsection{1.1   Section Title%
279 \label{section-title}%
280 }
281 \subsubsection*{Section Subtitle}
282
283 Lone subsections are converted to a section subtitle by a transform
284 activated with the \texttt{-{}-section-subtitles} command line option or the
285 \texttt{sectsubtitle-xform} configuration value.
286
287
288 \subsection{1.2   Empty Section}
289
290
291 \subsection{1.3   Transitions}
292
293 Here’s a transition:
294
295 %___________________________________________________________________________
296 \DUtransition
297
298 It divides the section. Transitions may also occur between sections:
299
300 %___________________________________________________________________________
301 \DUtransition
302
303
304 \section{2   Body Elements%
305 \label{body-elements}%
306 }
307
308
309 \subsection{2.1   Paragraphs}
310
311 A paragraph.
312
313
314 \subsubsection{2.1.1   Inline Markup%
315 \label{inline-markup}%
316 }
317
318 Paragraphs contain text and may contain inline markup: \emph{emphasis},
319 \textbf{strong emphasis}, \texttt{inline literals}, standalone hyperlinks
320 (\url{http://www.python.org}), external hyperlinks (\href{http://www.python.org/}{Python}\DUfootnotemark{footnote-reference-10}{footnote-6}{5}), internal
321 cross-references (\hyperref[example]{example}), external hyperlinks with embedded URIs
322 (\href{http://www.python.org}{Python web site}), \href{http://www.python.org/}{anonymous hyperlink
323 references}\DUfootnotemark{footnote-reference-16}{footnote-6}{5} (\href{https://docutils.sourceforge.io/}{a second reference}\DUfootnotemark{footnote-reference-17}{footnote-9}{8}), footnote references (manually
324 numbered\DUfootnotemark{footnote-reference-1}{footnote-1}{1}, anonymous auto-numbered\DUfootnotemark{footnote-reference-2}{footnote-2}{3}, labeled auto-numbered\DUfootnotemark{footnote-reference-3}{label}{2}, or symbolic\DUfootnotemark{footnote-reference-4}{footnote-3}{*}), citation references (see \hyperlink{cit2002}{[CIT2002]}),
325 substitution references (\includegraphics{../../../docs/user/rst/images/biohazard.png} \&
326 a \emph{trimmed heart} \texttt{(U+2665):}\ding{170}), and %
327 \phantomsection\label{inline-hyperlink-targets}inline hyperlink targets
328 (see \hyperref[targets]{Targets} below for a reference back to here). Character-level
329 inline markup is also possible (although exceedingly ugly!) in \emph{re}\texttt{Structured}\emph{Text}. Problems are indicated by %
330 \raisebox{1em}{\hypertarget{problematic-1}{}}\hyperlink{system-message-1}{\textbf{\color{red}|problematic|}} text
331 (generated by processing errors; this one is intentional). Here is a
332 reference to the \hyperref[doctitle]{doctitle} and the \hyperref[subtitle]{subtitle}.
333
334 The default role for interpreted text is \DUroletitlereference{Title Reference}. Here are
335 some explicit interpreted text roles: a PEP reference (\href{https://peps.python.org/pep-0287}{PEP 287}); an
336 RFC reference (\href{https://tools.ietf.org/html/rfc2822.html}{RFC 2822}); an abbreviation (\DUrole{abbreviation}{abb.}), an acronym
337 (\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print \textquotedbl{}hello world\textquotedbl{}}}); a \textsubscript{subscript};
338 a \textsuperscript{superscript} and explicit roles for \DUroletitlereference{Docutils}’
339 \emph{standard} \textbf{inline} \texttt{markup}.
340
341 % DO NOT RE-WRAP THE FOLLOWING PARAGRAPH!
342
343 Let’s test wrapping and whitespace significance in inline literals:
344 \texttt{This is an example of -{}-inline-literal -{}-text, -{}-including some-{}-
345 strangely-{}-hyphenated-words. ~Adjust-the-width-of-your-browser-window
346 to see how the text is wrapped. ~-{}- -{}-{}-{}- -{}-{}-{}-{}-{}-{}-{}- ~Now note ~ ~the
347 spacing ~ ~between the ~ ~words of ~ ~this sentence ~ ~(words
348 should ~ ~be grouped ~ ~in pairs).}
349
350 If the \texttt{-{}-pep-references} option was supplied, there should be a
351 live link to PEP 258 here.
352
353
354 \subsection{2.2   Bullet Lists}
355
356 \begin{itemize}
357 \item A bullet list
358
359 \begin{itemize}
360 \item Nested bullet list.
361
362 \item Nested item 2.
363 \end{itemize}
364
365 \item Item 2.
366
367 Paragraph 2 of item 2.
368
369 \begin{itemize}
370 \item Nested bullet list.
371
372 \item Nested item 2.
373
374 \begin{itemize}
375 \item Third level.
376
377 \item Item 2.
378 \end{itemize}
379
380 \item Nested item 3.
381
382 \item This nested list should be compacted by the HTML writer.
383
384 \phantomsection\label{target}
385 % Even if this item contains a target and a comment.
386 \end{itemize}
387 \end{itemize}
388
389
390 \subsection{2.3   Enumerated Lists}
391
392 \begin{enumerate}
393 \item Arabic numerals.
394
395 \begin{enumerate}
396 \renewcommand{\labelenumii}{\alph{enumii})}
397 \item lower alpha)
398
399 \begin{enumerate}
400 \renewcommand{\labelenumiii}{(\roman{enumiii})}
401 \item (lower roman)
402
403 \begin{enumerate}
404 \item upper alpha.
405
406 \begin{list}{\Roman{enumv})}{\usecounter{enumv}}
407 \item upper roman)
408 \end{list}
409 \end{enumerate}
410 \end{enumerate}
411 \end{enumerate}
412
413 \item Lists that don’t start at 1:
414
415 \begin{enumerate}
416 \renewcommand{\labelenumii}{\arabic{enumii}.}
417 \setcounter{enumii}{2}
418 \item Three
419
420 \item Four
421 \end{enumerate}
422
423 \begin{enumerate}
424 \renewcommand{\labelenumii}{\Alph{enumii}.}
425 \setcounter{enumii}{2}
426 \item C
427
428 \item D
429 \end{enumerate}
430
431 \begin{enumerate}
432 \renewcommand{\labelenumii}{\roman{enumii}.}
433 \setcounter{enumii}{2}
434 \item iii
435
436 \item iv
437 \end{enumerate}
438 \end{enumerate}
439
440
441 \subsection{2.4   Definition Lists}
442
443 \begin{description}
444 \item[{Term}]
445 Definition
446
447 \item[{Term}] (\textbf{classifier})
448 Definition paragraph 1.
449
450 Definition paragraph 2.
451
452 \item[{Term}]
453 Definition
454
455 \item[{Term}] (\textbf{classifier one})(\textbf{classifier two})
456 Definition
457 \end{description}
458
459
460 \subsection{2.5   Field Lists}
461
462 \begin{DUfieldlist}
463 \item[{what:}]
464 Field lists map field names to field bodies, like database
465 records. They are often part of an extension syntax. They are
466 an unambiguous variant of RFC 2822 fields.
467
468 \item[{how arg1 arg2:}]
469 The field marker is a colon, the field name, and a colon.
470
471 The field body may contain one or more body elements, indented
472 relative to the field marker.
473
474 \item[{credits:}]
475 \DUrole{credits}{This paragraph has the \DUroletitlereference{credits} class set. (This is actually not
476 about credits but just for ensuring that the class attribute
477 doesn’t get stripped away.)}
478 \end{DUfieldlist}
479
480
481 \subsection{2.6   Option Lists}
482
483 For listing command-line options:
484
485 \begin{DUoptionlist}
486 \item[-a] command-line option “a”
487 \item[-b file] options can have arguments
488 and long descriptions
489 \item[-{}-long] options can be long, too
490 \item[-{}-input=file] long options can also have arguments
491 \item[/V] DOS/VMS-style option
492 \item[-{}-very-long-option] The description can also start on the next line.
493
494 The description may contain multiple body elements,
495 regardless of where it starts.
496 \item[-x, -y, -z] Multiple options are an “option group”.
497 \item[-v, -{}-verbose] Commonly-seen: short \& long options.
498 \item[-1 file, -{}-one=file, -{}-two file] Multiple options with arguments.
499 \item[-f <{[}path{]}file>] Option argumens must start with a letter
500 or be wrapped in angle brackets.
501 \item[-d <src dest>] Angle brackets are also required if an
502 option expects more than one argument.
503 \end{DUoptionlist}
504
505 There must be at least two spaces between the option and the
506 description.
507
508
509 \subsection{2.7   Literal Blocks}
510
511 Literal blocks are indicated with a double-colon (“::”) at the end of
512 the preceding paragraph (over there \texttt{-{}->}). They can be indented:
513
514 \begin{quote}
515 \begin{alltt}
516 if literal_block:
517 text = 'is left as-is'
518 spaces_and_linebreaks = 'are preserved'
519 markup_processing = None
520 \end{alltt}
521 \end{quote}
522
523 Or they can be quoted without indentation:
524
525 \begin{quote}
526 \begin{alltt}
527 >> Great idea!
528 >
529 > Why didn't I think of that?
530 \end{alltt}
531 \end{quote}
532
533
534 \subsection{2.8   Line Blocks}
535
536 This section tests line blocks. Line blocks are body elements which
537 consist of lines and other line blocks. Nested line blocks cause
538 indentation.
539
540 \begin{DUlineblock}{0em}
541 \item[] This is a line block. It ends with a blank line.
542 \item[]
543 \begin{DUlineblock}{\DUlineblockindent}
544 \item[] New lines begin with a vertical bar (“|”).
545 \item[] Line breaks and initial indent are significant, and preserved.
546 \item[]
547 \begin{DUlineblock}{\DUlineblockindent}
548 \item[] Continuation lines are also possible. A long line that is intended
549 to wrap should begin with a space in place of the vertical bar.
550 \end{DUlineblock}
551 \item[] The left edge of a continuation line need not be aligned with
552 the left edge of the text above it.
553 \end{DUlineblock}
554 \end{DUlineblock}
555
556 \begin{DUlineblock}{0em}
557 \item[] This is a second line block.
558 \item[]
559 \item[] Blank lines are permitted internally, but they must begin with a “|”.
560 \end{DUlineblock}
561
562 Another line block, surrounded by paragraphs:
563
564 \begin{DUlineblock}{0em}
565 \item[] And it’s no good waiting by the window
566 \item[] It’s no good waiting for the sun
567 \item[] Please believe me, the things you dream of
568 \item[] They don’t fall in the lap of no-one
569 \end{DUlineblock}
570
571 Take it away, Eric the Orchestra Leader!
572
573 \begin{quote}
574 \begin{DUlineblock}{0em}
575 \item[] A one, two, a one two three four
576 \item[]
577 \item[] Half a bee, philosophically,
578 \item[]
579 \begin{DUlineblock}{\DUlineblockindent}
580 \item[] must, \emph{ipso facto}, half not be.
581 \end{DUlineblock}
582 \item[] But half the bee has got to be,
583 \item[]
584 \begin{DUlineblock}{\DUlineblockindent}
585 \item[] \emph{vis a vis} its entity. D’you see?
586 \item[]
587 \end{DUlineblock}
588 \item[] But can a bee be said to be
589 \item[]
590 \begin{DUlineblock}{\DUlineblockindent}
591 \item[] or not to be an entire bee,
592 \item[]
593 \begin{DUlineblock}{\DUlineblockindent}
594 \item[] when half the bee is not a bee,
595 \item[]
596 \begin{DUlineblock}{\DUlineblockindent}
597 \item[] due to some ancient injury?
598 \item[]
599 \end{DUlineblock}
600 \end{DUlineblock}
601 \end{DUlineblock}
602 \item[] Singing…
603 \end{DUlineblock}
604 \end{quote}
605
606 A line block, like the following poem by Christian Morgenstern, can
607 also be centre-aligned:
608
609 \begin{selectlanguage}{ngerman}
610 \begin{DUlineblock}{0em}
611 \centering
612 \item[] \textbf{Die Trichter}
613 \item[]
614 \item[] Zwei Trichter wandeln durch die Nacht.
615 \item[] Durch ihres Rumpfs verengten Schacht
616 \item[] fließt weißes Mondlicht
617 \item[] still und heiter
618 \item[] auf   ihren
619 \item[] Waldweg
620 \item[] u. s.
621 \item[] w.
622 \item[]
623 \end{DUlineblock}
624 \end{selectlanguage}
625
626
627 \subsection{2.9   Block Quotes}
628
629 Block quotes consist of indented body elements:
630
631 \begin{quote}
632 My theory by A. Elk. Brackets Miss, brackets. This theory goes
633 as follows and begins now. All brontosauruses are thin at one
634 end, much much thicker in the middle and then thin again at the
635 far end. That is my theory, it is mine, and belongs to me and I
636 own it, and what it is too.
637 \nopagebreak
638
639 \raggedleft —Anne Elk (Miss)
640 \end{quote}
641
642 The language of a quote (like any other object) can be specified by
643 a class attribute:
644
645 %
646
647 \begin{selectlanguage}{french}
648 \begin{quote}
649 ReStructuredText est un langage de balisage léger utilisé
650 notamment dans la documentation du langage Python.
651 \end{quote}
652 \end{selectlanguage}
653
654
655 \subsection{2.10   Doctest Blocks}
656
657 \begin{quote}
658 \begin{alltt}
659 >>> print 'Python-specific usage examples; begun with ">>>"'
660 Python-specific usage examples; begun with ">>>"
661 >>> print '(cut and pasted from interactive Python sessions)'
662 (cut and pasted from interactive Python sessions)
663 \end{alltt}
664 \end{quote}
665
666
667 \subsection{2.11   Footnotes}
668 %
669 \DUfootnotetext{footnote-1}{footnote-reference-1}{1}{%
670 A footnote contains body elements, consistently indented by at
671 least 1 space.
672
673 This is the footnote’s second paragraph.
674 }
675 %
676 \DUfootnotetext{label}{footnote-reference-3}{2}{%
677 Footnotes may be numbered, either manually (as in\DUfootnotemark{footnote-reference-5}{footnote-1}{1}) or
678 automatically using a “\#”-prefixed label. This footnote has a
679 label so it can be referred to from multiple places, both as a
680 footnote reference (\DUfootnotemark{footnote-reference-6}{label}{2}) and as a \hyperref[label]{hyperlink reference}.
681 }
682 %
683 \DUfootnotetext{footnote-2}{footnote-reference-2}{3}{%
684 This footnote is numbered automatically and anonymously using a
685 label of “\#” only.
686
687 This is the second paragraph.
688
689 And this is the third paragraph.
690 }
691 %
692 \DUfootnotetext{footnote-3}{footnote-reference-4}{*}{%
693 Footnotes may also use symbols, specified with a “*” label.
694 Here’s a reference to the next footnote:\DUfootnotemark{footnote-reference-7}{footnote-4}{†}.
695 }
696 %
697 \DUfootnotetext{footnote-4}{footnote-reference-7}{†}{%
698 This footnote shows the next symbol in the sequence.
699 }
700 %
701 \DUfootnotetext{footnote-5}{}{4}{%
702 Here’s an unreferenced footnote, with a reference to a
703 nonexistent footnote:%
704 \raisebox{1em}{\hypertarget{footnote-reference-8}{}}\hyperlink{system-message-2}{\textbf{\color{red}{[}5{]}\_}}.
705 }
706
707
708 \subsection{2.12   Citations}
709 \begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002]
710 Citations are text-labeled footnotes. They may be
711 rendered separately and differently from footnotes.
712 \end{figure}
713
714 Here’s a reference to the above, \hyperlink{cit2002}{[CIT2002]}, and a %
715 \raisebox{1em}{\hypertarget{citation-reference-3}{}}\hyperlink{system-message-3}{\textbf{\color{red}{[}nonexistent{]}\_}}
716 citation.
717
718
719 \subsection{2.13   Targets%
720 \label{targets}%
721 \label{another-target}%
722 }
723
724 \phantomsection\label{example}
725 This paragraph is pointed to by the explicit “example” target. A
726 reference can be found under \hyperref[inline-markup]{Inline Markup}, above. \hyperref[inline-hyperlink-targets]{Inline
727 hyperlink targets} are also possible.
728
729 Section headers are implicit targets, referred to by name. See
730 \hyperref[targets]{Targets}, which is a subsection of \hyperref[body-elements]{Body Elements}.
731
732 Explicit external targets are interpolated into references such as
733 “\href{http://www.python.org/}{Python}\DUfootnotemark{footnote-reference-11}{footnote-6}{5}”.
734
735 Targets may be indirect and anonymous. Thus \hyperref[targets]{this phrase} may also
736 refer to the \hyperref[targets]{Targets} section.
737
738 Here’s a %
739 \raisebox{1em}{\hypertarget{problematic-2}{}}\hyperlink{system-message-4}{\textbf{\color{red}`hyperlink reference without a target`\_}}, which generates an
740 error.
741
742
743 \subsubsection{2.13.1   Duplicate Target Names}
744
745 Duplicate names in section headers or other implicit targets will
746 generate “info” (level-1) system messages. Duplicate names in
747 explicit targets will generate “warning” (level-2) system messages.
748
749
750 \subsubsection{2.13.2   Duplicate Target Names}
751
752 Since there are two “Duplicate Target Names” section headers, we
753 cannot uniquely refer to either of them by name. If we try to (like
754 this: %
755 \raisebox{1em}{\hypertarget{problematic-3}{}}\hyperlink{system-message-5}{\textbf{\color{red}`Duplicate Target Names`\_}}), an error is generated.
756
757
758 \subsection{2.14   Directives%
759 \label{directives}%
760 }
761
762 These are just a sample of the many reStructuredText Directives. For
763 others, please see \href{https://docutils.sourceforge.io/docs/ref/rst/directives.html}{reStructuredText Directives}\DUfootnotemark{footnote-reference-18}{footnote-10}{9}.
764
765
766 \subsubsection{2.14.1   Document Parts}
767
768 An example of the “contents” directive can be seen above this section
769 (a local, untitled table of \hyperref[contents]{contents}) and at the beginning of the
770 document (a document-wide \hyperref[table-of-contents]{table of contents}).
771
772
773 \subsubsection{2.14.2   Images and Figures}
774
775 An image directive (also clickable – a hyperlink reference):
776
777 \hyperref[directives]{\includegraphics[width=0.7\linewidth]{../../../docs/user/rst/images/title.png}}
778
779 Image with multiple IDs:
780
781 \phantomsection\label{image-target-3}\label{image-target-2}\label{image-target-1}
782 \includegraphics{../../../docs/user/rst/images/biohazard.png}
783
784 A centered image:
785
786 \noindent\makebox[\linewidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}}
787
788 A left-aligned image:
789
790 \noindent{\includegraphics{../../../docs/user/rst/images/biohazard.png}\hfill}
791
792 This paragraph might flow around the image.
793 The specific behavior depends upon the style sheet and
794 the browser or rendering software used.
795
796 A right-aligned image:
797
798 \noindent{\hfill\includegraphics{../../../docs/user/rst/images/biohazard.png}}
799
800 This paragraph might flow around the image.
801 The specific behavior depends upon the style sheet and
802 the browser or rendering software used.
803
804 For inline images see \hyperref[substitution-definitions]{Substitution Definitions}.
805
806 Image size:
807
808 An image 2 em wide:
809
810 \includegraphics[width=2em]{../../../docs/user/rst/images/biohazard.png}
811
812 An image 2 cm wide and 15 pixel high:
813
814 \includegraphics[height=15px,width=2cm]{../../../docs/user/rst/images/biohazard.png}
815
816 Relative units allow adaption of the image to the screen or paper size.
817 An image occupying 50\% of the line width:
818
819 \includegraphics[width=0.5\linewidth]{../../../docs/user/rst/images/title.png}
820
821 A \emph{figure} is an image with a caption and/or a legend. With page-based output
822 media, figures might float to a different position if this helps the page
823 layout.
824
825 \begin{DUclass}{figclass1}
826 \begin{DUclass}{figclass2}
827 \begin{figure}
828 \noindent\makebox[\linewidth][c]{\href{https://docutils.sourceforge.io/rst.html}{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}}
829 \caption{Plaintext markup syntax and parser system.}
830 \begin{DUlegend}
831 \setlength{\DUtablewidth}{\linewidth}%
832 \begin{longtable*}{|p{0.156\DUtablewidth}|p{0.563\DUtablewidth}|}
833 \hline
834
835 re
836 &
837 Revised, revisited, based on ‘re’ module.
838 \\
839 \hline
840
841 Structured
842 &
843 Structure-enhanced text, structuredtext.
844 \\
845 \hline
846
847 Text
848 &
849 Well it is, isn’t it?
850 \\
851 \hline
852 \end{longtable*}
853
854 This paragraph is also part of the legend.
855 \end{DUlegend}
856 \end{figure}
857 \end{DUclass}
858 \end{DUclass}
859
860 A left-aligned figure, 70\% wide:
861
862 \begin{DUclass}{figclass1}
863 \begin{DUclass}{figclass2}
864 \begin{figure} % align = "left"
865 \noindent\makebox[\linewidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}}
866 \caption{\label{caption-label}\DUrole{captionclass1}{\DUrole{captionclass2}{This is the caption.}}}
867 \begin{DUlegend}
868 This is the legend.
869
870 The legend may consist of several paragraphs.
871 \end{DUlegend}
872 \end{figure}
873 \end{DUclass}
874 \end{DUclass}
875
876 This paragraph might flow around the figure.
877
878 The specific behavior depends upon the style sheet and the browser or
879 rendering software used.
880
881 A centred figure, 40\% wide:
882
883 \begin{figure}
884 \noindent\makebox[\linewidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}}
885 \caption{This is the caption.}
886 \begin{DUlegend}
887 This is the legend.
888
889 The legend may consist of several paragraphs.
890 \end{DUlegend}
891 \end{figure}
892
893 This paragraph might flow around the figure.
894
895 The specific behavior depends upon the style sheet and the browser or
896 rendering software used.
897
898 A right-aligned figure:
899
900 \begin{figure} % align = "right"
901 \noindent\makebox[\linewidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}}
902 \caption{This is the caption.}
903 \begin{DUlegend}
904 This is the legend.
905
906 The legend may consist of several paragraphs.
907 \end{DUlegend}
908 \end{figure}
909
910 This paragraph might flow around the figure. The specific behavior depends
911 upon the style sheet and the browser or rendering software used.
912
913
914 \subsubsection{2.14.3   Tables}
915
916 Tables may be given titles and additional arguments with the \emph{table}
917 directive:
918
919 \setlength{\DUtablewidth}{\linewidth}%
920 \begin{longtable}[l]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
921 \caption{left-aligned table}\\
922 \hline
923 \textbf{%
924 A
925 } & \textbf{%
926 not A
927 } \\
928 \hline
929 \endfirsthead
930 \caption[]{left-aligned table (... continued)}\\
931 \hline
932 \textbf{%
933 A
934 } & \textbf{%
935 not A
936 } \\
937 \hline
938 \endhead
939 \multicolumn{2}{p{0.15\DUtablewidth}}{\raggedleft\ldots continued on next page}\\
940 \endfoot
941 \endlastfoot
942
943 False
944 &
945 True
946 \\
947 \hline
948
949 True
950 &
951 False
952 \\
953 \hline
954 \end{longtable}
955
956 \setlength{\DUtablewidth}{\linewidth}%
957 \begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
958 \caption{center-aligned table}\\
959 \hline
960 \textbf{%
961 A
962 } & \textbf{%
963 not A
964 } \\
965 \hline
966 \endfirsthead
967 \caption[]{center-aligned table (... continued)}\\
968 \hline
969 \textbf{%
970 A
971 } & \textbf{%
972 not A
973 } \\
974 \hline
975 \endhead
976 \multicolumn{2}{p{0.15\DUtablewidth}}{\raggedleft\ldots continued on next page}\\
977 \endfoot
978 \endlastfoot
979
980 False
981 &
982 True
983 \\
984 \hline
985
986 True
987 &
988 False
989 \\
990 \hline
991 \end{longtable}
992
993 \setlength{\DUtablewidth}{\linewidth}%
994 \begin{longtable}[r]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
995 \caption{right-aligned table}\\
996 \hline
997 \textbf{%
998 A
999 } & \textbf{%
1000 not A
1001 } \\
1002 \hline
1003 \endfirsthead
1004 \caption[]{right-aligned table (... continued)}\\
1005 \hline
1006 \textbf{%
1007 A
1008 } & \textbf{%
1009 not A
1010 } \\
1011 \hline
1012 \endhead
1013 \multicolumn{2}{p{0.15\DUtablewidth}}{\raggedleft\ldots continued on next page}\\
1014 \endfoot
1015 \endlastfoot
1016
1017 False
1018 &
1019 True
1020 \\
1021 \hline
1022
1023 True
1024 &
1025 False
1026 \\
1027 \hline
1028 \end{longtable}
1029
1030 With the “widths” argument “auto” (or “class” value “colwidths-auto”),
1031 column widths are determined by the backend (if supported by the
1032 writer/backend).
1033
1034 \phantomsection\label{target2}\label{target1}
1035 \begin{longtable*}{|l|l|l|}
1036 \hline
1037 \textbf{A} & \textbf{B} & \textbf{A or B} \\
1038 \hline
1039 \endfirsthead
1040 \hline
1041 \textbf{A} & \textbf{B} & \textbf{A or B} \\
1042 \hline
1043 \endhead
1044 \endfoot
1045 \endlastfoot
1046 False & False & False \\
1047 \hline
1048 True & False & True \\
1049 \hline
1050 False & True & True \\
1051 \hline
1052 True & True & True \\
1053 \hline
1054 \end{longtable*}
1055
1056
1057 \subsubsection{2.14.4   Admonitions}
1058
1059 \begin{DUclass}{attention}
1060 \begin{DUadmonition}
1061 \DUtitle{Attention!}
1062
1063 Directives at large.
1064 \end{DUadmonition}
1065 \end{DUclass}
1066
1067 \begin{DUclass}{caution}
1068 \begin{DUadmonition}
1069 \DUtitle{Caution!}
1070
1071 Don’t take any wooden nickels.
1072 \end{DUadmonition}
1073 \end{DUclass}
1074
1075 \begin{DUclass}{danger}
1076 \begin{DUadmonition}
1077 \DUtitle{!DANGER!}
1078
1079 Mad scientist at work!
1080 \end{DUadmonition}
1081 \end{DUclass}
1082
1083 \begin{DUclass}{error}
1084 \begin{DUadmonition}
1085 \DUtitle{Error}
1086
1087 Does not compute.
1088 \end{DUadmonition}
1089 \end{DUclass}
1090
1091 \begin{DUclass}{hint}
1092 \begin{DUadmonition}
1093 \DUtitle{Hint}
1094
1095 It’s bigger than a bread box.
1096 \end{DUadmonition}
1097 \end{DUclass}
1098
1099 \begin{DUclass}{important}
1100 \begin{DUadmonition}
1101 \DUtitle{Important}
1102
1103 \begin{itemize}
1104 \item Wash behind your ears.
1105
1106 \item Clean up your room.
1107
1108 \item Call your mother.
1109
1110 \item Back up your data.
1111 \end{itemize}
1112 \end{DUadmonition}
1113 \end{DUclass}
1114
1115 \begin{DUclass}{note}
1116 \begin{DUadmonition}
1117 \DUtitle{Note}
1118
1119 This is a note.
1120 \end{DUadmonition}
1121 \end{DUclass}
1122
1123 \begin{DUclass}{tip}
1124 \begin{DUadmonition}
1125 \DUtitle{Tip}
1126
1127 15\% if the service is good.
1128 \end{DUadmonition}
1129 \end{DUclass}
1130
1131 \begin{DUclass}{warning}
1132 \begin{DUadmonition}
1133 \DUtitle{Warning}
1134
1135 Strong prose may provoke extreme mental exertion.
1136 Reader discretion is strongly advised.
1137 \end{DUadmonition}
1138 \end{DUclass}
1139
1140 \begin{DUclass}{admonition-and-by-the-way}
1141 \begin{DUadmonition}
1142 \DUtitle{And, by the way…}
1143
1144 You can make up your own admonition too.
1145 \end{DUadmonition}
1146 \end{DUclass}
1147
1148
1149 \subsubsection{2.14.5   Topics, Sidebars, and Rubrics}
1150
1151 \emph{Sidebars} are like miniature, parallel documents.
1152
1153 \DUsidebar{
1154 \DUtitle{Optional Sidebar Title}
1155
1156 \DUsubtitle{Optional Subtitle}
1157
1158 This is a sidebar. It is for text outside the flow of the main
1159 text.
1160
1161 \DUrubric{This is a rubric inside a sidebar}
1162
1163 Sidebars often appear beside the main text with a border and a different
1164 background or font color.
1165 }
1166
1167 A \emph{topic} is like a block quote with a title, or a self-contained section
1168 with no subsections.
1169
1170 \begin{DUclass}{topic}
1171 \begin{quote}
1172 \DUtitle{Topic Title}
1173
1174 This is a topic.
1175 \end{quote}
1176 \end{DUclass}
1177
1178 A \emph{rubric} is like an informal heading that doesn’t correspond to the
1179 document’s structure. It is typically highlighted in red (hence the name).
1180
1181 \DUrubric{This is a rubric}
1182
1183 Topics and rubrics can be used at places where a \hyperref[section-title]{section title} is not
1184 allowed (e.g. inside a directive).
1185
1186
1187 \subsubsection{2.14.6   Target Footnotes}
1188 %
1189 \DUfootnotetext{footnote-6}{footnote-reference-10}{5}{%
1190 \url{http://www.python.org/}
1191 }
1192 %
1193 \DUfootnotetext{footnote-7}{footnote-reference-13}{6}{%
1194 \url{http://pygments.org/}
1195 }
1196 %
1197 \DUfootnotetext{footnote-8}{footnote-reference-14}{7}{%
1198 \url{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf}
1199 }
1200 %
1201 \DUfootnotetext{footnote-9}{footnote-reference-17}{8}{%
1202 \url{https://docutils.sourceforge.io/}
1203 }
1204 %
1205 \DUfootnotetext{footnote-10}{footnote-reference-18}{9}{%
1206 \url{https://docutils.sourceforge.io/docs/ref/rst/directives.html}
1207 }
1208 %
1209 \DUfootnotetext{footnote-11}{footnote-reference-19}{10}{%
1210 \url{https://docutils.sourceforge.io/docs/ref/rst/directives.html\#metadata}
1211 }
1212
1213
1214 \subsubsection{2.14.7   Replacement Text}
1215
1216 I recommend you try \href{http://www.python.org/}{Python, \emph{the} best language around}\DUfootnotemark{footnote-reference-12}{footnote-6}{5}.
1217
1218
1219 \subsubsection{2.14.8   Compound Paragraph}
1220
1221 The \emph{compound} directive is used to create a “compound paragraph”, which
1222 is a single logical paragraph containing multiple physical body
1223 elements. For example:
1224
1225 \begin{DUclass}{compound}
1226 The ‘rm’ command is very dangerous. If you are logged
1227 in as root and enter
1228 \begin{quote}
1229 \begin{alltt}
1230 cd /
1231 rm -rf *
1232 \end{alltt}
1233 \end{quote}
1234 you will erase the entire contents of your file system.
1235 \end{DUclass}
1236
1237 Test the handling and display of compound paragraphs:
1238
1239 \begin{DUclass}{compound}
1240 \begin{DUclass}{some-class}
1241 Compound 2, paragraph 1,
1242
1243 compound 2, paragraph 2,
1244 \begin{itemize}
1245 \item list item 1,
1246
1247 \item list item 2,
1248 \end{itemize}
1249 compound 2, paragraph 3.
1250 \end{DUclass}
1251 \end{DUclass}
1252
1253 \begin{DUclass}{compound}
1254 Compound 3, only consisting of one paragraph.
1255 \end{DUclass}
1256
1257 \begin{DUclass}{compound}
1258 \begin{quote}
1259 \begin{alltt}
1260 Compound 4.
1261 This one starts with a literal block.
1262 \end{alltt}
1263 \end{quote}
1264 Compound 4, paragraph following the literal block.
1265 \end{DUclass}
1266
1267 Now something \emph{really} perverted – a nested compound block. This is
1268 just to test that it works at all; the results don’t have to be
1269 meaningful.
1270
1271 \begin{DUclass}{compound}
1272 Compound 5, block 1 (a paragraph).
1273
1274 \begin{DUclass}{compound}
1275 Compound 6 is block 2 in compound 5.
1276
1277 Compound 6, another paragraph.
1278 \end{DUclass}
1279
1280 Compound 5, block 3 (a paragraph).
1281 \end{DUclass}
1282
1283 \begin{DUclass}{compound}
1284 Compound 7, tests the inclusion of various block-level
1285 elements in one logical paragraph. First a table,
1286 \setlength{\DUtablewidth}{\linewidth}%
1287 \begin{longtable*}{|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|}
1288 \hline
1289
1290 Left cell, first
1291 paragraph.
1292
1293 Left cell, second
1294 paragraph.
1295 &
1296 Middle cell,
1297 consisting of
1298 exactly one
1299 paragraph.
1300 &
1301 Right cell.
1302
1303 Paragraph 2.
1304
1305 Paragraph 3.
1306 \\
1307 \hline
1308 \end{longtable*}
1309 followed by a paragraph. This physical paragraph is
1310 actually a continuation of the paragraph before the table. It is followed
1311 by
1312 \begin{quote}
1313 a quote and
1314 \end{quote}
1315 \begin{enumerate}
1316 \item an enumerated list,
1317 \end{enumerate}
1318 a paragraph,
1319 \begin{DUoptionlist}
1320 \item[-{}-an] option list,
1321 \end{DUoptionlist}
1322 a paragraph,
1323 \begin{DUfieldlist}
1324 \item[{a field:}]
1325 list,
1326 \end{DUfieldlist}
1327 a paragraph,
1328 \begin{description}
1329 \item[{a definition}]
1330 list,
1331 \end{description}
1332 a paragraph, an image:
1333 \includegraphics{../../../docs/user/rst/images/biohazard.png}
1334 a paragraph,
1335 \begin{DUlineblock}{0em}
1336 \item[] a line
1337 \item[] block,
1338 \end{DUlineblock}
1339 a paragraph followed by a comment,
1340 % this is a comment
1341 a paragraph, a
1342 \begin{DUclass}{note}
1343 \begin{DUadmonition}
1344 \DUtitle{Note}
1345
1346 with content
1347 \end{DUadmonition}
1348 \end{DUclass}
1349 and the final paragraph of the compound 7.
1350 \end{DUclass}
1351
1352
1353 \subsubsection{2.14.9   Parsed Literal Blocks}
1354
1355 \begin{quote}
1356 \ttfamily\raggedright
1357 This~is~a~parsed~literal~block.\\
1358 ~~~~This~line~is~indented.~~The~next~line~is~blank.\\
1359 ~\\
1360 Inline~markup~is~supported,~e.g.~\emph{emphasis},~\textbf{strong},~\texttt{literal\\
1361 text},~\textsubscript{sub-}~and~\textsuperscript{super}scripts,\\
1362 inline~formulas:~$A = 2 \pi r^2$,\\
1363 footnotes\DUfootnotemark{footnote-reference-9}{footnote-1}{1},~%
1364 \phantomsection\label{hyperlink-targets}hyperlink~targets,~and~\href{http://www.python.org/}{references}.
1365 \end{quote}
1366
1367
1368 \subsubsection{2.14.10   Code}
1369
1370 Blocks of source code can be set with the \DUroletitlereference{code} directive. If the code
1371 language is specified, the content is parsed and tagged by the \href{http://pygments.org/}{Pygments}\DUfootnotemark{footnote-reference-13}{footnote-7}{6}
1372 syntax highlighter and can be formatted with a style sheet. (Code parsing
1373 is turned off using the \texttt{syntax-highlight} config setting in the test
1374 conversions in order to get identical results with/without installed
1375 Pygments highlighter.)
1376
1377 \begin{DUclass}{code}
1378 \begin{DUclass}{python}
1379 \begin{quote}
1380 \begin{alltt}
1381 print 'This is Python code.'
1382 \end{alltt}
1383 \end{quote}
1384 \end{DUclass}
1385 \end{DUclass}
1386
1387 The \texttt{:number-lines:} option (with optional start value) generates line
1388 numbers:
1389
1390 \begin{DUclass}{code}
1391 \begin{DUclass}{python}
1392 \begin{quote}
1393 \ttfamily\raggedright
1394 \DUrole{ln}{~8~}\#~print~integers~from~0~to~9:\\
1395 \DUrole{ln}{~9~}for~i~in~range(10):\\
1396 \DUrole{ln}{10~}~~~~print~i
1397 \end{quote}
1398 \end{DUclass}
1399 \end{DUclass}
1400
1401 For inline code snippets, there is the \DUroletitlereference{code} role, which can be used
1402 directly (the code will not be parsed/tagged, as the language is not known)
1403 or as base for special code roles, e.g. the LaTeX code in the next
1404 paragraph.
1405
1406 Docutils uses LaTeX syntax for math directives and roles:
1407 \texttt{\DUrole{code}{\DUrole{tex}{\textbackslash{}alpha = f(x)}}} prints $\alpha = f(x)$.
1408
1409 The \texttt{:code:} option of the \DUroletitlereference{include} directive sets the included content
1410 as a code block, here the rst file \texttt{header\_footer.rst} with line numbers:
1411
1412 \begin{DUclass}{code}
1413 \begin{DUclass}{rst}
1414 \begin{quote}
1415 \ttfamily\raggedright
1416 \DUrole{ln}{1~}..~header::~Document~header\\
1417 \DUrole{ln}{2~}..~footer::~Document~footer
1418 \end{quote}
1419 \end{DUclass}
1420 \end{DUclass}
1421
1422
1423 \subsubsection{2.14.11   Meta}
1424
1425 The \href{https://docutils.sourceforge.io/docs/ref/rst/directives.html\#metadata}{“meta” directive}\DUfootnotemark{footnote-reference-19}{footnote-11}{10} is used to specify metadata to be stored in,
1426 e.g., HTML META tags or ODT file properties.
1427
1428
1429 \subsection{2.15   Substitution Definitions%
1430 \label{substitution-definitions}%
1431 }
1432
1433 An inline image (\includegraphics{../../../docs/user/rst/images/biohazard.png}) example:
1434
1435 A Unicode example:
1436
1437 (Substitution definitions are only visible in the rST source.)
1438
1439
1440 \subsection{2.16   Comments}
1441
1442 Here’s one:
1443
1444 % Comments begin with two dots and a space. Anything may
1445 % follow, except for the syntax of footnotes, hyperlink
1446 % targets, directives, or substitution definitions.
1447 %
1448 % Double-dashes -- "--" -- must be escaped somehow in HTML output.
1449 %
1450 % Comments may contain non-ASCII characters: ä ö ü æ ø å
1451
1452 (View the HTML/LaTeX/… source to see the comment.)
1453
1454
1455 \subsection{2.17   Raw text}
1456
1457 This does not necessarily look nice, because there may be missing white space.
1458
1459 It’s just there to freeze the behavior.
1460
1461 A test.
1462
1463 Second test.
1464
1465 \DUrole{myclass}{Another test with myclass set.}
1466
1467 This is the \DUrole{myrawroleclass}{fourth test} with myrawroleclass set.
1468
1469 Fifth test in LaTeX.\\Line two.
1470
1471
1472 \subsection{2.18   Container}
1473
1474 \begin{DUclass}{custom}
1475 paragraph 1
1476
1477 paragraph 2
1478 \end{DUclass}
1479
1480 % currently not implemented in LaTeX:
1481 % .. include:: data/header_footer.rst
1482
1483
1484 \subsection{2.19   Colspanning tables}
1485
1486 This table has a cell spanning two columns:
1487
1488 \setlength{\DUtablewidth}{\linewidth}%
1489 \begin{longtable*}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.086\DUtablewidth}|}
1490 \hline
1491 \multicolumn{2}{|p{0.15\DUtablewidth}|}{\textbf{%
1492 Inputs
1493 }} & \textbf{%
1494 Output
1495 } \\
1496 \hline
1497 \textbf{%
1498 A
1499 } & \textbf{%
1500 B
1501 } & \textbf{%
1502 A or B
1503 } \\
1504 \hline
1505 \endfirsthead
1506 \hline
1507 \multicolumn{2}{|p{0.15\DUtablewidth}|}{\textbf{%
1508 Inputs
1509 }} & \textbf{%
1510 Output
1511 } \\
1512 \hline
1513 \textbf{%
1514 A
1515 } & \textbf{%
1516 B
1517 } & \textbf{%
1518 A or B
1519 } \\
1520 \hline
1521 \endhead
1522 \multicolumn{3}{p{0.24\DUtablewidth}}{\raggedleft\ldots continued on next page}\\
1523 \endfoot
1524 \endlastfoot
1525
1526 False
1527 &
1528 False
1529 &
1530 False
1531 \\
1532 \hline
1533
1534 True
1535 &
1536 False
1537 &
1538 True
1539 \\
1540 \hline
1541
1542 False
1543 &
1544 True
1545 &
1546 True
1547 \\
1548 \hline
1549
1550 True
1551 &
1552 True
1553 &
1554 True
1555 \\
1556 \hline
1557 \end{longtable*}
1558
1559
1560 \subsection{2.20   Rowspanning tables}
1561
1562 Here’s a table with cells spanning several rows:
1563
1564 \setlength{\DUtablewidth}{\linewidth}%
1565 \begin{longtable*}{|p{0.296\DUtablewidth}|p{0.156\DUtablewidth}|p{0.226\DUtablewidth}|}
1566 \hline
1567 \textbf{%
1568 Header row, column 1
1569 (header rows optional)
1570 } & \textbf{%
1571 Header 2
1572 } & \textbf{%
1573 Header 3
1574 } \\
1575 \hline
1576 \endfirsthead
1577 \hline
1578 \textbf{%
1579 Header row, column 1
1580 (header rows optional)
1581 } & \textbf{%
1582 Header 2
1583 } & \textbf{%
1584 Header 3
1585 } \\
1586 \hline
1587 \endhead
1588 \multicolumn{3}{p{0.68\DUtablewidth}}{\raggedleft\ldots continued on next page}\\
1589 \endfoot
1590 \endlastfoot
1591
1592 body row 1, column 1
1593 &
1594 column 2
1595 &
1596 column 3
1597 \\
1598 \hline
1599
1600 body row 2
1601 & \multirow{2}{0.16\DUtablewidth}{%
1602 Cells may
1603 span rows.
1604 } & \multirow{2}{0.23\DUtablewidth}{%
1605 Another
1606 rowspanning
1607 cell.
1608 } \\
1609 \cline{1-1}
1610
1611 body row 3
1612 & & \\
1613 \hline
1614 \end{longtable*}
1615
1616
1617 \subsection{2.21   List Tables}
1618
1619 Here’s a list table exercising all features:
1620
1621 \begin{DUclass}{test}
1622 \setlength{\DUtablewidth}{0.95\linewidth}%
1623 \begin{longtable}{|p{0.133\DUtablewidth}|p{0.110\DUtablewidth}|p{0.249\DUtablewidth}|}
1624 \caption{list table with integral header}\\
1625 \hline
1626 \textbf{%
1627 Treat
1628 } & \textbf{%
1629 Quantity
1630 } & \textbf{%
1631 Description
1632 } \\
1633 \hline
1634 \endfirsthead
1635 \caption[]{list table with integral header (... continued)}\\
1636 \hline
1637 \textbf{%
1638 Treat
1639 } & \textbf{%
1640 Quantity
1641 } & \textbf{%
1642 Description
1643 } \\
1644 \hline
1645 \endhead
1646 \multicolumn{3}{p{0.49\DUtablewidth}}{\raggedleft\ldots continued on next page}\\
1647 \endfoot
1648 \endlastfoot
1649 \textbf{%
1650 Albatross
1651 } &
1652 2.99
1653 &
1654 On a stick!
1655 \\
1656 \hline
1657 \textbf{%
1658 Crunchy Frog
1659 } &
1660 1.49
1661 &
1662 If we took the bones out, it wouldn’t be
1663 crunchy, now would it?
1664 \\
1665 \hline
1666 \textbf{%
1667 Gannet Ripple
1668 } &
1669 1.99
1670 &
1671 On a stick!
1672 \\
1673 \hline
1674 \end{longtable}
1675 \end{DUclass}
1676
1677 \begin{longtable}[c]{|l|l|}
1678 \caption{center aligned list table}\\
1679 \hline
1680 Albatross & 2.99 \\
1681 \hline
1682 Crunchy Frog & 1.49 \\
1683 \hline
1684 Gannet Ripple & 1.99 \\
1685 \hline
1686 \end{longtable}
1687
1688
1689 \subsection{2.22   Custom Roles}
1690
1691 \begin{itemize}
1692 \item A role based on an existing role.
1693
1694 \texttt{\DUrole{custom}{one}} \texttt{\DUrole{custom}{two}} \texttt{\DUrole{custom}{three}}
1695
1696 \item A new role.
1697
1698 \DUrole{customnew}{one two three}
1699
1700 \item A role with class attribute.
1701
1702 \DUrole{special}{interpreted text}
1703
1704 \item A language-switching role:
1705
1706 Let’s count in German \foreignlanguage{ngerman}{eins zwei drei}.
1707
1708 \item A role with multiple class attributes, styled with raw directives:
1709
1710 \newcommand{\DUrolegreen}[1]{\textcolor{green}{#1}}
1711 \newcommand{\DUrolesc}[1]{\textsc{#1}}
1712
1713 The following works in most browsers but does not validate
1714 (\texttt{<style>} is only allowed in the document head):
1715
1716 \begin{quote}
1717 \begin{alltt}
1718 .. raw:: html
1719
1720 <style type="text/css"><!-{}-
1721 .green \{color: green;\}
1722 .sc \{font-variant: small-caps;\}
1723 -{}-></style>
1724 \end{alltt}
1725 \end{quote}
1726
1727 \DUrole{green}{\DUrole{sc}{\foreignlanguage{british}{British colourful text in small-caps}}}.
1728 \end{itemize}
1729
1730
1731 \subsection{2.23   Mathematics}
1732
1733 Docutils supports inline math with the prefix or postfix \texttt{:math:}
1734 role specificator, $n! + \sin(x_n^2)$ and $A_\text{c} =
1735 \frac{\pi}{4} d^2$, as well as displayed math via the
1736 \DUroletitlereference{math} directive:
1737 %
1738 \begin{equation*}
1739 f(\epsilon) = \frac{1}{1 + \exp\left(\frac{\varepsilon}{k_\text{B}T}\right)}
1740 \end{equation*}
1741 Content may start on the first line of the directive, e.g.
1742 %
1743 \begin{equation*}
1744 N = \frac{\text{number of apples}}{7}
1745 \end{equation*}
1746 Equations can be labeled with a reference name using the \texttt{:name:} option.
1747 See \hyperref[eq-m]{eq:M} and \hyperref[eq-schrodinger]{eq:schrödinger} below.
1748
1749 The determinant of the matrix
1750 %
1751 \phantomsection
1752 \begin{equation*}
1753 \mathbf{M} = \left(\begin{matrix}a&b\\c&d\end{matrix}\right)
1754 \label{eq-m}
1755 \end{equation*}
1756 is $|\mathbf{M}| = ad - bc$.
1757
1758 More than one display math block can be put in one math directive.
1759 For example, the following sum and integral with limits:
1760 %
1761 \begin{equation*}
1762 \int_0^1 x^n dx = \frac{1}{n + 1}
1763 \end{equation*}%
1764 \begin{equation*}
1765 \sum_{n=1}^m n = \frac{m(m+1)}{2}
1766 \end{equation*}
1767 LaTeX-supported Unicode math symbols can be used in math roles and
1768 directives:
1769
1770 The Schrödinger equation
1771 %
1772 \phantomsection
1773 \begin{equation*}
1774 i\hbar \frac{\partial }{\partial t}\Psi = \hat{H}\Psi ,
1775 \label{eq-schrodinger}
1776 \end{equation*}
1777 with the \emph{wave function} $\Psi $, describes how the quantum state of a
1778 physical system changes in time.
1779
1780 \begin{description}
1781 \item[{Math-Accents:}] \leavevmode
1782 \setlength{\DUtablewidth}{1\linewidth}%
1783 \begin{longtable*}{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
1784
1785 $\acute{a}$ \texttt{\textbackslash{}acute\{a\}}
1786 &
1787 $\dot{t}$ \texttt{\textbackslash{}dot\{t\}}
1788 &
1789 $\hat{\gamma}$ \texttt{\textbackslash{}hat\{\textbackslash{}gamma\}}
1790 \\
1791
1792 $\grave{a}$ \texttt{\textbackslash{}grave\{a\}}
1793 &
1794 $\ddot{t}$ \texttt{\textbackslash{}ddot\{t\}}
1795 &
1796 $\tilde{\alpha}$ \texttt{\textbackslash{}tilde\{\textbackslash{}alpha\}}
1797 \\
1798
1799 $\breve{x}$ \texttt{\textbackslash{}breve\{x\}}
1800 &
1801 $\dddot{t}$ \texttt{\textbackslash{}dddot\{t\}}
1802 &
1803 $\vec{\imath}$ \texttt{\textbackslash{}vec\{\textbackslash{}imath\}}
1804 \\
1805
1806 $\check{a}$ \texttt{\textbackslash{}check\{a\}}
1807 &
1808 $\bar{a}$ \texttt{\textbackslash{}bar\{a\}}
1809 &
1810 $\vec{R}$ \texttt{\textbackslash{}vec\{R\}}
1811 \\
1812 \end{longtable*}
1813 \end{description}
1814
1815 % \widetilde{xxx}
1816 % \widehat{xxx}
1817
1818 Modulation Transfer Function:
1819 %
1820 \begin{equation*}
1821 \text{MTF} = \left|\frac{\mathcal{F}\{s(x)\}}
1822 {\mathcal{F}\{ s(x)\} |_{\omega _{x}=0}}\right|
1823 = \mathrm{abs}\left(\frac
1824 {\int _{-\infty }^{\infty }s(x) \mathrm{e}^{\mathrm{i}\omega _{x}x}\mathrm{d}{x}}
1825 {\int _{-\infty }^{\infty }s(x)\mathrm{d}{x}}
1826 \right).
1827 \end{equation*}
1828 Math split over two lines: If a double backslash is detected outside a
1829 \texttt{\textbackslash{}begin\{...\} \textbackslash{}end\{...\}} pair, the math code is wrapped in an \href{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf}{AMSmath}\DUfootnotemark{footnote-reference-14}{footnote-8}{7}
1830 \texttt{align} environment:
1831 %
1832 \begin{align*}
1833 s_{\mathrm{out}}(x) & = s_{\mathrm{in}}(x') * s_\delta (x-x') \\
1834 & = \int s_{\mathrm{in}}(x')s_\delta (x-x')\mathrm{d}x'
1835 \end{align*}
1836 Cases with the \href{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf}{AMSmath}\DUfootnotemark{footnote-reference-15}{footnote-8}{7} \texttt{cases} environment:
1837 %
1838 \begin{equation*}
1839 \mathrm{sgn}(x) = \begin{cases}
1840 -1 & x<0\\
1841 \phantom{-} 1 & x>0
1842 \end{cases}
1843 \end{equation*}
1844
1845 \section{3   Tests for the LaTeX writer}
1846
1847 Test syntax elements which may cause trouble for the LaTeX writer but might
1848 not need to be tested with other writers. See also the
1849 “latex\_cornercases” test.
1850
1851
1852 \subsection{3.1   Custom Roles in LaTeX}
1853
1854 \begin{itemize}
1855 \item Role names and class arguments are converted to conform to the
1856 regular expression \texttt{{[}a-z{]}{[}-a-z0-9{]}*} (letters are downcased,
1857 accents and similar decoration is stripped, non-conforming
1858 characters are replaced by a hyphen).
1859
1860 Class arguments may contain numbers and hyphens, which need special
1861 treatment in LaTeX command names.
1862
1863 \DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{Text with role “custom4”}}}}} (but without styling by \texttt{DUrole*}
1864 macros).
1865
1866 \item With LaTeX, roles can be styled within the document using the \DUroletitlereference{raw}
1867 directive.
1868
1869 \newcommand{\DUrolelarge}[1]{{\large #1}}
1870 \makeatletter
1871 \@namedef{DUrolesmall-caps}{\textsc}
1872 \@namedef{DUrolecustom4}{\textbf}
1873 \makeatother
1874
1875 \DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{inline text}}}}} in large, bold, small-caps.
1876
1877 \item Custom roles can be based on standard roles:
1878
1879 This is a \emph{\DUrole{custom-emphasis}{customized emphasis text role}}
1880
1881 This is a \texttt{\DUrole{custom-literal}{customized literal text role}}
1882
1883 This is a \textbf{\DUrole{custom-strong}{customized strong text role}}
1884
1885 This is a \textsubscript{\DUrole{custom-subscript}{customized subscript text role}}
1886
1887 This is a \textsuperscript{\DUrole{custom-superscript}{customized superscript text role}}
1888
1889 This is a \DUroletitlereference{\DUrole{custom-title-reference}{customized title-reference text role}}
1890 \end{itemize}
1891
1892
1893 \subsection{3.2   class handling}
1894
1895 This section tests class handling for block level elements by the LaTeX
1896 writer. See the input file \texttt{classes\_latex.rst} for the raw LaTeX code used
1897 to style the examples.
1898
1899 An “epigraph” directive is exported as “quote” wrapped in a “DUclass”
1900 environment. Here, it is styled by a “DUCLASSepigraph” environment
1901 redefining the “quote” environment as “minipage”:
1902
1903 \newcommand*{\DUCLASSepigraph}{%
1904 \renewenvironment{quote}{\vspace{1em}
1905 \footnotesize\hfill{}%
1906 \begin{minipage}{0.4\columnwidth}}%
1907 {\end{minipage}\vskip\baselineskip}}
1908
1909 \begin{DUclass}{epigraph}
1910 \begin{quote}
1911 Do not play this piece fast. It is never right to play \emph{Ragtime} fast.
1912 \nopagebreak
1913
1914 \raggedleft —Scott Joplin
1915 \end{quote}
1916 \end{DUclass}
1917
1918 Raw latex is also used to style the following lists: “DUCLASSenumerateitems”
1919 redefines “itemize” as “enumerate”, “DUCLASSrules” draws horizontal lines
1920 above and below.
1921
1922 \newcommand*{\DUCLASSenumerateitems}{%
1923 \renewenvironment{itemize}{\begin{enumerate}}%
1924 {\end{enumerate}}%
1925 }
1926
1927 \newenvironment{DUCLASSrules}%
1928 {\noindent\rule[0.5ex]{1\columnwidth}{1pt}}%
1929 {\noindent\rule[0.5ex]{1\columnwidth}{1pt}}
1930
1931 An “enumerated” bullet list:
1932
1933 \begin{DUclass}{enumerateitems}
1934 \begin{itemize}
1935 \item item
1936
1937 \item next item
1938
1939 \item third item
1940 \end{itemize}
1941 \end{DUclass}
1942
1943 A list with lines above and below:
1944
1945 \begin{DUclass}{rules}
1946 \begin{itemize}
1947 \item item
1948
1949 \item next item
1950 \end{itemize}
1951 \end{DUclass}
1952
1953 A normal bullet list is kept unchanged by the above redefinitions:
1954
1955 \begin{itemize}
1956 \item item
1957
1958 \item next item
1959
1960 \item third item
1961 \end{itemize}
1962
1963 A container wraps several elements in a common “class wrapper”. Here, we use
1964 it to set 2 paragraphs and a list in small caps:
1965
1966 \newcommand*{\DUCLASSscshape}{\scshape}
1967
1968 \begin{DUclass}{scshape}
1969 paragraph 1
1970
1971 paragraph 2
1972
1973 \begin{itemize}
1974 \item bullet list
1975
1976 \item still bullet list
1977 \end{itemize}
1978 \end{DUclass}
1979
1980 A right-aligned line-block. Alignment handling is built into the latex
1981 writer for image, table, and line block elements.
1982
1983 \begin{DUlineblock}{0em}
1984 \raggedleft
1985 \item[] Max Mustermann
1986 \item[] Waldstr. 22
1987 \item[] D 01234 Testdorf
1988 \item[] Tel.: 0123/456789
1989 \end{DUlineblock}
1990
1991 % preface for System Messages:
1992
1993
1994 \section{4   Error Handling}
1995
1996 Any errors caught during processing will generate system messages.
1997
1998 There should be five messages in the following, auto-generated
1999 section, “Docutils System Messages”:
2000
2001 % section should be added by Docutils automatically
2002
2003
2004 \section[Docutils System Messages]{\color{red}Docutils System Messages}
2005
2006 \raisebox{1em}{\hypertarget{system-message-1}{}}
2007 \begin{DUclass}{system-message}
2008 \begin{DUadmonition}
2009 \DUtitle{\color{red}System Message}
2010
2011 ERROR/3 in \texttt{functional/input/data/standard.rst}, line~99
2012
2013 \hyperlink{problematic-1}{
2014 Undefined substitution referenced: \textquotedbl{}problematic\textquotedbl{}.
2015 }
2016 \end{DUadmonition}
2017 \end{DUclass}
2018
2019 \raisebox{1em}{\hypertarget{system-message-2}{}}
2020 \begin{DUclass}{system-message}
2021 \begin{DUadmonition}
2022 \DUtitle{\color{red}System Message}
2023
2024 ERROR/3 in \texttt{functional/input/data/standard.rst}, line~390
2025
2026 \hyperlink{footnote-reference-8}{
2027 Unknown target name: \textquotedbl{}5\textquotedbl{}.
2028 }
2029 \end{DUadmonition}
2030 \end{DUclass}
2031
2032 \raisebox{1em}{\hypertarget{system-message-3}{}}
2033 \begin{DUclass}{system-message}
2034 \begin{DUadmonition}
2035 \DUtitle{\color{red}System Message}
2036
2037 ERROR/3 in \texttt{functional/input/data/standard.rst}, line~399
2038
2039 \hyperlink{citation-reference-3}{
2040 Unknown target name: \textquotedbl{}nonexistent\textquotedbl{}.
2041 }
2042 \end{DUadmonition}
2043 \end{DUclass}
2044
2045 \raisebox{1em}{\hypertarget{system-message-4}{}}
2046 \begin{DUclass}{system-message}
2047 \begin{DUadmonition}
2048 \DUtitle{\color{red}System Message}
2049
2050 ERROR/3 in \texttt{functional/input/data/standard.rst}, line~426
2051
2052 \hyperlink{problematic-2}{
2053 Unknown target name: \textquotedbl{}hyperlink reference without a target\textquotedbl{}.
2054 }
2055 \end{DUadmonition}
2056 \end{DUclass}
2057
2058 \raisebox{1em}{\hypertarget{system-message-5}{}}
2059 \begin{DUclass}{system-message}
2060 \begin{DUadmonition}
2061 \DUtitle{\color{red}System Message}
2062
2063 ERROR/3 in \texttt{functional/input/data/standard.rst}, line~439
2064
2065 \hyperlink{problematic-3}{
2066 Duplicate target name, cannot be used as a unique reference: \textquotedbl{}duplicate target names\textquotedbl{}.
2067 }
2068 \end{DUadmonition}
2069 \end{DUclass}
2070
2071 \end{document}