Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.13k stars 959 forks source link

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

Open exislow opened 1 year ago

exislow commented 1 year ago

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?

cagix commented 1 year ago

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

GregoryKogan commented 6 months ago

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