Debian Codegraph @

test/functional/expected/latex_literal_block_listings.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{amsmath}
6 \usepackage{color}
7 \usepackage{graphicx}
8 \usepackage{listings}
9 \lstset{xleftmargin=\leftmargin}
10 \usepackage{longtable,ltcaption,array}
11 \setlength{\extrarowheight}{2pt}
12 \newlength{\DUtablewidth} % internal use in tables
13
14 %%% Custom LaTeX preamble
15
16 % PDF Standard Fonts
17 \usepackage{mathptmx} % Times
18 \usepackage[scaled=.90]{helvet}
19 \usepackage{courier}
20 % LaTeX syntax highlight with "listings":
21 \lstloadlanguages{[LaTeX]TeX} % comma separated list of languages
22 \newcommand{\DUCLASSlatex}{\lstset{language=[LaTeX]TeX}}
23
24
25 %%% User specified packages and stylesheets
26
27 %%% Fallback definitions for Docutils-specific commands
28 \usepackage{docutils}[2026-05-06]
29
30 % character width in monospaced font
31 \newlength{\ttemwidth}
32 \settowidth{\ttemwidth}{\ttfamily M}
33
34 % hyperlinks:
35 \ifdefined\hypersetup
36 \else
37 \usepackage[hyperfootnotes=false,
38 colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
39 \usepackage{bookmark}
40 \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
41 \fi
42
43 %%% Body
44 \begin{document}
45
46 In LaTeX, literal blocks can be customized with the \textquotedbl{}literal-block-env\textquotedbl{}
47 setting. This test file exists to check if the LaTeX writer output compiles
48 and looks as expected.
49
50 Start with a plain literal block:
51
52 \begin{lstlisting}
53 $\sin^2(x)$ and $\cos^2(x)$ equals one:
54
55 \[
56 \sin^2(x) + \cos^2(x) = 1 % for all x
57 \]
58 \end{lstlisting}
59
60 A latex \textquotedbl{}code-block\textquotedbl{} (set with \textquotedbl{}literal-block-env\textquotedbl{}, if syntax
61 highlight is \textquotedbl{}none\textquotedbl{}):
62
63 \begin{DUclass}{code}
64 \begin{DUclass}{latex}
65 \begin{lstlisting}
66 $\sin^2(x)$ and $\cos^2(x)$ equals one:
67
68 \[
69 \sin^2(x) + \cos^2(x) = 1 % for all x
70 \]
71 \end{lstlisting}
72 \end{DUclass}
73 \end{DUclass}
74
75 A literal block in a table:
76
77 \setlength{\DUtablewidth}{\linewidth}%
78 \begin{longtable*}{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
79 \hline
80
81 test
82 &
83 \begin{minipage}{8\ttemwidth}
84 \lstset{xleftmargin=0pt}
85 \begin{lstlisting}
86 \sin^2 x
87 \end{lstlisting}
88 \end{minipage}
89 &
90 test
91 \\
92 \hline
93 \end{longtable*}
94
95 A literal block in a table with auto-width columns:
96
97 \begin{longtable*}{|l|l|l|}
98 \hline
99 test &
100 \lstset{xleftmargin=0pt}
101 \begin{lstlisting}
102 \sin^2 x
103 \end{lstlisting}
104 & test \\
105 \hline
106 \end{longtable*}
107
108 \begin{DUclass}{note}
109 \begin{DUadmonition}
110 \DUtitle{Note}
111
112 A literal block in an admonition:
113
114 \begin{lstlisting}
115 \sin^2 x
116 \end{lstlisting}
117 \end{DUadmonition}
118 \end{DUclass}
119
120 \DUsidebar{
121 \DUtitle{Literal Block in a Sidebar}
122
123 \begin{quote}
124 \ttfamily\raggedright
125 \textbackslash{}sin\textasciicircum{}2~x
126 \end{quote}
127 }
128
129 Parsed literal block with inline markup and leading whitespace:
130
131 \begin{quote}
132 \ttfamily\raggedright
133 ~~~\emph{emphasis},~\textbf{strong~emphasis},~\texttt{inline~literals},\\
134 standalone~hyperlinks~(\url{http://www.python.org}),\\
135 \hyperref[internal]{internal}~and~\href{http://www.python.org/}{external}~hyperlinks,\\
136 %
137 \phantomsection\label{internal}internal~hyperlink~targets,\\
138 images~via~substitution~references~(\includegraphics{../../../docs/user/rst/images/biohazard.png}),\\
139 footnote~references\DUfootnotemark{footnote-reference-1}{footnote-1}{*},\\
140 citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
141 ~\\
142 ~~~Here~are~some~explicit~interpreted~text~roles:\\
143 a~PEP~reference~(\href{https://peps.python.org/pep-0287}{PEP~287}),\\
144 an~RFC~reference~(\href{https://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
145 an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
146 code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
147 maths~$\sin^2(x)$,\\
148 \textsubscript{subscript}~and~\textsuperscript{superscript},\\
149 \DUrole{custom}{custom}~\DUrole{custom-role}{roles},~and~explicit~roles~for\\
150 \DUroletitlereference{Docutils}'~\emph{standard}~\textbf{inline}~\texttt{markup}.
151 \end{quote}
152 %
153 \DUfootnotetext{footnote-1}{footnote-reference-1}{*}{%
154 This footnote is referenced in a \DUroletitlereference{parsed literal} block.
155
156 It contains a literal block:
157
158 \begin{quote}
159 \ttfamily\raggedright
160 \textbackslash{}sin\textasciicircum{}2~x
161 \end{quote}
162 }
163 \begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002]
164 Sample Citation, 2017.
165 \end{figure}
166
167 \end{document}