0

As shown here, Control's code (and the code of the sections after it) are on subsequent pages. I want the code to be shown directly in the same subheading.

My subheadings look like this:

*** ~Code file header~
#+CAPTION: ~Code file path~
#+BEGIN_SRC scala -n
Scala code
#+END_SRC
1

I think your question isn't actually about breaking code blocks (i.e., making the lines wrap to fit across the width of the page, or splitting the block over two pages).

From your proposed solution, I think the actual problem is that your code blocks are floating, meaning they don't appear where you've put them in the text, but actually show up later on in the document. This is a consequence of exporting to pdf, which uses LaTeX. LaTeX provides very sophisticated, and occasionally annoying, handling of floats. When you supply a #+CAPTION to your source code, org mode assumes you want to treat the block as a float.

You can force the block not to float by including :float nil flag:

 *** ~Code file header~
#+CAPTION: ~Code file path~
#+ATTR_LATEX: :float nil
#+BEGIN_SRC scala -n
Scala code
#+END_SRC
0

Adding

#+LaTeX_HEADER: \renewcommand{\listing}[6]{}

hacks out the effects of the \begin{listing}[htbp]s, which are placed around the \begin{minted} tags. The htbp seems to cause the break prevention.

  • @Drew I think it's there now – Soren Mar 14 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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