333 lines
4.8 KiB
Plaintext
333 lines
4.8 KiB
Plaintext
|
#LyX 2.0 created this file. For more info see http://www.lyx.org/
|
||
|
\lyxformat 413
|
||
|
\begin_document
|
||
|
\begin_header
|
||
|
\textclass article
|
||
|
\begin_preamble
|
||
|
\renewcommand{\textfraction}{0.05}
|
||
|
\renewcommand{\topfraction}{0.8}
|
||
|
\renewcommand{\bottomfraction}{0.8}
|
||
|
\renewcommand{\floatpagefraction}{0.75}
|
||
|
\end_preamble
|
||
|
\use_default_options true
|
||
|
\begin_modules
|
||
|
knitr
|
||
|
\end_modules
|
||
|
\maintain_unincluded_children false
|
||
|
\language english
|
||
|
\language_package default
|
||
|
\inputencoding auto
|
||
|
\fontencoding global
|
||
|
\font_roman default
|
||
|
\font_sans default
|
||
|
\font_typewriter default
|
||
|
\font_default_family default
|
||
|
\use_non_tex_fonts false
|
||
|
\font_sc false
|
||
|
\font_osf false
|
||
|
\font_sf_scale 100
|
||
|
\font_tt_scale 100
|
||
|
|
||
|
\graphics default
|
||
|
\default_output_format default
|
||
|
\output_sync 0
|
||
|
\bibtex_command default
|
||
|
\index_command default
|
||
|
\paperfontsize default
|
||
|
\spacing single
|
||
|
\use_hyperref false
|
||
|
\papersize default
|
||
|
\use_geometry false
|
||
|
\use_amsmath 1
|
||
|
\use_esint 1
|
||
|
\use_mhchem 1
|
||
|
\use_mathdots 1
|
||
|
\cite_engine basic
|
||
|
\use_bibtopic false
|
||
|
\use_indices false
|
||
|
\paperorientation portrait
|
||
|
\suppress_date false
|
||
|
\use_refstyle 1
|
||
|
\index Index
|
||
|
\shortcut idx
|
||
|
\color #008000
|
||
|
\end_index
|
||
|
\secnumdepth 3
|
||
|
\tocdepth 3
|
||
|
\paragraph_separation indent
|
||
|
\paragraph_indentation default
|
||
|
\quotes_language english
|
||
|
\papercolumns 1
|
||
|
\papersides 1
|
||
|
\paperpagestyle default
|
||
|
\tracking_changes false
|
||
|
\output_changes false
|
||
|
\html_math_output 0
|
||
|
\html_css_as_file 0
|
||
|
\html_be_strict false
|
||
|
\end_header
|
||
|
|
||
|
\begin_body
|
||
|
|
||
|
\begin_layout Standard
|
||
|
\begin_inset ERT
|
||
|
status open
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
<<setup, include=FALSE>>=
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
library(knitr)
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
opts_chunk$set(fig.path='figure/subfloats-')
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
@
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Title
|
||
|
Using subfloats in LyX with knitr
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Author
|
||
|
Yihui Xie
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Standard
|
||
|
If you insert a float figure inside a float figure in LyX, you will get
|
||
|
subfloats.
|
||
|
To make sure the two subfloats can stand side by side, you have to:
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Enumerate
|
||
|
remove new lines between the two subfloat environments in LyX (if you are
|
||
|
not sure if there are blank lines between them, check the LaTeX source);
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Enumerate
|
||
|
use the chunk option
|
||
|
\family typewriter
|
||
|
echo=FALSE
|
||
|
\family default
|
||
|
to hide the R source code in the output;
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Enumerate
|
||
|
set
|
||
|
\family typewriter
|
||
|
out.width
|
||
|
\family default
|
||
|
to be less than half of the linewidth if you do not want the sub figures
|
||
|
to exceed the page margin;
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Enumerate
|
||
|
most importantly, leave a blank line in the beginning of the subfloat environmen
|
||
|
t, so that
|
||
|
\family typewriter
|
||
|
<<>>=
|
||
|
\family default
|
||
|
starts in a new line and
|
||
|
\series bold
|
||
|
knitr
|
||
|
\series default
|
||
|
can recognize it;
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Standard
|
||
|
Figure
|
||
|
\begin_inset CommandInset ref
|
||
|
LatexCommand ref
|
||
|
reference "fig:knitr-subfloat"
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
is an example.
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Standard
|
||
|
This document was compiled with
|
||
|
\series bold
|
||
|
knitr
|
||
|
\series default
|
||
|
|
||
|
\begin_inset ERT
|
||
|
status open
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
|
||
|
\backslash
|
||
|
Sexpr{packageVersion('knitr')}
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
.
|
||
|
Rnw source at
|
||
|
\begin_inset Flex URL
|
||
|
status collapsed
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
https://github.com/yihui/knitr/blob/master/inst/examples/knitr-subfloats.Rnw
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
.
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Standard
|
||
|
\begin_inset Float figure
|
||
|
wide false
|
||
|
sideways false
|
||
|
status open
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
\begin_inset Float figure
|
||
|
wide false
|
||
|
sideways false
|
||
|
status open
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
\begin_inset ERT
|
||
|
status open
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
<<test-subfloat, echo=FALSE, out.width='.45
|
||
|
\backslash
|
||
|
|
||
|
\backslash
|
||
|
linewidth'>>=
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
plot(1)
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
@
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
\begin_inset Caption
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
this is a subfloat
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\begin_inset Float figure
|
||
|
wide false
|
||
|
sideways false
|
||
|
status open
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
\begin_inset ERT
|
||
|
status open
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
<<test-another, echo=FALSE, out.width='.45
|
||
|
\backslash
|
||
|
|
||
|
\backslash
|
||
|
linewidth'>>=
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
plot(rnorm(100))
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
|
||
|
@
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
\begin_inset Caption
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
another float
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
\begin_inset Caption
|
||
|
|
||
|
\begin_layout Plain Layout
|
||
|
one figure with 2 sub figures
|
||
|
\begin_inset CommandInset label
|
||
|
LatexCommand label
|
||
|
name "fig:knitr-subfloat"
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\end_inset
|
||
|
|
||
|
|
||
|
\end_layout
|
||
|
|
||
|
\end_body
|
||
|
\end_document
|