I left an empty environment knitrout
in the knitr
design for such purposes. You can redefine this environment to achieve what you want. There are many LaTeX environments that are non-breakable, such as a figure
environment. Below I use the minipage
environment as an example:
\documentclass{article}
\renewenvironment{knitrout}{\begin{minipage}{\columnwidth}}{\end{minipage}}
% alternatively, you can use `figure`
% \renewenvironment{knitrout}{\begin{figure}}{\end{figure}}
\begin{document}
\begin{figure}
\caption{One figure.}
\end{figure}
% placeholder
\framebox{\begin{minipage}[t][0.3\paperheight]{1\columnwidth}%
nothing
\end{minipage}}
<<echo=TRUE>>=
(iris)[1:20,]
@
\begin{figure}
\caption{Another one.}
\end{figure}
\end{document}