Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\newfloat{rcode}{h!}{rcode}
\floatname{rcode}{Code Example}

\begin{rcode}[htb!]
<<label = Example1, echo= true>>=
 bunch of R code
@
\caption{First code example}
\label{CodeEx1}
\end{rcode}

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
    
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
add comment

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

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

1 Answer

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
add comment

Your Answer

 
discard

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.