Fix :width: option for the table directives.
[docutils.git] / docutils / test / functional / expected / latex_literal_block.tex
blob35a008b8228a469bbd04eac9e0d1ba33fa4c5d25
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{alltt}
8 \usepackage{amsmath}
9 \usepackage{graphicx}
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 % backwards compatibility: try \docutilsrole#1{#2}
51 \ifcsname docutilsrole#1\endcsname%
52 \csname docutilsrole#1\endcsname{#2}%
53 \else
54 \csname DUrole#1\endcsname{#2}%
55 \fi%
58 % text mode subscript
59 \ifx\textsubscript\undefined
60 \usepackage{fixltx2e} % since 2015 loaded by default
61 \fi
63 % titlereference role
64 \providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
66 % character width in monospaced font
67 \newlength{\ttemwidth}
68 \settowidth{\ttemwidth}{\ttfamily M}
70 % hyperlinks:
71 \ifthenelse{\isundefined{\hypersetup}}{
72 \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
73 \usepackage{bookmark}
74 \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
75 }{}
77 %%% Body
78 \begin{document}
80 In LaTeX, literal blocks can be customized with the \textquotedbl{}literal-block-env\textquotedbl{}
81 setting. This test file exists to check the latex writer output compiles and
82 looks as expected. Start with a plain literal block:
84 \begin{quote}
85 \begin{alltt}
86 $\textbackslash{}sin^2(x)$ and $\textbackslash{}cos^2(x)$ equals one:
88 \textbackslash{}[
89 \textbackslash{}sin^2(x) + \textbackslash{}cos^2(x) = 1 % for all x
90 \textbackslash{}]
91 \end{alltt}
92 \end{quote}
94 A latex \textquotedbl{}code-block\textquotedbl{} (set with \textquotedbl{}literal-block-env\textquotedbl{}, if syntax
95 highlight is \textquotedbl{}none\textquotedbl{}):
97 \begin{DUclass}{code}
98 \begin{DUclass}{latex}
99 \begin{quote}
100 \begin{alltt}
101 $\textbackslash{}sin^2(x)$ and $\textbackslash{}cos^2(x)$ equals one:
103 \textbackslash{}[
104 \textbackslash{}sin^2(x) + \textbackslash{}cos^2(x) = 1 % for all x
105 \textbackslash{}]
106 \end{alltt}
107 \end{quote}
108 \end{DUclass}
109 \end{DUclass}
111 A literal block in a table:
113 \setlength{\DUtablewidth}{\linewidth}
114 \begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
115 \hline
117 test
119 \begin{minipage}{8\ttemwidth}
120 \begin{alltt}
121 \textbackslash{}sin^2 x
122 \end{alltt}
123 \end{minipage}
125 test
127 \hline
128 \end{longtable*}
130 A literal block in a table with auto-width columns:
132 \begin{longtable*}[c]{|l|l|l|}
133 \hline
134 test &
135 \ttfamily\raggedright
136 \textbackslash{}sin\textasciicircum{}2~x
137 & test \\
138 \hline
139 \end{longtable*}
141 Parsed literal block with inline markup and leading whitespace:
143 \begin{quote}
144 \ttfamily\raggedright
145 ~~~\emph{emphasis},~\textbf{strong~emphasis},~\texttt{inline~literals},\\
146 standalone~hyperlinks~(\url{http://www.python.org}),\\
147 \hyperref[internal]{internal}~and~\href{http://www.python.org/}{external}~hyperlinks,\\
149 \phantomsection\label{internal}internal~hyperlink~targets,\\
150 images~via~substitution~references~(\includegraphics{../../../docs/user/rst/images/biohazard.png}),\\
151 footnote~references\DUfootnotemark{id1}{id3}{*},\\
152 citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
154 ~~~Here~are~some~explicit~interpreted~text~roles:\\
155 a~PEP~reference~(\href{http://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
156 an~RFC~reference~(\href{http://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
157 an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
158 code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
159 maths~$\sin^2(x)$,\\
160 \textsubscript{subscript}~and~\textsuperscript{superscript},\\
161 \DUrole{custom}{custom}~\DUrole{custom-role}{roles},~and~explicit~roles~for\\
162 \DUroletitlereference{Docutils}'~\emph{standard}~\textbf{inline}~\texttt{markup}.
163 \end{quote}
165 \DUfootnotetext{id3}{id1}{*}{%
166 This footnote is referenced in a \DUroletitlereference{parsed literal} block.
168 \begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002]
169 Sample Citation, 2017.
170 \end{figure}
172 \end{document}