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