pandoc-latex-template icon indicating copy to clipboard operation
pandoc-latex-template copied to clipboard

Is it possible to split markdown files into several files and then compile with pandoc?

Open exislow opened this issue 11 months ago • 2 comments

If you write a book your *.md document gets pretty long. It makes sense, e.g. to create a main.md, which include several other markdown files, wheres each included file contains a chapter of the book.

Is this template capable of this?

exislow avatar Aug 04 '23 07:08 exislow

something like pandoc -t pdf --template=https://github.com/Wandmalfarbe/pandoc-latex-template/blob/master/eisvogel.tex main.md chap1.md chap2.md chap3.md -o paper.pdf should work out of the box ... if you really want "includes", check out this Lua filter for Pandoc: https://github.com/pandoc/lua-filters/tree/master/include-files

cagix avatar Aug 04 '23 10:08 cagix

This is great, but can be a little excessive in some cases. I found, that the easiest way of merging multiple markdown files together is just by grabbing them with glob like this:

pandoc src/*.md -o paper.pdf

Glob sorts files lexigraphically, so your src directory should look something like this:

src
├── 0-prologue.md
├── 1-chapter.md
├── 2-chapter.md
└── 3-chapter.md

GregoryKogan avatar Mar 10 '24 15:03 GregoryKogan