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.

minted works well when the code snippet is short, or fit into one page. The problem occurs when I pasted a code snippet with several hundred lines. Sometimes it processed but the output was truncated; other times it produced a bunch of errors. And if I break it into pages, the amount of characters in each page matter, i.e. it could yield a blank page after the \end{minted}. For example:

....
\begin{minted}[bgcolor=bg,mathescape]{c++}
code here
\end{minted}
... -> a blank page sometimes appear
\begin{minted}[bgcolor=bg,mathescape]{c++}
code here
\end{minted}
....

Has anyone encountered this awkward behavior with minted package? Any idea or suggestion would be greatly appreciated. Thanks.

share|improve this question
    
FYI, this behaviour is known, it’s a bug, and I have no idea how to fix it. –  Konrad Rudolph Oct 9 '11 at 16:11
    
@KonradRudolph: Please turn your comment into an answer. –  lockstep Dec 3 '11 at 22:14
    
I have recently converted a lot of source files to pdf using minted package with no problems and errors, each resulting pdf files several pages long. For each source file, a .tex file was generated, and the source code was inserted with \inputminted[opts...]{c++}{file}. –  guillem Nov 26 '12 at 9:59
add comment

2 Answers

up vote 6 down vote accepted

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 \letting \Verbatim and \endVerbatim to \relax, and then tinkering a bit to get the rendering right again. Disclaimer: I haven’t tried this.

share|improve this answer
add comment

You can prevent minted bad pagebreak behaviour by using externally package mdframed. 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}
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.