Tell me more ×
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 am using Pandoc to generate Tex from Markdown. It automatically generates listings when it comes across the appropriate Markdown (code indented four spaces). It then uses the listings package to instantiate those listings in Tex. The resulting code is:

\begin{lstlisting}[language=bash]
    # java -version
    java version "1.7.0_09-icedtea"
    OpenJDK Runtime Environment (rhel-2.3.3.el6_3.1-i386)
    OpenJDK Client VM (build 23.2-b09, mixed mode)
\end{lstlisting}

Sometimes these code listings extend across a page break and I'd prefer if they were bumped to the next page if this happens. I've looked around and seen a few suggestions about adding a minipage to the listing but since my Tex is being auto-generated via Pandoc it's not clear how I can do that without manually editing the resulting Tex document to add the minipages before and after the lstlistings.

So I am looking for:

  1. A way to bump the listings to the next page automatically, or
  2. A way to tell LaTex to redefine the lstlisting to have minipages before and after it.

EDIT: I should have added for those unfamiliar with Pandoc that the template it uses to generate Tex is here.

Thanks!

share|improve this question
Do you have access to a document preamble? I'm unfamiliar with Pandoc's interface. – Werner Dec 25 '12 at 5:25
This is the default LaTeX template that Pandoc generates this: github.com/jgm/pandoc-templates/blob/master/default.latex. – jamtur01 Dec 25 '12 at 5:28
Line 47-49 designates a condition based on the existence of a listing (I guess). Instead of a single line (48) with \usepackage{listings}, use \usepackage{listings,float}\lstset{float=H}. Again, since I'm unfamiliar with Pandoc, you'll have to try it. – Werner Dec 25 '12 at 5:40
You are correct - that enables the listings package when you pass the --listings option to Pandoc. I've made your change and given that a try but the listings continue to extend over the page break I am afraid. Thanks for your help though. – jamtur01 Dec 25 '12 at 5:59
The float option seem to be specific to an environment, and cannot be set globally. Do you have access to the language settings it uses (language=bash)? – Werner Dec 25 '12 at 16:04
show 4 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.