knitr Rnw latex: how to obtain a figure and captio

2019-08-10 16:33发布

问题:

I am trying to produce a full-page figure along with a caption in landscape mode. The Rnw file below works fine if I omit "fig.cap='Caption Trial'", but not if the caption is used. Any help would be greatly appreciated.

\documentclass{article}
\usepackage{fullpage}
\usepackage{pdflscape}
\begin{document}

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

\end{document}

回答1:

Try this:

\documentclass{article}
\usepackage{fullpage}
\usepackage{pdflscape}
\begin{document}

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

\end{document}