]> git.lyx.org Git - lyx.git/blob - lib/examples/Graphics_and_Insets/Minted_Listings.lyx
* docbook2epub.py syntax
[lyx.git] / lib / examples / Graphics_and_Insets / Minted_Listings.lyx
1 #LyX 2.4 created this file. For more info see https://www.lyx.org/
2 \lyxformat 600
3 \begin_document
4 \begin_header
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/Graphics_and_Insets/
7 \textclass article
8 \begin_preamble
9 \usepackage{xcolor}
10 \definecolor{lgray}{rgb}{0.95, 0.95, 0.95}
11 \end_preamble
12 \use_default_options true
13 \maintain_unincluded_children no
14 \language english
15 \language_package default
16 \inputencoding utf8
17 \fontencoding auto
18 \font_roman "default" "default"
19 \font_sans "default" "default"
20 \font_typewriter "default" "default"
21 \font_math "auto" "auto"
22 \font_default_family default
23 \use_non_tex_fonts false
24 \font_sc false
25 \font_sans_osf false
26 \font_typewriter_osf false
27 \font_roman_osf false
28 \font_sf_scale 100 100
29 \font_tt_scale 100 100
30 \use_microtype false
31 \use_dash_ligatures true
32 \graphics default
33 \default_output_format default
34 \output_sync 0
35 \bibtex_command default
36 \index_command default
37 \paperfontsize default
38 \spacing single
39 \use_hyperref false
40 \papersize default
41 \use_geometry false
42 \use_package amsmath 1
43 \use_package amssymb 1
44 \use_package cancel 1
45 \use_package esint 1
46 \use_package mathdots 1
47 \use_package mathtools 1
48 \use_package mhchem 1
49 \use_package stackrel 1
50 \use_package stmaryrd 1
51 \use_package undertilde 1
52 \cite_engine basic
53 \cite_engine_type default
54 \biblio_style plain
55 \use_bibtopic false
56 \use_indices false
57 \paperorientation portrait
58 \suppress_date false
59 \justification true
60 \use_refstyle 1
61 \use_minted 1
62 \use_lineno 0
63 \index Index
64 \shortcut idx
65 \color #008000
66 \end_index
67 \secnumdepth 3
68 \tocdepth 3
69 \paragraph_separation indent
70 \paragraph_indentation default
71 \is_math_indent 0
72 \math_numbering_side default
73 \quotes_style english
74 \dynamic_quotes 0
75 \papercolumns 1
76 \papersides 1
77 \paperpagestyle default
78 \listings_params "breaklines=true"
79 \tracking_changes false
80 \postpone_fragile_content false
81 \output_changes false
82 \html_math_output 0
83 \html_css_as_file 0
84 \html_be_strict false
85 \end_header
86
87 \begin_body
88
89 \begin_layout Standard
90 \begin_inset Note Note
91 status open
92
93 \begin_layout Plain Layout
94 This example shows how to typeset code listings in a document using the
95  minted latex package.
96 \end_layout
97
98 \begin_layout Plain Layout
99 Other than the minted package, you also need the pygments python module.
100  See the minted documentation for directions on how to install it and what
101  you have to do for using it with LaTeX.
102  If you use a linux system, you can possibly install a suitable package
103  through your package manager.
104  Look for python packages named 
105 \family typewriter
106 python-pygments
107 \family default
108  or similar.
109 \end_layout
110
111 \end_inset
112
113
114 \end_layout
115
116 \begin_layout Standard
117 A common example of a C program is shown in Listing
118 \begin_inset space ~
119 \end_inset
120
121
122 \begin_inset CommandInset ref
123 LatexCommand ref
124 reference "lis:foo"
125 plural "false"
126 caps "false"
127 noprefix "false"
128
129 \end_inset
130
131  using the default style, a light gray background, visible spaces, and numbered
132  lines.
133  The listing of some fortran code using the 
134 \family typewriter
135 bw
136 \family default
137  style is instead shown in a non-floating listing below.
138 \end_layout
139
140 \begin_layout Standard
141 \begin_inset listings
142 lstparams "language=C,float=t,numbers=left,showspaces=true,bgcolor=lgray"
143 inline false
144 status open
145
146 \begin_layout Plain Layout
147
148 int main()
149 \end_layout
150
151 \begin_layout Plain Layout
152
153 {
154 \end_layout
155
156 \begin_layout Plain Layout
157
158     printf(
159 \begin_inset Quotes eld
160 \end_inset
161
162 Hello world!
163 \backslash
164 n
165 \begin_inset Quotes erd
166 \end_inset
167
168 );
169 \end_layout
170
171 \begin_layout Plain Layout
172
173     return 0;
174 \end_layout
175
176 \begin_layout Plain Layout
177
178 }
179 \end_layout
180
181 \begin_layout Plain Layout
182
183 \begin_inset Caption Standard
184
185 \begin_layout Plain Layout
186 foo
187 \begin_inset CommandInset label
188 LatexCommand label
189 name "lis:foo"
190
191 \end_inset
192
193
194 \end_layout
195
196 \end_inset
197
198
199 \end_layout
200
201 \end_inset
202
203
204 \end_layout
205
206 \begin_layout Standard
207 \begin_inset listings
208 lstparams "language=Fortran,frame=lines,style=bw"
209 inline false
210 status open
211
212 \begin_layout Plain Layout
213
214 * Compute machine precision
215 \end_layout
216
217 \begin_layout Plain Layout
218
219 \end_layout
220
221 \begin_layout Plain Layout
222
223       implicit double precision (a-h,o-z)
224 \end_layout
225
226 \begin_layout Plain Layout
227
228       unit = 1.d0
229 \end_layout
230
231 \begin_layout Plain Layout
232
233     1 eps = unit
234 \end_layout
235
236 \begin_layout Plain Layout
237
238       unit = 0.5d0*unit
239 \end_layout
240
241 \begin_layout Plain Layout
242
243       u = 1.d0-unit
244 \end_layout
245
246 \begin_layout Plain Layout
247
248       if (u .lt.
249  1.d0) go to 1
250 \end_layout
251
252 \begin_layout Plain Layout
253
254       write(*,'(1pg24.17)') eps
255 \end_layout
256
257 \begin_layout Plain Layout
258
259       stop
260 \end_layout
261
262 \begin_layout Plain Layout
263
264       end
265 \end_layout
266
267 \end_inset
268
269
270 \end_layout
271
272 \begin_layout Standard
273 Here is an inline listing of some TeX code: 
274 \begin_inset listings
275 lstparams "language=TeX,fontfamily=tt"
276 inline true
277 status open
278
279 \begin_layout Plain Layout
280
281
282 \backslash
283 let
284 \backslash
285 thefun
286 \backslash
287 begin
288 \end_layout
289
290 \end_inset
291
292 .
293 \end_layout
294
295 \end_body
296 \end_document