latex writer: fix fallback definition of \DUroles macro.
[docutils.git] / docutils / test / functional / expected / latex_literal_block_fancyvrb.tex
blobed609e8d62283ca0f65434a16d2e2bff62d4e663
1 \documentclass[a4paper]{article}
2 % generated by Docutils <http://docutils.sourceforge.net/>
3 \usepackage{cmap} % fix search and cut-and-paste in Acrobat
4 \usepackage{ifthen}
5 \usepackage[T1]{fontenc}
6 \usepackage[utf8]{inputenc}
7 \usepackage{amsmath}
8 \usepackage{graphicx}
9 \usepackage{fancyvrb}
10 \usepackage{longtable,ltcaption,array}
11 \setlength{\extrarowheight}{2pt}
12 \newlength{\DUtablewidth} % internal use in tables
14 %%% Custom LaTeX preamble
15 % PDF Standard Fonts
16 \usepackage{mathptmx} % Times
17 \usepackage[scaled=.90]{helvet}
18 \usepackage{courier}
20 %%% User specified packages and stylesheets
22 %%% Fallback definitions for Docutils-specific commands
24 % class handling for environments (block-level elements)
25 % \begin{DUclass}{spam} tries \DUCLASSspam and
26 % \end{DUclass}{spam} tries \endDUCLASSspam
27 \ifx\DUclass\undefined % poor man's "provideenvironment"
28 \newenvironment{DUclass}[1]%
29 {\def\DocutilsClassFunctionName{DUCLASS#1}% arg cannot be used in end-part of environment.
30 \csname \DocutilsClassFunctionName \endcsname}%
31 {\csname end\DocutilsClassFunctionName \endcsname}%
32 \fi
33 % numeric or symbol footnotes with hyperlinks
34 \providecommand*{\DUfootnotemark}[3]{%
35 \raisebox{1em}{\hypertarget{#1}{}}%
36 \hyperlink{#2}{\textsuperscript{#3}}%
38 \providecommand{\DUfootnotetext}[4]{%
39 \begingroup%
40 \renewcommand{\thefootnote}{%
41 \protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
42 \protect\hyperlink{#2}{#3}}%
43 \footnotetext{#4}%
44 \endgroup%
47 % inline markup (custom roles)
48 % \DUrole{#1}{#2} tries \DUrole#1{#2}
49 \providecommand*{\DUrole}[2]{%
50 \ifcsname DUrole#1\endcsname%
51 \csname DUrole#1\endcsname{#2}%
52 \else
53 % backwards compatibility: try \docutilsrole#1{#2}
54 \ifcsname docutilsrole#1\endcsname%
55 \csname docutilsrole#1\endcsname{#2}%
56 \else%
57 #2%
58 \fi%
59 \fi%
62 % text mode subscript
63 \ifx\textsubscript\undefined
64 \usepackage{fixltx2e} % since 2015 loaded by default
65 \fi
67 % titlereference role
68 \providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
70 % character width in monospaced font
71 \newlength{\ttemwidth}
72 \settowidth{\ttemwidth}{\ttfamily M}
74 % hyperlinks:
75 \ifthenelse{\isundefined{\hypersetup}}{
76 \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
77 \usepackage{bookmark}
78 \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
79 }{}
81 %%% Body
82 \begin{document}
84 In LaTeX, literal blocks can be customized with the \textquotedbl{}literal-block-env\textquotedbl{}
85 setting. This test file exists to check the latex writer output compiles and
86 looks as expected. Start with a plain literal block:
88 \begin{quote}
89 \begin{Verbatim}
90 $\sin^2(x)$ and $\cos^2(x)$ equals one:
93 \sin^2(x) + \cos^2(x) = 1 % for all x
95 \end{Verbatim}
96 \end{quote}
98 A latex \textquotedbl{}code-block\textquotedbl{} (set with \textquotedbl{}literal-block-env\textquotedbl{}, if syntax
99 highlight is \textquotedbl{}none\textquotedbl{}):
101 \begin{DUclass}{code}
102 \begin{DUclass}{latex}
103 \begin{quote}
104 \begin{Verbatim}
105 $\sin^2(x)$ and $\cos^2(x)$ equals one:
108 \sin^2(x) + \cos^2(x) = 1 % for all x
110 \end{Verbatim}
111 \end{quote}
112 \end{DUclass}
113 \end{DUclass}
115 A literal block in a table:
117 \setlength{\DUtablewidth}{\linewidth}
118 \begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
119 \hline
121 test
123 \begin{minipage}{8\ttemwidth}
124 \begin{Verbatim}
125 \sin^2 x
126 \end{Verbatim}
127 \end{minipage}
129 test
131 \hline
132 \end{longtable*}
134 A literal block in a table with auto-width columns:
136 \begin{longtable*}[c]{|l|l|l|}
137 \hline
138 test &
139 \ttfamily\raggedright
140 \textbackslash{}sin\textasciicircum{}2~x
141 & test \\
142 \hline
143 \end{longtable*}
145 Parsed literal block with inline markup and leading whitespace:
147 \begin{quote}
148 \ttfamily\raggedright
149 ~~~\emph{emphasis},~\textbf{strong~emphasis},~\texttt{inline~literals},\\
150 standalone~hyperlinks~(\url{http://www.python.org}),\\
151 \hyperref[internal]{internal}~and~\href{http://www.python.org/}{external}~hyperlinks,\\
153 \phantomsection\label{internal}internal~hyperlink~targets,\\
154 images~via~substitution~references~(\includegraphics{../../../docs/user/rst/images/biohazard.png}),\\
155 footnote~references\DUfootnotemark{id1}{id3}{*},\\
156 citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
158 ~~~Here~are~some~explicit~interpreted~text~roles:\\
159 a~PEP~reference~(\href{http://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
160 an~RFC~reference~(\href{http://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
161 an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
162 code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
163 maths~$\sin^2(x)$,\\
164 \textsubscript{subscript}~and~\textsuperscript{superscript},\\
165 \DUrole{custom}{custom}~\DUrole{custom-role}{roles},~and~explicit~roles~for\\
166 \DUroletitlereference{Docutils}'~\emph{standard}~\textbf{inline}~\texttt{markup}.
167 \end{quote}
169 \DUfootnotetext{id3}{id1}{*}{%
170 This footnote is referenced in a \DUroletitlereference{parsed literal} block.
172 \begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002]
173 Sample Citation, 2017.
174 \end{figure}
176 \end{document}