# How to enable the breaking of code blocks in a PDF?

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.

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


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


#+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.