| 1 |
%% LyX 2.2.1 created this file. For more info, see http://www.lyx.org/. |
| 2 |
%% Do not edit unless you really know what you are doing. |
| 3 |
\documentclass[twocolumn]{article} |
| 4 |
\usepackage[sc]{mathpazo} |
| 5 |
\usepackage[T1]{fontenc} |
| 6 |
\usepackage{geometry} |
| 7 |
\geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm} |
| 8 |
\setcounter{secnumdepth}{2} |
| 9 |
\setcounter{tocdepth}{2} |
| 10 |
\setlength{\parskip}{\bigskipamount} |
| 11 |
\setlength{\parindent}{0pt} |
| 12 |
\usepackage{url} |
| 13 |
\usepackage[unicode=true,pdfusetitle, |
| 14 |
bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2, |
| 15 |
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false] |
| 16 |
{hyperref} |
| 17 |
\hypersetup{ |
| 18 |
pdfstartview={XYZ null null 1}} |
| 19 |
\usepackage{breakurl} |
| 20 |
|
| 21 |
\makeatletter |
| 22 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. |
| 23 |
\renewcommand{\textfraction}{0.05} |
| 24 |
\renewcommand{\topfraction}{0.8} |
| 25 |
\renewcommand{\bottomfraction}{0.8} |
| 26 |
\renewcommand{\floatpagefraction}{0.75} |
| 27 |
|
| 28 |
\makeatother |
| 29 |
|
| 30 |
\begin{document} |
| 31 |
<<setup, include=FALSE, cache=FALSE>>= |
| 32 |
library(knitr) |
| 33 |
opts_chunk$set(fig.path='figure/twocolumn-', fig.align='center', fig.show='hold') |
| 34 |
render_listings() |
| 35 |
@ |
| 36 |
|
| 37 |
\title{Using knitr in A Two-column Document} |
| 38 |
|
| 39 |
\author{Yihui Xie} |
| 40 |
|
| 41 |
\maketitle |
| 42 |
We can use the \texttt{figure{*}} environment in \LaTeX{} so that |
| 43 |
figures can span over two columns. Because the output hooks use the |
| 44 |
\textbf{framed} package which does not work well with the \texttt{figure{*}} |
| 45 |
environment, we can either modify the output hooks or use other packages |
| 46 |
like \textbf{listings}. For example, |
| 47 |
|
| 48 |
<<chunk-hook, echo=2, tidy=TRUE, tidy.opts=list(width.cutoff=30)>>= |
| 49 |
<<setup>> |
| 50 |
@ |
| 51 |
|
| 52 |
\begin{figure*} |
| 53 |
<<boring-plots, fig.width=5, fig.height=5, out.width='.45\\linewidth'>>= |
| 54 |
x=rnorm(100) |
| 55 |
par(mar=c(4,4,.1,.1)) |
| 56 |
boxplot(x) |
| 57 |
hist(x,main='') |
| 58 |
@ |
| 59 |
|
| 60 |
\caption{Two plots spanning over two columns.} |
| 61 |
\end{figure*} |
| 62 |
|
| 63 |
The output PDF file will be like: \url{https://github.com/yihui/knitr/releases/download/doc/knitr-twocolumn.pdf}. |
| 64 |
The Rnw source of this document is at \url{https://github.com/yihui/knitr/blob/master/inst/examples/knitr-twocolumn.Rnw}. |
| 65 |
\end{document} |