11

Perhaps I'm missing something, but is there a way to either

(a) ensure that pandoc places pagebreaks before level 1 and level 2 headers in markdown (#,##), or

(b) hide \newpage from other markdown tools?

Is it possible to edit the template that pandoc uses for the conversion in order to do (a)?

Any ideas gratefully received.

:-)

5
  • 1
    You can easily tweak the style to get get pagebreaks before section. In ConTeXt, one can simply add \setuphead[section,subsection][page=yes]. The titlesec package in LaTeX should provide similar functionality.
    – Aditya
    Sep 4, 2013 at 15:35
  • 1
    Ok, pretend for a moment that I don't have a clue what ConTeXt is ;-)
    – Dycey
    Sep 4, 2013 at 15:37
  • So, what you're saying is pandoc -s -w context doc.md -o doc.tex then edit the .tex file to include your \setuphead line, and context doc.tex ?
    – Dycey
    Sep 4, 2013 at 16:00
  • Nope, that did something weird :-) Dropped me into a text editor (vim? emacs?) and complained bitterly.
    – Dycey
    Sep 4, 2013 at 16:07
  • ConTeXt is a TeX macro package (just like LaTeX is a TeX macro package). The method you described should work (I don't know what calling context will drop you into an editor). Ideally, you should modify the default ConTeXt template to create a custom template (see pandoc documentation) that has the above line included, so that you do not have to edit the file to add that line every time.
    – Aditya
    Sep 4, 2013 at 17:38

3 Answers 3

6

pandoc --chapters, or pandoc -V documentclass=memoir or pandoc -V documentclass=book will tell pandoc to treat level 1 headers as chapters rather than sections. In both the book and memoir document classes, chapters are preceded by page breaks.

I'm not sure exactly what you need to set in your header to get page breaks before sections. Have you read the documentation for the memoir class? It includes a \setbeforesectionskip{} command that might a place to start.

4

The problem is that LaTeX is not really intended for unattended typesetting.

I concur with Aditya in that ConTeXt is better equipped in dealing with automated page breaks using a setup along the lines of:

\setuphead[section,subsection][page=yes, before={\placefloats\testpage[11]}]

However, in my personal experience, I have obtained even better, flawless results using CSS paged media engines; like for example Prince XML.

Read more about this here. The PDFs on my personal web site are produced like this. Inspect the makefile for the gory details.

1

You can just use a lua filter for this case see Pandoc Lua filter for page breaks. Simply call:

$ pandoc --lua-filter pagebreak.lua -f markdown your.md

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .