]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/test/test-minted.tex
Update paths in tex2lyx tests
[lyx.git] / src / tex2lyx / test / test-minted.tex
1 %% Do not edit unless you really know what you are doing.
2 \documentclass[a4paper,12pt]{article}
3 \usepackage[T1]{fontenc}
4 \usepackage[latin9]{inputenc}
5 \usepackage{minted}
6
7 \begin{document}
8
9 \listoflistings
10
11 \section{Minted Listings}
12
13 Inline: \mintinline[style=bw]{C++}!int a=5;!\\
14 Float (Listing~\ref{Example-Listing}):
15
16 \begin{listing}[h]
17 \begin{minted}{Python}
18 # Example listing float
19 def func(param):
20     'this is a python function'
21     pass
22 \end{minted}
23 \caption{Example Listing float}
24 \label{Example-Listing}
25 \end{listing}
26
27 Here is an example listing with left line numbering, language ``Python''
28 and ``Space~as~symbol'', range lines from 4 to end:
29
30 \begin{minted}[firstline=4,numbers=left,showspaces=true]{Python}
31 def func(param):
32     'this is a python function'
33     pass
34 def func(param):
35     'This is a German word: Tschüß'
36     pass
37 \end{minted}
38
39 A floating one-liner with [h] placement and without caption:
40 \begin{listing}[h]
41 \begin{minted}[fontfamily=tt,fontsize={\large},bgcolor=lightgray]{ABAP}
42 hello
43 \end{minted}
44 \end{listing}
45
46 Another inline listing:
47 \mintinline{TeX}!\begin{centering} hello!
48
49 A non-floating listing with line frames and a top caption
50 (Listing~\ref{hello-world}):
51 \lyxmintcaption[t]{An example C program\label{hello-world}}
52 \begin{minted}[numbers=left,frame=lines]{C}
53 int main()
54 {
55     printf("Hello world!\n");
56     return 0;
57 }
58 \end{minted}
59
60 A non-floating listing with line frames and a bottom caption
61 (Listing~\ref{func}):
62 \begin{minted}[numbers=left,frame=lines]{Fortran}
63 subroutine incr(i)
64   integer :: i
65   i = i + 1 
66   return 
67 end subroutine function
68 \end{minted}
69 \lyxmintcaption[b]{\label{func}A Fortran subroutine}
70
71 A framed floating listing with a caption and a label (Listing~\ref{python1}):
72 \begin{listing}[h]
73     \begin{minted}[frame=single]{Python}
74 def boring(args = None):
75     pass
76 \end{minted}
77 \caption{A Python function.}
78 \label{python1}
79 \end{listing}
80
81
82 The same framed floating listing with a caption, a label and a stray math
83 equation (Listing~\ref{python2}):
84 \begin{listing}[h]
85 $y=f(x)$
86 \begin{minted}[frame=single]{Python}
87 def boring(args = None):
88     pass
89 \end{minted}
90 \caption{The previous Python function.}
91 \label{python2}
92 \end{listing}
93
94 \end{document}