# Using knitr, how can I rotate page to landscape and fit the figure to full extent?

LaTeX newbie here, so please be gentle.

I'm working with knitr to generate pdf report. The document consists of quite few large maps, with a lot of details or small multiples. Ideally, whenever such map appears, I'd like to set the page orientation to landscape and get the maximum figure that will fit into it.

So far I've been trying a set up of:

\documentclass[a4paper]{article}

% setting very small margins
\usepackage{fullpage}

% better for printing, page displayed vertically, content in landscape mode
% \usepackage{lscape}

% better for screen, page displayed horizontally, content in landscape mode
\usepackage{pdflscape}


But whenever i use \begin{landscape} I get an extra white page in front..

I tried the solution from this question, but it didn't remove the page.

And I still haven’t figure out the knitr settings for maximum available figure to fit. In chunk options I can use out.width='1\\linewidth'. Or I could use out.width, out.height but then I have to figure out dimensions myself right?

-
\begin{landscape} is akin to adding a figure the size of the page (a weak analogy, but...). a figure the size of the page needs to have a clean page to typeset on, so it issues \clearpage (or something). if you want your landscape stuff as “real figures”, use the rotating package’s sidewaysfigure (etc) environment (but note it doesn't have the pdflscape package’s tricks in it ... i’ve not managed to make that work yet). – wasteofspace Apr 23 '13 at 16:17

I do not see the extra white page you mentioned:

\documentclass[a4paper]{article}
\usepackage{fullpage}
\usepackage{pdflscape}
\begin{document}

\begin{landscape}
<<test, out.width='1\\linewidth', fig.width=7, fig.height=4>>=
par(mar=c(4, 4, .1, .1)); plot(1:10)
@
\end{landscape}

\end{document}


-
Hi Yihui. Thanks a lot for answer (and your amazing work on knitr too!). It seemed that lack of figure size specifications was causing problems. I followed your suggestions and specified dimension out.width='10in', fig.width=16, fig.height=9 and that solved the problem. – radek Apr 29 '13 at 9:04