pandoc-ext / section-bibliographies

Filter to create a separate bibliography for each section or chapter
MIT License
41 stars 4 forks source link

Reference list starts on new page, no page break before next section #4

Closed ajstamm closed 1 year ago

ajstamm commented 1 year ago

So far, your lua is the only one I have gotten to work for my dissertation. However, my reference lists consistently start on a new page, after the references header, then there is no page break before the new chpater, even if the new chapter is a separate file.

I think the issue is that I call pagebreak or newpage just before the next chapter heading and your code thinks it's supposed to come before the reference list, then doesn't call newpage after the reference list. Is there a way to override this? I'm using pandoc in RStudio on Windows.

Thanks!

tarleb commented 1 year ago

Hi, and apologies for the late reply.

My suggestion would be to use a filter to add the pagebreaks. E.g., this filter would add a pagebreak before every chapter:

function Header (h)
  if h.level == 1 then
    return {pandoc.RawBlock('tex', '\\newpage'), h}
  end
end

The filter should be written to a file and run after the section-bibs filter. E.g.

filters:
  - section-bibs
  - insert-pagebreaks.lua

I hope this doesn't come too late, good luck for your dissertation!

ajstamm commented 1 year ago

Thank you, @tarleb ! I'll try that and let you know how it works. Dissertation is due in April, so I still have time to figure it out.

tarleb commented 1 year ago

One more question: which output format are you targeting? PDF, docx, both, or something different? Asking because there might be a format dependent solution that could be simpler than what I propose above.

ajstamm commented 1 year ago

I'm writing to PDF.

tarleb commented 1 year ago

Then the solution might be as simple as setting documentclass: book.

ajstamm commented 1 year ago

I'll try that, too, and let you know what works.

Crismoc commented 1 year ago

Hi, and apologies for the late reply.

My suggestion would be to use a filter to add the pagebreaks. E.g., this filter would add a pagebreak before every chapter:

function Header (h)
  if h.level == 1 then
    return {pandoc.RawBlock('tex', '\\newpage'), h}
  end
end

The filter should be written to a file and run after the section-bibs filter. E.g.

filters:
  - section-bibs
  - insert-pagebreaks.lua

I hope this doesn't come too late, good luck for your dissertation!

Thanks for providing this solution! Just as a reference for future users, it happened to me that I wanted to avoid the page break in the first level 1 header (# Abstract), so I made it a level 2 header (## Abstract) and then I used a dummy level 1 header (#).

tarleb commented 1 year ago

Closing now, as I believe that we can't do much about it within this filter.