TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bit of Sweave code as such:

<<label = Example1, echo= true>>=
//Bunch of R Code

I've tried putting it in my own float environment like so

\floatname{rcode}{Code Example}

<<label = Example1, echo= true>>=
 bunch of R code
\caption{First code example}

But then the float is too big and goes on the next page. How do I get it to split over the page like it did before the environment. I've tried the continuedfloat package and wasn't able to get it working. I've also tried the algorithm package and had problems there as well.

share|improve this question

migrated from stackoverflow.com Jun 22 '12 at 14:44

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Jun 22 '12 at 17:07
Your specifiers of the float parameters are wrong. Please see: tex.stackexchange.com/questions/39017/… – Marco Daniel Jun 22 '12 at 17:15
You can try the knitr package instead of Sweave, with which you can use your own environment easily (e.g. gist.github.com/2760395) without writing \begin{rcode} and \end{rcode} repeatedly. – Yihui Jun 22 '12 at 20:14

Floats deliberately stay together, and if necessary move to a later page to avoid leaving large spaces. Either accept this approach and use a \label/\ref to refer to your code, or don't put the code in a float and allow it to break over the page.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.