public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: BP Jonsson <bpj-J3H7GcXPSITLoDKTGw+V6w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Re-open #2889? Or create a new bug?
Date: Mon, 2 May 2016 20:00:32 +0200	[thread overview]
Message-ID: <572795C0.40203@gmail.com> (raw)
In-Reply-To: <87mvo8zafi.fsf-97jfqw80gc6171pxa8y+qA@public.gmane.org>

Den 2016-05-02 kl. 18:33, skrev Joost Kremers:
> A workaround is to put a \newpage after each heading, or some dummy
> text, or even just a hard space. This is not something Pandoc can fix,
> and fixing it in (La)TeX might even be undesirable if it increases the
> possibility of headings appearing at the bottom of a page.

It can be fixed with a simple pandoc filter (not to be run on the 
final document!)

It inserts a raw latex block containing the command 
`\pagebreak[2]` after every heading, without the need to hardcode 
them in the source.

\pagebreak[2] is what you want here. It 'suggests' a pagebreak 
with a not too low penalty, and does not insert any extra space

/bpj

````python
#!/usr/bin/env python

"""
heading-breaks.py

A pandoc filter which inserts a raw \pagebreak[2] after headings,
so that LaTeX breaks pages between headings in outlines.
"""

import pandocfilters as pf

pagebreak = pf.RawBlock( 'latex', '\\pagebreak[2]' )

def filter_func(key, val, fmt, meta):
     if 'Header' != key:
         return None
     return [pf.Header(*val),pagebreak]


if __name__ == "__main__":
     pf.toJSONFilter(filter_func)
````


  parent reply	other threads:[~2016-05-02 18:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-02 14:57 kurt.pfeifle via pandoc-discuss
     [not found] ` <6f5f70b7-802d-4fcb-ba05-e211149c890a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-02 15:36   ` John MacFarlane
     [not found]     ` <20160502153607.GB43753-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
2016-05-02 15:44       ` kurt.pfeifle via pandoc-discuss
2016-05-02 15:52   ` John Muccigrosso
2016-05-02 16:33   ` Joost Kremers
     [not found]     ` <87mvo8zafi.fsf-97jfqw80gc6171pxa8y+qA@public.gmane.org>
2016-05-02 18:00       ` BP Jonsson [this message]
2016-05-03 10:27 ` Ulrike Fischer
     [not found]   ` <1m7ye3farembp.dlg-bMiYgyzgJ3Ab1SvskN2V4Q@public.gmane.org>
2016-05-03 18:39     ` John MACFARLANE
     [not found]       ` <20160503183915.GB21146-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org>
2016-05-05 18:30         ` BP Jonsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=572795C0.40203@gmail.com \
    --to=bpj-j3h7gcxpsitlodktgw+v6w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).