3350056 Aug 11, 2016
72 lines (57 sloc) 2.15 KB
%% LyX 2.2.1 created this file. For more info, see
%% Do not edit unless you really know what you are doing.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
<<setup, include=FALSE>>=
\title{Using subfloats in \LyX{} with knitr}
\author{Yihui Xie}
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:
\item 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);
\item use the chunk option \texttt{echo=FALSE} to hide the R source code
in the output;
\item set \texttt{out.width} to be less than half of the linewidth if you
do not want the sub figures to exceed the page margin;
\item most importantly, leave a blank line in the beginning of the subfloat
environment, so that \texttt{<\textcompwordmark{}<>\textcompwordmark{}>=}
starts in a new line and \textbf{knitr} can recognize it;
Figure \ref{fig:knitr-subfloat} is an example.
This document was compiled with \textbf{knitr} \Sexpr{packageVersion('knitr')}.
Rnw source at \url{}.
\subfloat[this is a subfloat]{
<<test-subfloat, echo=FALSE, out.width='.45\\linewidth'>>=
}\subfloat[another float]{
<<test-another, echo=FALSE, out.width='.45\\linewidth'>>=
\caption{one figure with 2 sub figures\label{fig:knitr-subfloat}}