Debian Codegraph @

inst/examples/knitr-twocolumn.lyx

raw
1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
2 \lyxformat 413
3 \begin_document
4 \begin_header
5 \textclass article
6 \begin_preamble
7 \renewcommand{\textfraction}{0.05}
8 \renewcommand{\topfraction}{0.8}
9 \renewcommand{\bottomfraction}{0.8}
10 \renewcommand{\floatpagefraction}{0.75}
11 \end_preamble
12 \use_default_options true
13 \begin_modules
14 knitr
15 \end_modules
16 \maintain_unincluded_children false
17 \language english
18 \language_package none
19 \inputencoding default
20 \fontencoding global
21 \font_roman palatino
22 \font_sans default
23 \font_typewriter default
24 \font_default_family default
25 \use_non_tex_fonts false
26 \font_sc true
27 \font_osf false
28 \font_sf_scale 100
29 \font_tt_scale 100
30
31 \graphics default
32 \default_output_format default
33 \output_sync 0
34 \bibtex_command default
35 \index_command default
36 \paperfontsize default
37 \spacing single
38 \use_hyperref true
39 \pdf_bookmarks true
40 \pdf_bookmarksnumbered true
41 \pdf_bookmarksopen true
42 \pdf_bookmarksopenlevel 2
43 \pdf_breaklinks false
44 \pdf_pdfborder false
45 \pdf_colorlinks false
46 \pdf_backref false
47 \pdf_pdfusetitle true
48 \pdf_quoted_options "pdfstartview={XYZ null null 1}"
49 \papersize default
50 \use_geometry true
51 \use_amsmath 1
52 \use_esint 1
53 \use_mhchem 1
54 \use_mathdots 1
55 \cite_engine basic
56 \use_bibtopic false
57 \use_indices false
58 \paperorientation portrait
59 \suppress_date false
60 \use_refstyle 1
61 \index Index
62 \shortcut idx
63 \color #008000
64 \end_index
65 \leftmargin 3cm
66 \topmargin 3cm
67 \rightmargin 3cm
68 \bottommargin 3cm
69 \secnumdepth 2
70 \tocdepth 2
71 \paragraph_separation skip
72 \defskip bigskip
73 \quotes_language english
74 \papercolumns 2
75 \papersides 1
76 \paperpagestyle default
77 \tracking_changes false
78 \output_changes false
79 \html_math_output 0
80 \html_css_as_file 0
81 \html_be_strict false
82 \end_header
83
84 \begin_body
85
86 \begin_layout Standard
87 \begin_inset ERT
88 status open
89
90 \begin_layout Plain Layout
91
92 <<setup, include=FALSE, cache=FALSE>>=
93 \end_layout
94
95 \begin_layout Plain Layout
96
97 library(knitr)
98 \end_layout
99
100 \begin_layout Plain Layout
101
102 opts_chunk$set(fig.path='figure/twocolumn-', fig.align='center', fig.show='hold')
103 \end_layout
104
105 \begin_layout Plain Layout
106
107 render_listings()
108 \end_layout
109
110 \begin_layout Plain Layout
111
112 @
113 \end_layout
114
115 \end_inset
116
117
118 \end_layout
119
120 \begin_layout Title
121 Using knitr in A Two-column Document
122 \end_layout
123
124 \begin_layout Author
125 Yihui Xie
126 \end_layout
127
128 \begin_layout Standard
129 We can use the
130 \family typewriter
131 figure*
132 \family default
133 environment in LaTeX so that figures can span over two columns.
134 Because the output hooks use the
135 \series bold
136 framed
137 \series default
138 package which does not work well with the
139 \family typewriter
140 figure*
141 \family default
142 environment, we can either modify the output hooks or use other packages
143 like
144 \series bold
145 listings
146 \series default
147 .
148 For example,
149 \end_layout
150
151 \begin_layout Standard
152 \begin_inset ERT
153 status open
154
155 \begin_layout Plain Layout
156
157 <<chunk-hook, echo=2, tidy=TRUE, tidy.opts=list(width.cutoff=30)>>=
158 \end_layout
159
160 \begin_layout Plain Layout
161
162 <<setup>>
163 \end_layout
164
165 \begin_layout Plain Layout
166
167 @
168 \end_layout
169
170 \end_inset
171
172
173 \end_layout
174
175 \begin_layout Standard
176 \begin_inset Float figure
177 wide true
178 sideways false
179 status open
180
181 \begin_layout Plain Layout
182 \begin_inset ERT
183 status open
184
185 \begin_layout Plain Layout
186
187 <<boring-plots, fig.width=5, fig.height=5, out.width='.45
188 \backslash
189
190 \backslash
191 linewidth'>>=
192 \end_layout
193
194 \begin_layout Plain Layout
195
196 x=rnorm(100)
197 \end_layout
198
199 \begin_layout Plain Layout
200
201 par(mar=c(4,4,.1,.1))
202 \end_layout
203
204 \begin_layout Plain Layout
205
206 boxplot(x)
207 \end_layout
208
209 \begin_layout Plain Layout
210
211 hist(x,main='')
212 \end_layout
213
214 \begin_layout Plain Layout
215
216 @
217 \end_layout
218
219 \end_inset
220
221
222 \end_layout
223
224 \begin_layout Plain Layout
225 \begin_inset Caption
226
227 \begin_layout Plain Layout
228 Two plots spanning over two columns.
229 \end_layout
230
231 \end_inset
232
233
234 \end_layout
235
236 \end_inset
237
238
239 \end_layout
240
241 \begin_layout Standard
242 The output PDF file will be like:
243 \begin_inset Flex URL
244 status collapsed
245
246 \begin_layout Plain Layout
247
248 https://github.com/yihui/knitr/releases/download/doc/knitr-twocolumn.pdf
249 \end_layout
250
251 \end_inset
252
253 .
254 The Rnw source of this document is at
255 \begin_inset Flex URL
256 status collapsed
257
258 \begin_layout Plain Layout
259
260 https://github.com/yihui/knitr/blob/master/inst/examples/knitr-twocolumn.Rnw
261 \end_layout
262
263 \end_inset
264
265 .
266 \end_layout
267
268 \end_body
269 \end_document