Clean up code-block-directive sandbox project.
[docutils/kirr.git] / sandbox / code-block-directive / docs / myfunction.py.tex
blob70f96df3a917282e58c2c66c63078bb01929dc7e
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 \setcounter{secnumdepth}{0}
10 %%% Custom LaTeX preamble
11 % suppress the (LaTeX-added) References section heading
12 \AtBeginDocument{\renewcommand{\refname}{\vspace{-1em}}}
13 \newlength{\DUlineblockindent}
14 \setlength{\DUlineblockindent}{1em}
16 %%% User specified packages and stylesheets
17 \usepackage{palatino-optima-txtt}
18 \usepackage{microtype}
19 \usepackage{bookmark}
21 \usepackage{../data/pygments-docutilsroles}
22 %%% Fallback definitions for Docutils-specific commands
24 % inline markup (custom roles)
25 % \DUrole{#1}{#2} tries \DUrole#1{#2}
26 \providecommand*{\DUrole}[2]{%
27 \ifcsname DUrole#1\endcsname%
28 \csname DUrole#1\endcsname{#2}%
29 \else% backwards compatibility: try \docutilsrole#1{#2}
30 \ifcsname docutilsrole#1\endcsname%
31 \csname docutilsrole#1\endcsname{#2}%
32 \else%
33 #2%
34 \fi%
35 \fi%
38 % hyperlinks:
39 \ifthenelse{\isundefined{\hypersetup}}{
40 \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=black]{hyperref}
41 \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
42 }{}
45 %%% Body
46 \begin{document}
48 This is a test of the new ``code'' directive:
50 % Translate this document with a pygments enhanced frontend, e.g.
52 % ../rst2html-highlight.py --stylesheet=../data/pygments-default.css
53 % ../rst2latex-highlight.py --stylesheet=../data/pygments-docutilsroles.sty
55 % or via the test case in
57 % ../pygments_code_block_directive.py --traceback
59 The example from Docutils TODO list:
61 \begin{quote}{\ttfamily \raggedright \noindent
62 \DUrole{k}{print}~\DUrole{s}{'This~is~Python~code.'}~\\
63 \DUrole{k}{for}~\DUrole{n}{i}~\DUrole{ow}{in}~\DUrole{nb}{range}\DUrole{p}{(}\DUrole{mi}{10}\DUrole{p}{):}~\\
64 ~~~~\DUrole{k}{print}~\DUrole{n}{i}
66 \end{quote}
68 Numbered lines:
70 \begin{quote}{\ttfamily \raggedright \noindent
71 \DUrole{l}{\DUrole{n}{1~}}\DUrole{c}{\#~This~is~Python~code,}~\\
72 \DUrole{ln}{2~}\DUrole{c}{\#~that~prints~the~integers~from~0~to~9}~\\
73 \DUrole{ln}{3~}\DUrole{k}{for}~\DUrole{n}{i}~\DUrole{ow}{in}~\DUrole{nb}{range}\DUrole{p}{(}\DUrole{mi}{10}\DUrole{p}{):}~\\
74 \DUrole{ln}{4~}~~~~\DUrole{k}{print}~\DUrole{n}{i}
76 \end{quote}
78 Another example:
80 \begin{quote}{\ttfamily \raggedright \noindent
81 \DUrole{l}{\DUrole{n}{~7~}}\DUrole{k}{def}~\DUrole{nf}{my\_function}\DUrole{p}{():}~\\
82 \DUrole{ln}{~8~}~~~~\DUrole{sd}{"{}"{}"Test~the~lexer.\\
83 }\DUrole{ln}{~9~}\DUrole{sd}{~~~~"{}"{}"}~\\
84 \DUrole{ln}{10~}~\\
85 \DUrole{ln}{11~}~~~~\DUrole{c}{\#~and~now~for~something~completely~different}~\\
86 \DUrole{ln}{12~}~~~~\DUrole{k}{print}~\DUrole{mi}{8}\DUrole{o}{/}\DUrole{mi}{2}
88 \end{quote}
90 Inline code \texttt{\DUrole{code}{\$\textbackslash{}alpha =
91 \textbackslash{}int\_0\textasciicircum{}\textbackslash{}infty f(x) dx\$}}.
93 Python code \texttt{\DUrole{code}{\DUrole{python}{\DUrole{testclass}{\DUrole{k}{print}\DUrole{p}{(}\DUrole{s}{"The end."}\DUrole{p}{)}}}}}
95 \end{document}