Compiling To LaTeX -- One file per section?

Yes, this was a very single-purpose demonstration, I think a better script+project example would push more of the configuration into the project and make it easier to switch post-processing on or off—perhaps by using the extension more intelligently, allowing for mixed content out of one compile command. I.e. the extension printed by the Section Layout prefix tab could inform the script whether post-processing should be used for that specific chunk, and if so, to what file type.

I’ve never had time to come back to this and make it a more universally useful tool though.

But for your specific purpose, try the attached script instead:

splitter.rb (1.0 KB)

  • The metadata block capture and prepending into each sub-file is removed, since you stipulate putting metadata into each section that is meant to become a file.
  • The post-processing command is removed from the final loop (where footnotes and image references are added to each file), and replaced with a simple command to move the temp file into the working folder.

As for what to change in the project:

  1. Edit the “MultiFile Output” format.
  2. Change the Section Layout: New File: Prefix tab to end in .md instead of .tex.
  3. Likewise fix the “references.tex” entry in the Text Layout pane.
  4. In Processing, tick Use Pandoc syntax and update the embedded script with the above content, or switch to external execution.
1 Like