%% LyX 2.0.5.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[twocolumn]{article}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\setlength{\parskip}{\bigskipamount}
\setlength{\parindent}{0pt}
\usepackage{url}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}
\hypersetup{
 pdfstartview={XYZ null null 1}}
\usepackage{breakurl}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\renewcommand{\textfraction}{0.05}
\renewcommand{\topfraction}{0.8}
\renewcommand{\bottomfraction}{0.8}
\renewcommand{\floatpagefraction}{0.75}

\makeatother

\begin{document}

<<setup, include=FALSE, cache=FALSE>>=
opts_chunk$set(fig.path='figure/twocolumn-', fig.align='center', fig.show='hold')
render_listings()
@


\title{Using knitr in A Two-column Document}


\author{Yihui Xie}

\maketitle
We can use the \texttt{figure{*}} environment in \LaTeX{} so that
figures can span over two columns. Because the output hooks use the
\textbf{framed} package which does not work well with the \texttt{figure{*}}
environment, we can either modify the output hooks or use other packages
like \textbf{listings}. For example,

<<chunk-hook, echo=2>>=
<<setup>>
@

\begin{figure*}
<<boring-plots, fig.width=5, fig.height=5, out.width='.45\\linewidth'>>=
x=rnorm(100)
par(mar=c(4,4,.1,.1))
boxplot(x)
hist(x,main='')
@

\caption{Two plots spanning over two columns.}
\end{figure*}


The output PDF file will be like: \url{https://bitbucket.org/stat/knitr/downloads/knitr-twocolumn.pdf}.
The Rnw source of this document is at \url{https://github.com/yihui/knitr/blob/master/inst/examples/knitr-twocolumn.Rnw}.

\end{document}
