minted truncates the code if it doesn't fit into one page
Unfortunately, this behaviour is due to a known bug. Worse, I have no idea how to fix it.
In the long run, I plan to get rid of the fancyvrb
package altogether since strictly speaking minted
doesn’t need the verbatim capabilities – LaTeX sequences get escaped anyway. This would lead to a lot more flexibility.
For now, though, this is unfortunately not a trivial change. If you want to get your hands dirty you can try \let
ting \Verbatim
and \endVerbatim
to \relax
, and then tinkering a bit to get the rendering right again. Disclaimer: I haven’t tried this.
The bad behaviour of the minted package in truncating code can be prevented through the mdframed package. Example:
\begin{mdframed}[linecolor=black, topline=true, bottomline=true,
leftline=false, rightline=false, backgroundcolor=yellow!20!white]
\begin{minted}[mathescape]{c++}
int main()
{
bla bla...
}
\end{minted}
\end{mdframed}
Obviously you should have package mdframed loaded in your preamble, simply by \usepackage{mdframed}
and eventually with global options.
Even better, without pasting:
\begin{mdframed}[linecolor=black, topline=true, bottomline=true,
leftline=false, rightline=false, backgroundcolor=yellow!20!white]
\inputminted[fontsize=\scriptsize, linenos, frame=lines]{c++}{path/to/your/code.cpp}
\end{mdframed}