public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Julien Dutant <julien.dutant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Getting LaTeX process custom output files?
Date: Thu, 25 Mar 2021 06:49:02 -0700 (PDT)	[thread overview]
Message-ID: <04f715c6-bf37-4f03-a780-1c10d4d09740n@googlegroups.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2879 bytes --]

Hi all,

Suppose I have a LaTeX template that generates custom output files as it is 
processed - to record the page number at which each chapter starts. Is 
there a way I can get it back once pandoc is done? From what I see the only 
way is to run pandoc to generate .tex output, and then run pdflatex 
separately to get my custom LaTeX-process output file. Is that right? 

Context: I'm writing a lua filter that generates PDFs for a collection of 
papers. But I would also like it to generate separate PDFs for each 
chapter. Currently I run my filter with:

pandoc -L collection-builder --template collection.latex collection.md -o 
collection.pdf

Where collection.md is a 'driver' file containing only a YAML block with 
fields for every chapter:

---
collection:
- title: My collection
- editor: Jane Doe
chapters:
- filename: chapter1.md
- filename: chapter2.md
----

The Lua filter runs Pandoc on each chapter to generate a .tex file for 
each. It then populates its own metadata with the names of each .tex file:

----
...
chapters:
- filename: chapter1.md
  texoutput: chapter1.tmp.tex
- filename: chapter2.md
  texoutput: chapter2.tmp.tex
---

The template collection.latex then imports all these chapter files with:

$foreach(chapters)$
\import{$chapters.texoutput$)
$endfor$

So my Pandoc command generates a collection.pdf with all the chapters. 
However, to generate PDFs for each chapter separately, I need to know at 
which page it starts in the collection PDF. Ideally, I would like to 
extract this information and add it to chapter1.md's metadata block in a 
page-start field, so that I can later generate single chapters directly 
from those; but it'd be ok if I had to generate the entire collection each 
time I want to regenerate a single chapter PDF.

I can add code to the LaTeX template to tell the LaTeX engine to generate a 
custom output file, e.g. pagenumbers.yaml:

---
chapter1: 1
chapter2: 17
---

But as far as I can tell, if the LaTeX engine is run by Pandoc itself 
there's no way of getting that file back - Pandoc trashes all LaTeX output 
besides the PDF. So it looks to me like my filter should only use Pandoc to 
generate (temporary) .tex files, and then run the pdf engine on them to get 
the pagenumbers.yaml file itself. Is that the best solution? Is there a 
trick to get some custom output of the LaTeX engine back after Pandoc 
generates a PDF I haven't thought of (e.g. in stdout?)?

Any suggestions welcome,

Julien

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/04f715c6-bf37-4f03-a780-1c10d4d09740n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3718 bytes --]

             reply	other threads:[~2021-03-25 13:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AQHXIX2gqLcc1zMbF0m499336o3twKqVDAyAgABF8DA=>
2021-03-25 13:49 ` Julien Dutant [this message]
     [not found]   ` <04f715c6-bf37-4f03-a780-1c10d4d09740n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-03-25 19:48     ` John MacFarlane
     [not found]       ` <m2mturm2tw.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2021-03-25 23:07         ` AW: " denis.maier-FfwAq0itz3ofv37vnLkPlQ
     [not found]           ` <e04c4f87026b4c2b964e551b63ad25aa-FfwAq0itz3ofv37vnLkPlQ@public.gmane.org>
2021-03-26 13:14             ` Julien Dutant
     [not found]               ` <5157881e-36ea-48ef-ba40-30370eed79e3n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-03-26 14:31                 ` AW: " denis.maier-FfwAq0itz3ofv37vnLkPlQ

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=04f715c6-bf37-4f03-a780-1c10d4d09740n@googlegroups.com \
    --to=julien.dutant-re5jqeeqqe8avxtiumwx3w@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).