Fix [ 239 ] Latex writer glues paragraphs with figure floats.
[docutils.git] / docutils / test / functional / expected / standalone_rst_latex.tex
blob54308b6c09745a4cfb4dd207b7e9d3c78352a07c
1 \documentclass[a4paper]{article}
2 % generated by Docutils <http://docutils.sourceforge.net/>
3 \usepackage{fixltx2e} % LaTeX patches, \textsubscript
4 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
5 \usepackage{ifthen}
6 \usepackage[T1]{fontenc}
7 \usepackage[utf8]{inputenc}
8 \usepackage{amsmath}
9 \usepackage[british,french,ngerman,english]{babel}
10 % Prevent side-effects if French hyphenation patterns are not loaded:
11 \frenchbsetup{StandardLayout}
12 \AtBeginDocument{\selectlanguage{english}\noextrasfrench}
13 % basic code highlight:
14 \providecommand*\DUrolecomment[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
15 \providecommand*\DUroledeleted[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
16 \providecommand*\DUrolekeyword[1]{\textbf{#1}}
17 \providecommand*\DUrolestring[1]{\textit{#1}}
18 \usepackage{color}
19 \usepackage{float} % float configuration
20 \floatplacement{figure}{H} % place figures here definitely
21 \usepackage{graphicx}
22 \usepackage{multirow}
23 \usepackage{pifont}
24 \setcounter{secnumdepth}{0}
25 \usepackage{longtable,ltcaption,array}
26 \setlength{\extrarowheight}{2pt}
27 \newlength{\DUtablewidth} % internal use in tables
28 \usepackage{tabularx}
29 \usepackage{textcomp} % text symbol macros
31 %%% Custom LaTeX preamble
32 % PDF Standard Fonts
33 \usepackage{mathptmx} % Times
34 \usepackage[scaled=.90]{helvet}
35 \usepackage{courier}
37 %%% User specified packages and stylesheets
39 %%% Fallback definitions for Docutils-specific commands
41 % providelength (provide a length variable and set default, if it is new)
42 \providecommand*{\DUprovidelength}[2]{
43 \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
46 % abstract title
47 \providecommand*{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}
49 % admonition (specially marked topic)
50 \providecommand{\DUadmonition}[2][class-arg]{%
51 % try \DUadmonition#1{#2}:
52 \ifcsname DUadmonition#1\endcsname%
53 \csname DUadmonition#1\endcsname{#2}%
54 \else
55 \begin{center}
56 \fbox{\parbox{0.9\textwidth}{#2}}
57 \end{center}
58 \fi
61 \makeatletter
62 \@namedef{DUrolealign-center}{\centering}
63 \makeatother
66 % dedication topic
67 \providecommand{\DUtopicdedication}[1]{\begin{center}#1\end{center}}
69 % docinfo (width of docinfo table)
70 \DUprovidelength{\DUdocinfowidth}{0.9\textwidth}
72 % error admonition title
73 \providecommand*{\DUtitleerror}[1]{\DUtitle{\color{red}#1}}
75 % fieldlist environment
76 \ifthenelse{\isundefined{\DUfieldlist}}{
77 \newenvironment{DUfieldlist}%
78 {\quote\description}
79 {\enddescription\endquote}
80 }{}
81 % numeric or symbol footnotes with hyperlinks
82 \providecommand*{\DUfootnotemark}[3]{%
83 \raisebox{1em}{\hypertarget{#1}{}}%
84 \hyperlink{#2}{\textsuperscript{#3}}%
86 \providecommand{\DUfootnotetext}[4]{%
87 \begingroup%
88 \renewcommand{\thefootnote}{%
89 \protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
90 \protect\hyperlink{#2}{#3}}%
91 \footnotetext{#4}%
92 \endgroup%
95 % inline markup (custom roles)
96 % \DUrole{#1}{#2} tries \DUrole#1{#2}
97 \providecommand*{\DUrole}[2]{%
98 \ifcsname DUrole#1\endcsname%
99 \csname DUrole#1\endcsname{#2}%
100 \else% backwards compatibility: try \docutilsrole#1{#2}
101 \ifcsname docutilsrole#1\endcsname%
102 \csname docutilsrole#1\endcsname{#2}%
103 \else%
105 \fi%
106 \fi%
109 % legend environment
110 \ifthenelse{\isundefined{\DUlegend}}{
111 \newenvironment{DUlegend}{\small}{}
114 % lineblock environment
115 \DUprovidelength{\DUlineblockindent}{2.5em}
116 \ifthenelse{\isundefined{\DUlineblock}}{
117 \newenvironment{DUlineblock}[1]{%
118 \list{}{\setlength{\partopsep}{\parskip}
119 \addtolength{\partopsep}{\baselineskip}
120 \setlength{\topsep}{0pt}
121 \setlength{\itemsep}{0.15\baselineskip}
122 \setlength{\parsep}{0pt}
123 \setlength{\leftmargin}{#1}}
124 \raggedright
126 {\endlist}
129 % optionlist environment
130 \providecommand*{\DUoptionlistlabel}[1]{\bf #1 \hfill}
131 \DUprovidelength{\DUoptionlistindent}{3cm}
132 \ifthenelse{\isundefined{\DUoptionlist}}{
133 \newenvironment{DUoptionlist}{%
134 \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
135 \setlength{\rightmargin}{1cm}
136 \setlength{\leftmargin}{\rightmargin}
137 \addtolength{\leftmargin}{\labelwidth}
138 \addtolength{\leftmargin}{\labelsep}
139 \renewcommand{\makelabel}{\DUoptionlistlabel}}
141 {\endlist}
144 % rubric (informal heading)
145 \providecommand*{\DUrubric}[2][class-arg]{%
146 \subsubsection*{\centering\textit{\textmd{#2}}}}
148 % sidebar (text outside the main text flow)
149 \providecommand{\DUsidebar}[2][class-arg]{%
150 \begin{center}
151 \colorbox[gray]{0.80}{\parbox{0.9\textwidth}{#2}}
152 \end{center}
155 % subtitle (for topic/sidebar)
156 \providecommand*{\DUsubtitle}[2][class-arg]{\par\emph{#2}\smallskip}
158 % title for topics, admonitions, unsupported section levels, and sidebar
159 \providecommand*{\DUtitle}[2][class-arg]{%
160 % call \DUtitle#1{#2} if it exists:
161 \ifcsname DUtitle#1\endcsname%
162 \csname DUtitle#1\endcsname{#2}%
163 \else
164 \smallskip\noindent\textbf{#2}\smallskip%
168 % titlereference role
169 \providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
171 % topic (quote with heading)
172 \providecommand{\DUtopic}[2][class-arg]{%
173 \ifcsname DUtopic#1\endcsname%
174 \csname DUtopic#1\endcsname{#2}%
175 \else
176 \begin{quote}#2\end{quote}
180 % transition (break, fancybreak, anonymous section)
181 \providecommand*{\DUtransition}[1][class-arg]{%
182 \hspace*{\fill}\hrulefill\hspace*{\fill}
183 \vskip 0.5\baselineskip
186 % hyperlinks:
187 \ifthenelse{\isundefined{\hypersetup}}{
188 \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
189 \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
191 \hypersetup{
192 pdftitle={reStructuredText Test Document},
193 pdfauthor={David Goodger;Me;Myself;I}
196 %%% Title Data
197 \title{\phantomsection%
198 reStructuredText Test Document%
199 \label{restructuredtext-test-document}%
200 \label{doctitle}%
201 \\ % subtitle%
202 \large{Examples of Syntax Constructs}%
203 \label{examples-of-syntax-constructs}%
204 \label{subtitle}}
205 \author{}
206 \date{}
208 %%% Body
209 \begin{document}
210 \maketitle
212 % Docinfo
213 \begin{center}
214 \begin{tabularx}{\DUdocinfowidth}{lX}
215 \textbf{Author}: &
216 David Goodger \\
217 \textbf{Address}: &
218 {\raggedright
219 123 Example Street\\
220 Example, EX Canada\\
221 A1B 2C3 } \\
222 \textbf{Contact}: &
223 \href{mailto:goodger@python.org}{goodger@python.org} \\
224 \textbf{Author}: &
225 Me \\
226 \textbf{Author}: &
227 Myself \\
228 \textbf{Author}: &
229 I \\
230 \textbf{Organization}: &
231 humankind \\
232 \textbf{Date}: &
233 Now, or yesterday. Or maybe even \emph{before} yesterday. \\
234 \textbf{Status}: &
235 This is a “work in progress” \\
236 \textbf{Revision}: &
237 is managed by a version control system. \\
238 \textbf{Version}: &
239 1 \\
240 \textbf{Copyright}: &
241 This document has been placed in the public domain. You
242 may do with it as you wish. You may copy, modify,
243 redistribute, reattribute, sell, buy, rent, lease,
244 destroy, or improve it, quote it at length, excerpt,
245 incorporate, collate, fold, staple, or mutilate it, or do
246 anything else to it that your or anyone else’s heart
247 desires. \\
248 \textbf{field name}: &
249 This is a “generic bibliographic field”.
251 \textbf{field name “2}: &
252 Generic bibliographic fields may contain multiple body elements.
254 Like this.
256 \end{tabularx}
257 \end{center}
259 \DUtopic[dedication]{
260 \DUtitle[dedication]{Dedication}
262 For Docutils users \& co-developers.
265 \DUtopic[abstract]{
266 \DUtitle[abstract]{Abstract}
268 This is a test document, containing at least one example of each
269 reStructuredText construct.
272 % This is a comment. Note how any initial comments are moved by
273 % transforms to after the document title, subtitle, and docinfo.
275 % Above is the document title, and below is the subtitle.
276 % They are transformed from section titles after parsing.
278 % bibliographic fields (which also require a transform):
280 \pagebreak[4] % start ToC on new page
282 \phantomsection\label{table-of-contents}
283 \pdfbookmark[1]{Table of Contents}{table-of-contents}
284 \renewcommand{\contentsname}{Table of Contents}
285 \tableofcontents
289 \section{1~~~Structural Elements%
290 \label{structural-elements}%
294 \subsection{1.1~~~Section Title%
295 \label{section-title}%
297 \subsubsection*{Section Subtitle}
299 Lone subsections are converted to a section subtitle by a transform
300 activated with the \texttt{-{}-section-subtitles} command line option or the
301 \texttt{sectsubtitle-xform} configuration value.
304 \subsection{1.2~~~Empty Section%
305 \label{empty-section}%
309 \subsection{1.3~~~Transitions%
310 \label{transitions}%
313 Here’s a transition:
316 %___________________________________________________________________________
317 \DUtransition
320 It divides the section. Transitions may also occur between sections:
323 %___________________________________________________________________________
324 \DUtransition
328 \section{2~~~Body Elements%
329 \label{body-elements}%
333 \subsection{2.1~~~Paragraphs%
334 \label{paragraphs}%
337 A paragraph.
340 \subsubsection{2.1.1~~~Inline Markup%
341 \label{inline-markup}%
344 Paragraphs contain text and may contain inline markup: \emph{emphasis},
345 \textbf{strong emphasis}, \texttt{inline literals}, standalone hyperlinks
346 (\url{http://www.python.org}), external hyperlinks (\href{http://www.python.org/}{Python}\DUfootnotemark{id30}{id29}{5}), internal
347 cross-references (\hyperref[example]{example}), external hyperlinks with embedded URIs
348 (\href{http://www.python.org}{Python web site}), \href{http://www.python.org/}{anonymous hyperlink
349 references}\DUfootnotemark{id38}{id29}{5} (\href{http://docutils.sourceforge.net/}{a second reference}\DUfootnotemark{id40}{id39}{8}), footnote references (manually
350 numbered\DUfootnotemark{id1}{id8}{1}, anonymous auto-numbered\DUfootnotemark{id2}{id12}{3}, labeled auto-numbered\DUfootnotemark{id3}{label}{2}, or symbolic\DUfootnotemark{id4}{id13}{*}), citation references (\hyperlink{cit2002}{[CIT2002]}),
351 substitution references (\includegraphics{../../../docs/user/rst/images/biohazard.png}), and %
352 \phantomsection\label{inline-hyperlink-targets}inline hyperlink targets
353 (see \hyperref[targets]{Targets} below for a reference back to here). Character-level
354 inline markup is also possible (although exceedingly ugly!) in \emph{re}\texttt{Structured}\emph{Text}. Problems are indicated by %
355 \raisebox{1em}{\hypertarget{id28}{}}\hyperlink{id27}{\textbf{\color{red}|problematic|}} text
356 (generated by processing errors; this one is intentional). Here is a
357 reference to the \hyperref[doctitle]{doctitle} and the \hyperref[subtitle]{subtitle}.
359 The default role for interpreted text is \DUroletitlereference{Title Reference}. Here are
360 some explicit interpreted text roles: a PEP reference (\href{http://www.python.org/dev/peps/pep-0287}{PEP 287}); an
361 RFC reference (\href{http://www.faqs.org/rfcs/rfc2822.html}{RFC 2822}); an abbreviation (\DUrole{abbreviation}{abb.}), an acronym
362 (\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print \textquotedbl{}hello world\textquotedbl{}}}); a \textsubscript{subscript};
363 a \textsuperscript{superscript} and explicit roles for \DUroletitlereference{Docutils}
364 \emph{standard} \textbf{inline} \texttt{markup}.
366 % DO NOT RE-WRAP THE FOLLOWING PARAGRAPH!
368 Let’s test wrapping and whitespace significance in inline literals:
369 \texttt{This is an example of -{}-inline-literal -{}-text, -{}-including some-{}-
370 strangely-{}-hyphenated-words. ~Adjust-the-width-of-your-browser-window
371 to see how the text is wrapped. ~-{}- -{}-{}-{}- -{}-{}-{}-{}-{}-{}-{}- ~Now note ~ ~the
372 spacing ~ ~between the ~ ~words of ~ ~this sentence ~ ~(words
373 should ~ ~be grouped ~ ~in pairs).}
375 If the \texttt{-{}-pep-references} option was supplied, there should be a
376 live link to PEP 258 here.
379 \subsection{2.2~~~Bullet Lists%
380 \label{bullet-lists}%
383 \begin{itemize}
385 \item A bullet list
387 \begin{itemize}
389 \item Nested bullet list.
391 \item Nested item 2.
393 \end{itemize}
395 \item Item 2.
397 Paragraph 2 of item 2.
399 \begin{itemize}
401 \item Nested bullet list.
403 \item Nested item 2.
405 \begin{itemize}
407 \item Third level.
409 \item Item 2.
411 \end{itemize}
413 \item Nested item 3.
415 \item This nested list should be compacted by the HTML writer.
417 \phantomsection\label{target}
418 % Even if this item contains a target and a comment.
420 \end{itemize}
422 \end{itemize}
425 \subsection{2.3~~~Enumerated Lists%
426 \label{enumerated-lists}%
428 \newcounter{listcnt0}
429 \begin{list}{\arabic{listcnt0}.}
431 \usecounter{listcnt0}
432 \setlength{\rightmargin}{\leftmargin}
435 \item Arabic numerals.
436 \newcounter{listcnt1}
437 \begin{list}{\alph{listcnt1})}
439 \usecounter{listcnt1}
440 \setlength{\rightmargin}{\leftmargin}
443 \item lower alpha)
444 \newcounter{listcnt2}
445 \begin{list}{(\roman{listcnt2})}
447 \usecounter{listcnt2}
448 \setlength{\rightmargin}{\leftmargin}
451 \item (lower roman)
452 \newcounter{listcnt3}
453 \begin{list}{\Alph{listcnt3}.}
455 \usecounter{listcnt3}
456 \setlength{\rightmargin}{\leftmargin}
459 \item upper alpha.
460 \newcounter{listcnt4}
461 \begin{list}{\Roman{listcnt4})}
463 \usecounter{listcnt4}
464 \setlength{\rightmargin}{\leftmargin}
467 \item upper roman)
468 \end{list}
469 \end{list}
470 \end{list}
471 \end{list}
473 \item Lists that don’t start at 1:
474 \setcounter{listcnt1}{0}
475 \begin{list}{\arabic{listcnt1}.}
477 \usecounter{listcnt1}
478 \addtocounter{listcnt1}{2}
479 \setlength{\rightmargin}{\leftmargin}
482 \item Three
484 \item Four
485 \end{list}
486 \setcounter{listcnt1}{0}
487 \begin{list}{\Alph{listcnt1}.}
489 \usecounter{listcnt1}
490 \addtocounter{listcnt1}{2}
491 \setlength{\rightmargin}{\leftmargin}
494 \item C
496 \item D
497 \end{list}
498 \setcounter{listcnt1}{0}
499 \begin{list}{\roman{listcnt1}.}
501 \usecounter{listcnt1}
502 \addtocounter{listcnt1}{2}
503 \setlength{\rightmargin}{\leftmargin}
506 \item iii
508 \item iv
509 \end{list}
510 \end{list}
513 \subsection{2.4~~~Definition Lists%
514 \label{definition-lists}%
517 \begin{description}
518 \item[{Term}] \leavevmode
519 Definition
521 \item[{Term}] \leavevmode (\textbf{classifier})
523 Definition paragraph 1.
525 Definition paragraph 2.
527 \item[{Term}] \leavevmode
528 Definition
530 \item[{Term}] \leavevmode (\textbf{classifier one})
531 (\textbf{classifier two})
533 Definition
535 \end{description}
538 \subsection{2.5~~~Field Lists%
539 \label{field-lists}%
542 \begin{DUfieldlist}
543 \item[{what:}]
544 Field lists map field names to field bodies, like database
545 records. They are often part of an extension syntax. They are
546 an unambiguous variant of RFC 2822 fields.
548 \item[{how arg1 arg2:}]
549 The field marker is a colon, the field name, and a colon.
551 The field body may contain one or more body elements, indented
552 relative to the field marker.
554 \item[{credits:}]
555 \DUrole{credits}{This paragraph has the \DUroletitlereference{credits} class set. (This is actually not
556 about credits but just for ensuring that the class attribute
557 doesn’t get stripped away.)}
559 \end{DUfieldlist}
562 \subsection{2.6~~~Option Lists%
563 \label{option-lists}%
566 For listing command-line options:
568 \begin{DUoptionlist}
570 \item[-a] command-line option “a”
572 \item[-b file] options can have arguments
573 and long descriptions
575 \item[-{}-long] options can be long also
577 \item[-{}-input=file] long options can also have
578 arguments
580 \item[-{}-very-long-option] The description can also start on the next line.
582 The description may contain multiple body elements,
583 regardless of where it starts.
585 \item[-x, -y, -z] Multiple options are an “option group”.
587 \item[-v, -{}-verbose] Commonly-seen: short \& long options.
589 \item[-1 file, -{}-one=file, -{}-two file] Multiple options with arguments.
591 \item[/V] DOS/VMS-style options too
593 \end{DUoptionlist}
595 There must be at least two spaces between the option and the
596 description.
599 \subsection{2.7~~~Literal Blocks%
600 \label{literal-blocks}%
603 Literal blocks are indicated with a double-colon (“::”) at the end of
604 the preceding paragraph (over there \texttt{-{}->}). They can be indented:
606 \begin{quote}{\ttfamily \raggedright \noindent
607 if~literal\_block:\\
608 ~~~~text~=~'is~left~as-is'\\
609 ~~~~spaces\_and\_linebreaks~=~'are~preserved'\\
610 ~~~~markup\_processing~=~None
612 \end{quote}
614 Or they can be quoted without indentation:
616 \begin{quote}{\ttfamily \raggedright \noindent
617 >{}>~Great~idea!\\
619 >~Why~didn't~I~think~of~that?
621 \end{quote}
624 \subsection{2.8~~~Line Blocks%
625 \label{line-blocks}%
628 This section tests line blocks. Line blocks are body elements which
629 consist of lines and other line blocks. Nested line blocks cause
630 indentation.
632 \begin{DUlineblock}{0em}
633 \item[] This is a line block. It ends with a blank line.
634 \item[]
635 \begin{DUlineblock}{\DUlineblockindent}
636 \item[] New lines begin with a vertical bar (“|”).
637 \item[] Line breaks and initial indent are significant, and preserved.
638 \item[]
639 \begin{DUlineblock}{\DUlineblockindent}
640 \item[] Continuation lines are also possible. A long line that is intended
641 to wrap should begin with a space in place of the vertical bar.
642 \end{DUlineblock}
643 \item[] The left edge of a continuation line need not be aligned with
644 the left edge of the text above it.
645 \end{DUlineblock}
646 \end{DUlineblock}
648 \begin{DUlineblock}{0em}
649 \item[] This is a second line block.
650 \item[]
651 \item[] Blank lines are permitted internally, but they must begin with a “|”.
652 \end{DUlineblock}
654 Another line block, surrounded by paragraphs:
656 \begin{DUlineblock}{0em}
657 \item[] And it’s no good waiting by the window
658 \item[] It’s no good waiting for the sun
659 \item[] Please believe me, the things you dream of
660 \item[] They don’t fall in the lap of no-one
661 \end{DUlineblock}
663 Take it away, Eric the Orchestra Leader!
665 \begin{quote}
667 \begin{DUlineblock}{0em}
668 \item[] A one, two, a one two three four
669 \item[]
670 \item[] Half a bee, philosophically,
671 \item[]
672 \begin{DUlineblock}{\DUlineblockindent}
673 \item[] must, \emph{ipso facto}, half not be.
674 \end{DUlineblock}
675 \item[] But half the bee has got to be,
676 \item[]
677 \begin{DUlineblock}{\DUlineblockindent}
678 \item[] \emph{vis a vis} its entity. D’you see?
679 \item[]
680 \end{DUlineblock}
681 \item[] But can a bee be said to be
682 \item[]
683 \begin{DUlineblock}{\DUlineblockindent}
684 \item[] or not to be an entire bee,
685 \item[]
686 \begin{DUlineblock}{\DUlineblockindent}
687 \item[] when half the bee is not a bee,
688 \item[]
689 \begin{DUlineblock}{\DUlineblockindent}
690 \item[] due to some ancient injury?
691 \item[]
692 \end{DUlineblock}
693 \end{DUlineblock}
694 \end{DUlineblock}
695 \item[] Singing…
696 \end{DUlineblock}
698 \end{quote}
700 A line block, like the following poem by Christian Morgenstern, can
701 also be centre-aligned:
703 \begin{DUlineblock}{0em}
704 \foreignlanguage{ngerman}{\DUrole{align-center}{
705 \item[] \textbf{Die Trichter}
706 \item[]
707 \item[] Zwei Trichter wandeln durch die Nacht.
708 \item[] Durch ihres Rumpfs verengten Schacht
709 \item[] fließt weißes Mondlicht
710 \item[] still und heiter
711 \item[] auf ~ ihren
712 \item[] Waldweg
713 \item[] u. s.
714 \item[] w.
715 \item[]
717 \end{DUlineblock}
720 \subsection{2.9~~~Block Quotes%
721 \label{block-quotes}%
724 Block quotes consist of indented body elements:
726 \begin{quote}
728 My theory by A. Elk. Brackets Miss, brackets. This theory goes
729 as follows and begins now. All brontosauruses are thin at one
730 end, much much thicker in the middle and then thin again at the
731 far end. That is my theory, it is mine, and belongs to me and I
732 own it, and what it is too.
733 \nopagebreak
735 \raggedleft —Anne Elk (Miss)
737 \end{quote}
739 The language of a quote (like any other object) can be specified by
740 a class attribute:
744 \begin{quote}
745 \foreignlanguage{french}{
746 ReStructuredText est un langage de balisage léger utilisé
747 notamment dans la documentation du langage Python.
749 \end{quote}
752 \subsection{2.10~~~Doctest Blocks%
753 \label{doctest-blocks}%
756 \begin{quote}{\ttfamily \raggedright \noindent
757 >{}>{}>~print~'Python-specific~usage~examples;~begun~with~\textquotedbl{}>{}>{}>\textquotedbl{}'\\
758 Python-specific~usage~examples;~begun~with~\textquotedbl{}>{}>{}>\textquotedbl{}\\
759 >{}>{}>~print~'(cut~and~pasted~from~interactive~Python~sessions)'\\
760 (cut~and~pasted~from~interactive~Python~sessions)
762 \end{quote}
765 \subsection{2.11~~~Footnotes%
766 \label{footnotes}%
769 \DUfootnotetext{id8}{id1}{1}{%
770 A footnote contains body elements, consistently indented by at
771 least 3 spaces.
773 This is the footnote’s second paragraph.
776 \DUfootnotetext{label}{id3}{2}{\phantomsection\label{label}%
777 Footnotes may be numbered, either manually (as in\DUfootnotemark{id9}{id8}{1}) or
778 automatically using a “\#”-prefixed label. This footnote has a
779 label so it can be referred to from multiple places, both as a
780 footnote reference (\DUfootnotemark{id10}{label}{2}) and as a \hyperref[label]{hyperlink reference}.
783 \DUfootnotetext{id12}{id2}{3}{%
784 This footnote is numbered automatically and anonymously using a
785 label of “\#” only.
787 This is the second paragraph.
789 And this is the third paragraph.
792 \DUfootnotetext{id13}{id4}{*}{%
793 Footnotes may also use symbols, specified with a “*” label.
794 Here’s a reference to the next footnote:\DUfootnotemark{id14}{id15}{}.
797 \DUfootnotetext{id15}{id14}{}{%
798 This footnote shows the next symbol in the sequence.
801 \DUfootnotetext{id16}{id16}{4}{%
802 Here’s an unreferenced footnote, with a reference to a
803 nonexistent footnote:%
804 \raisebox{1em}{\hypertarget{id46}{}}%
805 \raisebox{1em}{\hypertarget{id17}{}}\hyperlink{id45}{\textbf{\color{red}{[}5{]}\_}}.
809 \subsection{2.12~~~Citations%
810 \label{citations}%
812 \begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002]
813 Citations are text-labeled footnotes. They may be
814 rendered separately and differently from footnotes.
815 \end{figure}
817 Here’s a reference to the above, \hyperlink{cit2002}{[CIT2002]}, and a %
818 \raisebox{1em}{\hypertarget{id48}{}}%
819 \raisebox{1em}{\hypertarget{id19}{}}\hyperlink{id47}{\textbf{\color{red}{[}nonexistent{]}\_}}
820 citation.
823 \subsection{2.13~~~Targets%
824 \label{targets}%
825 \label{another-target}%
828 \phantomsection\label{example}
829 This paragraph is pointed to by the explicit “example” target. A
830 reference can be found under \hyperref[inline-markup]{Inline Markup}, above. \hyperref[inline-hyperlink-targets]{Inline
831 hyperlink targets} are also possible.
833 Section headers are implicit targets, referred to by name. See
834 \hyperref[targets]{Targets}, which is a subsection of \hyperref[body-elements]{Body Elements}.
836 Explicit external targets are interpolated into references such as
837 \href{http://www.python.org/}{Python}\DUfootnotemark{id31}{id29}{5}”.
839 Targets may be indirect and anonymous. Thus \hyperref[targets]{this phrase} may also
840 refer to the \hyperref[targets]{Targets} section.
842 Here’s a %
843 \raisebox{1em}{\hypertarget{id50}{}}\hyperlink{id49}{\textbf{\color{red}`hyperlink reference without a target`\_}}, which generates an
844 error.
847 \subsubsection{2.13.1~~~Duplicate Target Names%
848 \label{duplicate-target-names}%
851 Duplicate names in section headers or other implicit targets will
852 generate “info” (level-1) system messages. Duplicate names in
853 explicit targets will generate “warning” (level-2) system messages.
856 \subsubsection{2.13.2~~~Duplicate Target Names%
857 \label{id21}%
860 Since there are two “Duplicate Target Names” section headers, we
861 cannot uniquely refer to either of them by name. If we try to (like
862 this: %
863 \raisebox{1em}{\hypertarget{id52}{}}\hyperlink{id51}{\textbf{\color{red}`Duplicate Target Names`\_}}), an error is generated.
866 \subsection{2.14~~~Directives%
867 \label{directives}%
870 \phantomsection\label{contents}
871 These are just a sample of the many reStructuredText Directives. For
872 others, please see
873 \url{http://docutils.sourceforge.net/docs/ref/rst/directives.html}.
876 \subsubsection{2.14.1~~~Document Parts%
877 \label{document-parts}%
880 An example of the “contents” directive can be seen above this section
881 (a local, untitled table of \hyperref[contents]{contents}) and at the beginning of the
882 document (a document-wide \hyperref[table-of-contents]{table of contents}).
885 \subsubsection{2.14.2~~~Images and Figures%
886 \label{images-and-figures}%
889 An image directive (also clickable – a hyperlink reference):
891 \hyperref[directives]{\includegraphics{../../../docs/user/rst/images/title.png}}
893 Image with multiple IDs:
895 \includegraphics{../../../docs/user/rst/images/title.png}
896 \phantomsection\label{image-target-3}\label{image-target-2}\label{image-target-1}
898 A centered image:
900 \noindent\makebox[\textwidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}}
902 A left-aligned image:
904 \noindent{\includegraphics{../../../docs/user/rst/images/biohazard.png}\hfill}
906 This paragraph might flow around the image.
907 The specific behavior depends upon the style sheet and
908 the browser or rendering software used.
910 A right-aligned image:
912 \noindent{\hfill\includegraphics{../../../docs/user/rst/images/biohazard.png}}
914 This paragraph might flow around the image.
915 The specific behavior depends upon the style sheet and
916 the browser or rendering software used.
918 For inline images see \hyperref[substitution-definitions]{Substitution Definitions}.
920 Image size:
922 An image 2 em wide:
924 \includegraphics[width=2em]{../../../docs/user/rst/images/biohazard.png}
926 An image 2 em wide and 15 pixel high:
928 \includegraphics[height=15px,width=2em]{../../../docs/user/rst/images/biohazard.png}
930 An image occupying 50\% of the line width:
932 \includegraphics[width=0.500\linewidth]{../../../docs/user/rst/images/title.png}
934 An image 2 cm high:
936 \includegraphics[height=2cm]{../../../docs/user/rst/images/biohazard.png}
938 A \emph{figure} is an image with a caption and/or a legend. With page-based output
939 media, figures might float to a different position if this helps the page
940 layout.
942 \begin{figure}
943 \noindent\makebox[\textwidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}
944 \caption{Plaintext markup syntax and parser system.}
945 \begin{DUlegend}
946 \setlength{\DUtablewidth}{\linewidth}
947 \begin{longtable*}[c]{|p{0.156\DUtablewidth}|p{0.563\DUtablewidth}|}
948 \hline
952 Revised, revisited, based on ‘re’ module.
954 \hline
956 Structured
958 Structure-enhanced text, structuredtext.
960 \hline
962 Text
964 Well it is, isn’t it?
966 \hline
967 \end{longtable*}
969 This paragraph is also part of the legend.
970 \end{DUlegend}
971 \end{figure}
973 A left-aligned figure:
975 \begin{figure} % align = "left"
976 \noindent\makebox[\textwidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}}
977 \caption{This is the caption.}
978 \begin{DUlegend}
979 This is the legend.
981 The legend may consist of several paragraphs.
982 \end{DUlegend}
983 \end{figure}
985 This paragraph might flow around the figure.
987 The specific behavior depends upon the style sheet and the browser or
988 rendering software used.
990 A centered figure:
992 \begin{figure}
993 \noindent\makebox[\textwidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}}
994 \caption{This is the caption.}
995 \begin{DUlegend}
996 This is the legend.
998 The legend may consist of several paragraphs.
999 \end{DUlegend}
1000 \end{figure}
1002 This paragraph might flow around the figure.
1004 The specific behavior depends upon the style sheet and the browser or
1005 rendering software used.
1007 A right-aligned figure:
1009 \begin{figure} % align = "right"
1010 \noindent\makebox[\textwidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}}
1011 \caption{This is the caption.}
1012 \begin{DUlegend}
1013 This is the legend.
1015 The legend may consist of several paragraphs.
1016 \end{DUlegend}
1017 \end{figure}
1019 This paragraph might flow around the figure. The specific behavior depends
1020 upon the style sheet and the browser or rendering software used.
1023 \subsubsection{2.14.3~~~Admonitions%
1024 \label{admonitions}%
1027 \DUadmonition[attention]{
1028 \DUtitle[attention]{Attention!}
1030 Directives at large.
1033 \DUadmonition[caution]{
1034 \DUtitle[caution]{Caution!}
1036 Don’t take any wooden nickels.
1039 \DUadmonition[danger]{
1040 \DUtitle[danger]{!DANGER!}
1042 Mad scientist at work!
1045 \DUadmonition[error]{
1046 \DUtitle[error]{Error}
1048 Does not compute.
1051 \DUadmonition[hint]{
1052 \DUtitle[hint]{Hint}
1054 It’s bigger than a bread box.
1057 \DUadmonition[important]{
1058 \DUtitle[important]{Important}
1060 \begin{itemize}
1062 \item Wash behind your ears.
1064 \item Clean up your room.
1066 \item Call your mother.
1068 \item Back up your data.
1070 \end{itemize}
1073 \DUadmonition[note]{
1074 \DUtitle[note]{Note}
1076 This is a note.
1079 \DUadmonition[tip]{
1080 \DUtitle[tip]{Tip}
1082 15\% if the service is good.
1085 \DUadmonition[warning]{
1086 \DUtitle[warning]{Warning}
1088 Strong prose may provoke extreme mental exertion.
1089 Reader discretion is strongly advised.
1092 \DUadmonition[admonition-and-by-the-way]{
1093 \DUtitle[admonition-and-by-the-way]{And, by the way…}
1095 You can make up your own admonition too.
1099 \subsubsection{2.14.4~~~Topics, Sidebars, and Rubrics%
1100 \label{topics-sidebars-and-rubrics}%
1103 \emph{Sidebars} are like miniature, parallel documents.
1105 \DUsidebar{
1106 \DUtitle[title]{Sidebar Title}
1108 \DUsubtitle[sidebar]{Optional Subtitle}
1110 This is a sidebar. It is for text outside the flow of the main
1111 text.
1113 \DUrubric{This is a rubric inside a sidebar}
1115 Sidebars often appear beside the main text with a border and a different
1116 background or font color.
1119 A \emph{topic} is like a block quote with a title, or a self-contained section
1120 with no subsections.
1122 \DUtopic[]{
1123 \DUtitle[title]{Topic Title}
1125 This is a topic.
1128 A \emph{rubric} is like an informal heading that doesn’t correspond to the
1129 document’s structure. It is typically highlighted in red (hence the name).
1131 \DUrubric{This is a rubric}
1133 Topics and rubrics can be used at places where a \hyperref[section-title]{section title} is not
1134 allowed (e.g. inside a directive).
1137 \subsubsection{2.14.5~~~Target Footnotes%
1138 \label{target-footnotes}%
1141 \DUfootnotetext{id29}{id30}{5}{%
1142 \url{http://www.python.org/}
1145 \DUfootnotetext{id33}{id34}{6}{%
1146 \url{http://pygments.org/}
1149 \DUfootnotetext{id35}{id36}{7}{%
1150 \url{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf}
1153 \DUfootnotetext{id39}{id40}{8}{%
1154 \url{http://docutils.sourceforge.net/}
1157 \DUfootnotetext{id41}{id42}{9}{%
1158 \url{A:DOS\\path\\}
1162 \subsubsection{2.14.6~~~Replacement Text%
1163 \label{replacement-text}%
1166 I recommend you try \href{http://www.python.org/}{Python, \emph{the} best language around}\DUfootnotemark{id32}{id29}{5}.
1169 \subsubsection{2.14.7~~~Compound Paragraph%
1170 \label{compound-paragraph}%
1173 Compound 1, paragraph 1.
1175 Compound 1, paragraph 2.
1177 \begin{itemize}
1179 \item Compound 1, list item one.
1181 \item Compound 1, list item two.
1183 \end{itemize}
1185 Another compound statement:
1187 Compound 2, a literal block:
1189 \begin{quote}{\ttfamily \raggedright \noindent
1190 Compound~2,~literal.
1192 \end{quote}
1193 Compound 2, this is a test.
1195 Compound 3, only consisting of one paragraph.
1197 \begin{quote}{\ttfamily \raggedright \noindent
1198 Compound~4.\\
1199 This~one~starts~with~a~literal~block.
1201 \end{quote}
1202 Compound 4, a paragraph.
1204 Now something \emph{really} perverted – a nested compound block. This is
1205 just to test that it works at all; the results don’t have to be
1206 meaningful.
1208 Compound 5, block 1 (a paragraph).
1210 Compound 6, block 2 in compound 5.
1212 Compound 6, another paragraph.
1214 Compound 5, block 3 (a paragraph).
1216 Compound 7, with a table inside:
1218 \setlength{\DUtablewidth}{\linewidth}
1219 \begin{longtable*}[c]{|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|}
1220 \hline
1222 Left cell, first
1223 paragraph.
1225 Left cell, second
1226 paragraph.
1228 Middle cell,
1229 consisting of
1230 exactly one
1231 paragraph.
1233 Right cell.
1235 Paragraph 2.
1237 Paragraph 3.
1239 \hline
1240 \end{longtable*}
1241 Compound 7, a paragraph after the table.
1243 Compound 7, another paragraph.
1246 \subsubsection{2.14.8~~~Parsed Literal Blocks%
1247 \label{parsed-literal-blocks}%
1250 \begin{quote}{\ttfamily \raggedright \noindent
1251 This~is~a~parsed~literal~block.\\
1252 ~~~~This~line~is~indented.~~The~next~line~is~blank.\\
1254 Inline~markup~is~supported,~e.g.~\emph{emphasis},~\textbf{strong},~\texttt{literal\\
1255 text},~footnotes\DUfootnotemark{id22}{id8}{1},~%
1256 \phantomsection\label{hyperlink-targets}hyperlink~targets,~and~\href{http://www.python.org/}{references}.
1258 \end{quote}
1261 \subsubsection{2.14.9~~~Code%
1262 \label{code}%
1265 Blocks of source code can be set with the \DUroletitlereference{code} directive. If the code
1266 language is specified, the content is parsed and tagged by the \href{http://pygments.org/}{Pygments}\DUfootnotemark{id34}{id33}{6}
1267 syntax highlighter and can be formatted with a style sheet. (Code parsing
1268 is turned off using the \texttt{syntax-highlight} config setting in the test
1269 conversions in order to get identical results with/without installed
1270 Pygments highlighter.)
1272 \begin{quote}{\ttfamily \raggedright \noindent
1273 print~'This~is~Python~code.'
1275 \end{quote}
1277 The \texttt{:number-lines:} option (with optional start value) generates line
1278 numbers:
1280 \begin{quote}{\ttfamily \raggedright \noindent
1281 \DUrole{ln}{~8~}\#~print~integers~from~0~to~9:\\
1282 \DUrole{ln}{~9~}for~i~in~range(10):\\
1283 \DUrole{ln}{10~}~~~~print~i
1285 \end{quote}
1287 For inline code snippets, there is the \DUroletitlereference{code} role, which can be used
1288 directly (the code will not be parsed/tagged, as the language is not known)
1289 or as base for special code roles, e.g. the LaTeX code in the next
1290 paragraph.
1292 Docutils uses LaTeX syntax for math directives and roles:
1293 \texttt{\DUrole{code}{\DUrole{tex}{\textbackslash{}alpha = f(x)}}} prints $\alpha = f(x)$.
1295 The \texttt{:code:} option of the \DUroletitlereference{include} directive sets the included content
1296 as a code block, here the rst file \texttt{header\_footer.txt} with line numbers:
1298 \begin{quote}{\ttfamily \raggedright \noindent
1299 \DUrole{ln}{1~}..~header::~Document~header\\
1300 \DUrole{ln}{2~}..~footer::~Document~footer
1302 \end{quote}
1305 \subsection{2.15~~~Substitution Definitions%
1306 \label{substitution-definitions}%
1309 An inline image (\includegraphics{../../../docs/user/rst/images/biohazard.png}) example:
1311 (Substitution definitions are not visible in the HTML source.)
1314 \subsection{2.16~~~Comments%
1315 \label{comments}%
1318 Here’s one:
1320 % Comments begin with two dots and a space. Anything may
1321 % follow, except for the syntax of footnotes, hyperlink
1322 % targets, directives, or substitution definitions.
1324 % Double-dashes -- "--" -- must be escaped somehow in HTML output.
1326 % Comments may contain non-ASCII characters: ä ö ü æ ø å
1328 (View the HTML source to see the comment.)
1331 \subsection{2.17~~~Raw text%
1332 \label{raw-text}%
1335 This does not necessarily look nice, because there may be missing white space.
1337 It’s just there to freeze the behavior.
1339 A test.
1341 Second test.
1343 \DUrole{myclass}{Another test with myclass set.}
1345 This is the \DUrole{myrawroleclass}{fourth test} with myrawroleclass set.
1347 Fifth test in LaTeX.\\Line two.
1350 \subsection{2.18~~~Container%
1351 \label{container}%
1354 paragraph 1
1356 paragraph 2
1358 % currently not implemented in LaTeX:
1359 % .. include:: data/header_footer.txt
1362 \subsection{2.19~~~Colspanning tables%
1363 \label{colspanning-tables}%
1366 This table has a cell spanning two columns:
1368 \setlength{\DUtablewidth}{\linewidth}
1369 \begin{longtable*}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.086\DUtablewidth}|}
1370 \hline
1371 \multicolumn{2}{|p{0.15\DUtablewidth}|}{\textbf{%
1372 Inputs
1373 }} & \textbf{%
1374 Output
1375 } \\
1376 \hline
1377 \textbf{%
1379 } & \textbf{%
1381 } & \textbf{%
1382 A or B
1383 } \\
1384 \hline
1385 \endfirsthead
1386 \hline
1387 \multicolumn{2}{|p{0.15\DUtablewidth}|}{\textbf{%
1388 Inputs
1389 }} & \textbf{%
1390 Output
1391 } \\
1392 \hline
1393 \textbf{%
1395 } & \textbf{%
1397 } & \textbf{%
1398 A or B
1399 } \\
1400 \hline
1401 \endhead
1402 \multicolumn{3}{c}{\hfill ... continued on next page} \\
1403 \endfoot
1404 \endlastfoot
1406 False
1408 False
1410 False
1412 \hline
1414 True
1416 False
1418 True
1420 \hline
1422 False
1424 True
1426 True
1428 \hline
1430 True
1432 True
1434 True
1436 \hline
1437 \end{longtable*}
1440 \subsection{2.20~~~Rowspanning tables%
1441 \label{rowspanning-tables}%
1444 Here’s a table with cells spanning several rows:
1446 \setlength{\DUtablewidth}{\linewidth}
1447 \begin{longtable*}[c]{|p{0.296\DUtablewidth}|p{0.156\DUtablewidth}|p{0.226\DUtablewidth}|}
1448 \hline
1449 \textbf{%
1450 Header row, column 1
1451 (header rows optional)
1452 } & \textbf{%
1453 Header 2
1454 } & \textbf{%
1455 Header 3
1456 } \\
1457 \hline
1458 \endfirsthead
1459 \hline
1460 \textbf{%
1461 Header row, column 1
1462 (header rows optional)
1463 } & \textbf{%
1464 Header 2
1465 } & \textbf{%
1466 Header 3
1467 } \\
1468 \hline
1469 \endhead
1470 \multicolumn{3}{c}{\hfill ... continued on next page} \\
1471 \endfoot
1472 \endlastfoot
1474 body row 1, column 1
1476 column 2
1478 column 3
1480 \hline
1482 body row 2
1483 & \multirow{2}{0.16\DUtablewidth}{%
1484 Cells may
1485 span rows.
1486 } & \multirow{2}{0.23\DUtablewidth}{%
1487 Another
1488 rowspanning
1489 cell.
1490 } \\
1491 \cline{1-1}
1493 body row 3
1494 & \\
1495 \hline
1496 \end{longtable*}
1499 \subsection{2.21~~~Custom Roles%
1500 \label{custom-roles}%
1503 \begin{itemize}
1505 \item A role based on an existing role.
1507 \texttt{\DUrole{custom}{one}} \texttt{\DUrole{custom}{two}} \texttt{\DUrole{custom}{three}}
1509 \item A new role.
1511 \DUrole{customnew}{one two three}
1513 \item A role with class attribute.
1515 \DUrole{special}{interpreted text}
1517 \item A language-switching role:
1519 Let’s count in German \foreignlanguage{ngerman}{eins zwei drei}.
1521 \item A role with multiple class attributes, styled with raw directives:
1523 \newcommand{\DUrolegreen}[1]{\textcolor{green}{#1}}
1524 \newcommand{\DUrolesc}[1]{\textsc{#1}}
1526 The following works in most browsers but does not validate
1527 (\texttt{<style>} is only allowed in the document head):
1529 \begin{quote}{\ttfamily \raggedright \noindent
1530 ..~raw::~html\\
1532 ~~<style~type=\textquotedbl{}text/css\textquotedbl{}><!-{}-\\
1533 ~~~.green~\{color:~green;\}\\
1534 ~~~.sc~\{font-variant:~small-caps;\}\\
1535 ~~~-{}-></style>
1537 \end{quote}
1539 \DUrole{green}{\DUrole{sc}{\foreignlanguage{british}{British colourful text in small-caps}}}.
1541 \end{itemize}
1544 \subsection{2.22~~~Mathematics%
1545 \label{mathematics}%
1548 Docutils supports inline math with the prefix or postfix \texttt{:math:}
1549 role specificator, $n! + \sin(x_n^2)$ and $A_\text{c} =
1550 \frac{\pi}{4} d^2$, as well as displayed math via the
1551 \DUroletitlereference{math} directive:
1553 \begin{equation*}
1554 f(\epsilon) = \frac{1}{1 + \exp\left(\frac{\varepsilon}{k_\text{B}T}\right)}
1555 \end{equation*}
1556 Content may start on the first line of the directive, e.g.
1558 \begin{equation*}
1559 N = \frac{\text{number of apples}}{7}
1560 \end{equation*}
1561 Equations can be labeled with a reference name using the \texttt{:name:} option.
1562 See \hyperref[eq-m]{eq:M} and \hyperref[eq-schrodinger]{eq:schrödinger} below.
1564 The determinant of the matrix
1566 \begin{equation*}
1567 \mathbf{M} = \left(\begin{matrix}a&b\\c&d\end{matrix}\right)
1568 \phantomsection
1569 \label{eq-m}
1570 \end{equation*}
1571 is $|\mathbf{M}| = ad - bc$.
1573 More than one display math block can be put in one math directive.
1574 For example, the following sum and integral with limits:
1576 \begin{equation*}
1577 \int_0^1 x^n dx = \frac{1}{n + 1}
1578 \end{equation*}%
1579 \begin{equation*}
1580 \sum_{n=1}^m n = \frac{m(m+1)}{2}
1581 \end{equation*}
1582 LaTeX-supported Unicode math symbols can be used in math roles and
1583 directives:
1585 The Schrödinger equation
1587 \begin{equation*}
1588 i\hbar \frac{\partial }{\partial t}\Psi = \hat{H}\Psi ,
1589 \phantomsection
1590 \label{eq-schrodinger}
1591 \end{equation*}
1592 with the \emph{wave function} $\Psi $, describes how the quantum state of a
1593 physical system changes in time.
1595 \begin{description}
1596 \item[{Math-Accents:}] \leavevmode
1597 \setlength{\DUtablewidth}{\linewidth}
1598 \begin{longtable*}[c]{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
1600 $\acute{a}$ \texttt{\textbackslash{}acute\{a\}}
1602 $\dot{t}$ \texttt{\textbackslash{}dot\{t\}}
1604 $\hat{\gamma}$ \texttt{\textbackslash{}hat\{\textbackslash{}gamma\}}
1607 $\grave{a}$ \texttt{\textbackslash{}grave\{a\}}
1609 $\ddot{t}$ \texttt{\textbackslash{}ddot\{t\}}
1611 $\tilde{\alpha}$ \texttt{\textbackslash{}tilde\{\textbackslash{}alpha\}}
1614 $\breve{x}$ \texttt{\textbackslash{}breve\{x\}}
1616 $\dddot{t}$ \texttt{\textbackslash{}dddot\{t\}}
1618 $\vec{\imath}$ \texttt{\textbackslash{}vec\{\textbackslash{}imath\}}
1621 $\check{a}$ \texttt{\textbackslash{}check\{a\}}
1623 $\bar{a}$ \texttt{\textbackslash{}bar\{a\}}
1625 $\vec{R}$ \texttt{\textbackslash{}vec\{R\}}
1627 \end{longtable*}
1629 \end{description}
1631 % \widetilde{xxx}
1632 % \widehat{xxx}
1634 Modulation Transfer Function:
1636 \begin{equation*}
1637 \text{MTF} = \left|\frac{\mathcal{F}\{s(x)\}}
1638 {\mathcal{F}\{ s(x)\} |_{\omega _{x}=0}}\right|
1639 = \mathrm{abs}\left(\frac
1640 {\int _{-\infty }^{\infty }s(x) \mathrm{e}^{\mathrm{i}\omega _{x}x}\mathrm{d}{x}}
1641 {\int _{-\infty }^{\infty }s(x)\mathrm{d}{x}}
1642 \right).
1643 \end{equation*}
1644 Math split over two lines: If a double backslash is detected outside a
1645 \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{id36}{id35}{7}
1646 \texttt{align} environment:
1648 \begin{align*}
1649 s_{\mathrm{out}}(x) & = s_{\mathrm{in}}(x') * s_\delta (x-x') \\
1650 & = \int s_{\mathrm{in}}(x')s_\delta (x-x')\mathrm{d}x'
1651 \end{align*}
1652 Cases (“manually”, with \texttt{matrix} environment):
1654 \begin{equation*}
1655 \mathrm{sgn}(x) = \left\{\begin{matrix}
1656 -1 & x<0\\
1657 1 & x>0
1658 \end{matrix}\right.
1659 \end{equation*}
1660 Cases with the \href{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf}{AMSmath}\DUfootnotemark{id37}{id35}{7} \texttt{cases} environment (not (yet) supported by
1661 HTML writers with \texttt{-{}-math-output=MathML}):
1663 \begin{equation*}
1664 \mathrm{sgn}(x) = \begin{cases}
1665 -1 & x<0\\
1666 1 & x>0
1667 \end{cases}
1668 \end{equation*}
1670 \section{3~~~Tests for the LaTeX writer%
1671 \label{tests-for-the-latex-writer}%
1674 Test syntax elements which may cause trouble for the LaTeX writer but might
1675 not need to be tested with other writers (e.g. the HTML writer).
1678 \subsection{3.1~~~Custom Roles in LaTeX%
1679 \label{custom-roles-in-latex}%
1682 \begin{itemize}
1684 \item Role names and class arguments are converted to conform to the
1685 regular expression \texttt{{[}a-z{]}{[}-a-z0-9{]}*} (letters are downcased,
1686 accents and similar decoration is stripped, non-conforming
1687 characters are replaced by a hyphen).
1689 Class arguments may contain numbers and hyphens, which need special
1690 treatment in LaTeX command names.
1692 \DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{Interpreted Text}}}}}
1694 \item With LaTeX, roles can be styled within the document using the \DUroletitlereference{raw}
1695 directive.
1697 \newcommand{\DUrolelarge}[1]{{\large #1}}
1698 \makeatletter
1699 \@namedef{DUrolesmall-caps}{\textsc}
1700 \@namedef{DUrolecustom4}{\textbf}
1701 \makeatother
1703 \DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{Interpreted Text}}}}} in large, bold, small-caps.
1705 \item Custom roles can be based on standard roles:
1707 This is a \emph{\DUrole{custom-emphasis}{customized emphasis text role}}
1709 This is a \texttt{\DUrole{custom-literal}{customized literal text role}}
1711 This is a \textbf{\DUrole{custom-strong}{customized strong text role}}
1713 This is a \textsubscript{\DUrole{custom-subscript}{customized subscript text role}}
1715 This is a \textsuperscript{\DUrole{custom-superscript}{customized superscript text role}}
1717 This is a \DUroletitlereference{\DUrole{custom-title-reference}{customized title-reference text role}}
1719 \end{itemize}
1722 \subsection{3.2~~~More Tables%
1723 \label{more-tables}%
1726 A multicolumn table with multi-paragraph rowspanning cells:
1728 \setlength{\DUtablewidth}{\linewidth}
1729 \begin{longtable*}[c]{|p{0.133\DUtablewidth}|p{0.179\DUtablewidth}|p{0.179\DUtablewidth}|p{0.110\DUtablewidth}|p{0.121\DUtablewidth}|p{0.145\DUtablewidth}|}
1730 \hline
1732 test
1734 \textbf{bold hd}
1735 & \multicolumn{3}{p{0.41\DUtablewidth}|}{
1736 multicolumn 1
1738 With a second paragraph
1739 } &
1740 \emph{emph hd}
1742 \hline
1743 \multicolumn{2}{|p{0.31\DUtablewidth}|}{
1744 multicolumn 2
1746 With a second paragraph
1747 } &
1748 cell
1750 cell
1752 cell
1754 cell
1756 \hline
1758 cell
1759 & \multicolumn{2}{p{0.36\DUtablewidth}|}{
1760 multicolumn 3 (one line,
1761 but very very very very
1762 very looooong)
1763 } &
1764 cell
1766 cell
1768 cell
1770 \hline
1772 cell
1774 cell
1776 cell
1777 & \multicolumn{3}{p{0.38\DUtablewidth}|}{
1778 Short multicolumn 4
1779 } \\
1780 \hline
1781 \end{longtable*}
1783 A table with multirow header
1785 \begin{quote}
1787 \setlength{\DUtablewidth}{\linewidth}
1788 \begin{longtable*}[c]{|p{0.156\DUtablewidth}|p{0.238\DUtablewidth}|}
1789 \hline
1790 \multirow{2}{0.16\DUtablewidth}{%
1791 \textbf{%
1793 }} & \textbf{%
1794 Variable Summary
1795 } \\
1796 \cline{2-2}
1797 & \textbf{%
1798 Description
1799 } \\
1800 \hline
1801 \endfirsthead
1802 \hline
1803 \multirow{2}{0.16\DUtablewidth}{%
1804 \textbf{%
1806 }} & \textbf{%
1807 Variable Summary
1808 } \\
1809 \cline{2-2}
1810 & \textbf{%
1811 Description
1812 } \\
1813 \hline
1814 \endhead
1815 \multicolumn{2}{c}{\hfill ... continued on next page} \\
1816 \endfoot
1817 \endlastfoot
1818 \multicolumn{2}{|p{0.39\DUtablewidth}|}{
1819 multirow header breaks latex
1820 } \\
1821 \hline
1822 \end{longtable*}
1824 \end{quote}
1826 % This file is used by the standalone_rst_latex test.
1829 \subsection{3.3~~~Option lists%
1830 \label{id23}%
1833 The LaTeX-2e description environment is used for definition lists.
1834 The definition is continued on the same line as the term, this should
1835 not happen if a option-list is at the top of the definition.
1837 If the option list is not at the first element in the definition, it
1838 is contained in a quote
1840 \begin{quote}
1842 \begin{DUoptionlist}
1844 \item[-{}-help] show help
1846 \item[-v] verbose
1848 \end{DUoptionlist}
1850 \end{quote}
1852 \begin{description}
1853 \item[{In a definition list:}] \leavevmode %
1854 \begin{DUoptionlist}
1856 \item[-{}-help] show help
1858 \item[-v] verbose
1860 \end{DUoptionlist}
1862 \end{description}
1865 \subsection{3.4~~~Monospaced non-alphanumeric characters%
1866 \label{monospaced-non-alphanumeric-characters}%
1869 These are all ASCII characters except a-zA-Z0-9 and space:
1871 \texttt{!!!\textquotedbl{}\textquotedbl{}\textquotedbl{}\#\#\#\$\$\$\%\%\%\&\&\&'{}'{}'((()))***+++,{},{},-{}-{}-...///:::}
1873 \texttt{;;;<{}<{}<===>{}>{}>???@@@{[}{[}{[}\textbackslash{}\textbackslash{}\textbackslash{}{]}{]}{]}\textasciicircum{}\textasciicircum{}\textasciicircum{}\_\_\_`{}`{}`\{\{\{|||\}\}\}\textasciitilde{}\textasciitilde{}\textasciitilde{}}
1875 \texttt{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
1877 The two lines of non-alphanumeric characters should both have the same
1878 width as the third line.
1881 \subsection{3.5~~~Non-ASCII characters%
1882 \label{non-ascii-characters}%
1885 Punctuation and footnote symbols
1887 \setlength{\DUtablewidth}{\linewidth}
1888 \begin{longtable*}[c]{|p{0.028\DUtablewidth}|p{0.424\DUtablewidth}|}
1889 \hline
1893 en-dash
1895 \hline
1899 em-dash
1901 \hline
1905 single turned comma quotation mark
1907 \hline
1911 single comma quotation mark
1913 \hline
1917 low single comma quotation mark
1919 \hline
1923 double turned comma quotation mark
1925 \hline
1929 double comma quotation mark
1931 \hline
1935 low double comma quotation mark
1937 \hline
1941 dagger
1943 \hline
1947 double dagger
1949 \hline
1951 \ding{169}
1953 black diamond suit
1955 \hline
1957 \ding{170}
1959 black heart suit
1961 \hline
1963 $\spadesuit$
1965 black spade suit
1967 \hline
1969 $\clubsuit$
1971 black club suit
1973 \hline
1977 ellipsis
1979 \hline
1983 trade mark sign
1985 \hline
1987 $\Leftrightarrow$
1989 left-right double arrow
1991 \hline
1992 \end{longtable*}
1994 The \DUroletitlereference{Latin-1 extended} Unicode block
1996 \setlength{\DUtablewidth}{\linewidth}
1997 \begin{longtable*}[c]{|p{0.051\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|}
1998 \hline
2022 \hline
2025 & &
2031 & &
2042 \hline
2066 \hline
2090 \hline
2114 \hline
2138 \hline
2162 \hline
2186 \hline
2210 \hline
2234 \hline
2249 & & & & \\
2250 \hline
2251 \end{longtable*}
2253 \begin{itemize}
2255 \item The following line should not be wrapped, because it uses
2256 no-break spaces (\textbackslash{}u00a0):
2258 X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X~X
2260 \item Line wrapping with/without breakpoints marked by soft hyphens
2261 (\textbackslash{}u00ad):
2263 pdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-sch
2265 pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch
2267 \item The currency sign (\textbackslash{}u00a4) is not supported by all fonts
2268 (some have an Euro sign at its place). You might see an error
2269 like:
2271 \begin{quote}{\ttfamily \raggedright \noindent
2272 !~Package~textcomp~Error:~Symbol~\textbackslash{}textcurrency~not~provided~by\\
2273 (textcomp)~~~~~~~~~~~~~~~~font~family~ptm~in~TS1~encoding.\\
2274 (textcomp)~~~~~~~~~~~~~~~~Default~family~used~instead.
2276 \end{quote}
2278 (which in case of font family ptm is a false positive). Add either
2280 \begin{DUfieldlist}
2281 \item[{warn:}]
2282 turn the error in a warning, use the default symbol (bitmap), or
2284 \item[{force,almostfull:}]
2285 use the symbol provided by the font at the users
2286 risk,
2288 \end{DUfieldlist}
2290 to the document options or use a different font package.
2292 \end{itemize}
2295 \subsection{3.6~~~Encoding special chars%
2296 \label{encoding-special-chars}%
2299 The LaTeX Info pages lists under “2.18 Special Characters”
2301 \begin{quote}
2303 The following characters play a special role in LaTeX and are called
2304 “special printing characters”, or simply “special characters”.
2306 \begin{quote}
2308 \# \$ \% \& \textasciitilde{} \_ \textasciicircum{} \textbackslash{} \{ \}
2310 \end{quote}
2312 \end{quote}
2314 The special chars verbatim:
2316 \begin{quote}{\ttfamily \raggedright \noindent
2317 \#~\$~\%~\&~\textasciitilde{}~\_~\textasciicircum{}~\textbackslash{}~\{~\}
2319 \end{quote}
2321 However also \emph{square brackets} {[}{]} need special care.
2323 \begin{quote}
2325 item and all the other commands with optional arguments check
2326 if the token right after the macro name is an opening bracket.
2327 In that case the contents between that bracket and the following
2328 closing bracket on the same grouping level are taken as the
2329 optional argument. What makes this unintuitive is the fact that
2330 the square brackets aren’t grouping characters themselves, so in
2331 your last example item{[}{[}{]}{]} the optional argument consists of
2332 {[}… (without the closing bracket).
2334 \end{quote}
2336 Compare the items in the following lists:
2338 \begin{itemize}
2340 \item simple item
2342 \item {[}bracketed{]} item
2344 \end{itemize}
2346 \begin{description}
2347 \item[{simple}] \leavevmode
2348 description term
2350 \item[{{[}bracketed{]}}] \leavevmode
2351 description term
2353 \end{description}
2355 The OT1 font-encoding has different characters for the less-than,
2356 greater-than and bar, < | >, except for typewriter font \DUroletitlereference{cmtt}:
2358 \begin{quote}{\ttfamily \raggedright \noindent
2359 <~|~>
2361 \end{quote}
2364 \subsection{3.7~~~Hyperlinks and -targets%
2365 \label{hyperlinks-and-targets}%
2368 In LaTeX, we must set an explicit anchor (\texttt{\textbackslash{}phantomsection}) for a
2370 \phantomsection\label{hypertarget-in-plain-text}hypertarget in plain text or in a figure but not in a longtable or
2371 caption:
2373 \setlength{\DUtablewidth}{\linewidth}
2374 \begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
2375 \caption{Table with %
2376 \label{hypertarget-in-table-title}hypertarget in table title.}\\
2377 \hline
2379 False
2381 True
2383 None
2385 \hline
2386 \end{longtable}
2387 \label{table-label}
2389 \begin{figure}
2390 \phantomsection\label{figure-label}
2391 \noindent\makebox[\textwidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}}
2392 \caption{Figure with %
2393 \label{hypertarget-in-figure-caption}hypertarget in figure caption.}
2394 \begin{DUlegend}
2395 Legend with %
2396 \phantomsection\label{hypertarget-in-figure-legend}hypertarget in figure legend.
2397 \end{DUlegend}
2398 \end{figure}
2400 \includegraphics{../../../docs/user/rst/images/biohazard.png}
2401 \phantomsection\label{image-label}
2403 See \hyperref[hypertarget-in-plain-text]{hypertarget in plain text},
2404 \hyperref[table-label]{table label}, \hyperref[hypertarget-in-table-title]{hypertarget in table title},
2405 \hyperref[figure-label]{figure label}, \hyperref[hypertarget-in-figure-caption]{hypertarget in figure caption},
2406 \hyperref[hypertarget-in-figure-legend]{hypertarget in figure legend}, and
2407 \hyperref[image-label]{image label}.
2410 \subsection{3.8~~~External references%
2411 \label{external-references}%
2414 Long URLs should be wrapped in the PDF.
2415 This can be achieved with the url command which is used by the LaTeX writer
2416 whenever the content (name) of a reference node equals the link URL.
2418 \begin{description}
2419 \item[{Example:}] \leavevmode
2420 a long URL that should wrap in the output
2421 \url{http://docutils.sourceforge.net/docs/user/latex.html\#id79}
2423 \end{description}
2425 If the argument contains any “\%”, “\#”, or “\textasciicircum{}\textasciicircum{}”, or ends with \texttt{\textbackslash{}}, it can’t
2426 be used in the argument to another command. The argument must not contain
2427 unbalanced braces.
2429 The characters \textasciicircum{}, \{, \}, and \texttt{\textbackslash{}} are invalid in a “http:” or “ftp:” URL
2430 and not recognized as part of it:
2432 \begin{DUlineblock}{0em}
2433 \item[] \url{http://www.example.org}/strange\textasciicircum{}\textasciicircum{}name
2434 \item[] \url{http://www.example.org}\textbackslash{}using\textbackslash{}DOS\textbackslash{}paths\textbackslash{}
2435 \item[] \url{http://www.example.org/XML}/strange\{n\}ame
2436 \end{DUlineblock}
2438 They can, however be used in paths and/or filenames.
2440 Handling by the LaTeX writer:
2442 \begin{itemize}
2444 \item \texttt{\#}, \texttt{\textbackslash{}} and \texttt{\%} are escaped:
2446 \begin{DUlineblock}{0em}
2447 \item[] \href{http://www.w3.org/XML/Schema\#dev}{URL with \#}
2448 \url{http://www.w3.org/XML/Schema\#dev}
2449 \item[] \href{http://www.w3.org/XML/Schema\%dev}{URL with \%}
2450 \url{http://example.org/Schema\%dev}
2451 \item[] \href{A:DOS\\path\\}{file with DOS path}\DUfootnotemark{id42}{id41}{9} \url{A:DOS\\path\\}\DUfootnotemark{id43}{id41}{9}
2452 \end{DUlineblock}
2454 \DUadmonition[note]{
2455 \DUtitle[note]{Note}
2457 These URLs are typeset inside a LaTeX command without error.
2459 \begin{DUlineblock}{0em}
2460 \item[] \url{http://www.w3.org/XML/Schema\#dev}
2461 \item[] \url{http://example.org/Schema\%dev}
2462 \item[] \url{A:DOS\\path\\}\DUfootnotemark{id44}{id41}{9}
2463 \end{DUlineblock}
2466 \end{itemize}
2468 \begin{itemize}
2470 \item \textasciicircum{}\textasciicircum{} LaTeX’s special syntax for characters results in “strange” replacements
2471 (both with href and url). A warning is given.
2473 \href{../strange^^name}{file with \textasciicircum{}\textasciicircum{}}:
2474 \url{../strange^^name}
2476 \item Unbalanced braces, \{ or \}, will fail (both with href and url):
2478 \begin{quote}{\ttfamily \raggedright \noindent
2479 `file~with~\{~<../strange\{name>`\_\_\\
2480 `<../strange\{name>`\_\_
2482 \end{quote}
2484 while balanced braces are suported:
2486 \begin{DUlineblock}{0em}
2487 \item[] \url{../strange{n}ame}
2488 \item[] \url{../st{r}ange{n}ame}
2489 \item[] \url{../{st{r}ange{n}ame}}
2490 \end{DUlineblock}
2492 \end{itemize}
2495 \subsection{3.9~~~Section titles with \hyperref[inline-markup]{inline markup}%
2496 \label{section-titles-with-inline-markup}%
2500 \subsubsection{3.9.1~~~\emph{emphasized}, H\textsubscript{2}O and $x^2$%
2501 \label{emphasized-h2o-and-x-2}%
2505 \subsubsection{3.9.2~~~Substitutions work%
2506 \label{substitutions-fail}%
2510 \subsection{3.10~~~Deeply nested sections%
2511 \label{deeply-nested-sections}%
2514 In LaTeX and HTML,
2517 \subsubsection{3.10.1~~~Level 3%
2518 \label{level-3}%
2521 nested sections
2524 \paragraph{3.10.1.1~~~level 4%
2525 \label{level-4}%
2528 reach at some level
2531 \subparagraph{3.10.1.1.1~~~level 5%
2532 \label{level-5}%
2535 (depending on the document class)
2538 \DUtitle[sectionVI]{3.10.1.1.1.1~~~level 6%
2539 \label{level-6}%
2542 an unsupported level.
2544 % unusual combinations (from newlatex, for interactive testing)
2545 % .. include:: data/latex.txt
2547 % Preface for System Messages:
2550 \section{4~~~Error Handling%
2551 \label{error-handling}%
2554 Any errors caught during processing will generate system messages.
2556 There should be five messages in the following, auto-generated
2557 section, “Docutils System Messages”:
2559 % section should be added by Docutils automatically
2562 \section[Docutils System Messages]{\color{red}Docutils System Messages%
2565 \DUadmonition[system-message]{
2566 \DUtitle[system-message]{system-message}
2567 \raisebox{1em}{\hypertarget{id27}{}}
2569 {\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~104
2571 \hyperlink{id28}{
2572 Undefined substitution referenced: \textquotedbl{}problematic\textquotedbl{}.
2575 \DUadmonition[system-message]{
2576 \DUtitle[system-message]{system-message}
2577 \raisebox{1em}{\hypertarget{id45}{}}
2579 {\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~391
2581 \hyperlink{id46}{
2582 Unknown target name: \textquotedbl{}5\textquotedbl{}.
2585 \DUadmonition[system-message]{
2586 \DUtitle[system-message]{system-message}
2587 \raisebox{1em}{\hypertarget{id47}{}}
2589 {\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~400
2591 \hyperlink{id48}{
2592 Unknown target name: \textquotedbl{}nonexistent\textquotedbl{}.
2595 \DUadmonition[system-message]{
2596 \DUtitle[system-message]{system-message}
2597 \raisebox{1em}{\hypertarget{id49}{}}
2599 {\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~427
2601 \hyperlink{id50}{
2602 Unknown target name: \textquotedbl{}hyperlink reference without a target\textquotedbl{}.
2605 \DUadmonition[system-message]{
2606 \DUtitle[system-message]{system-message}
2607 \raisebox{1em}{\hypertarget{id51}{}}
2609 {\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~440
2611 \hyperlink{id52}{
2612 Duplicate target name, cannot be used as a unique reference: \textquotedbl{}duplicate target names\textquotedbl{}.
2615 \end{document}