December 13, 2025

Start using Make to compile pdf with Pandoc

For a long time I have used a Pandoc command like this to convert Markdown files to pdf files:

$ pandoc -o essay.pdf \ 
--pdf-engine=xelatex metadata.yaml \
--lua-filter=/home/user/bin/smallscripts/count-para.lua \
--trace essay.md \

I first used to retrieve this command from history in Bash, then later saved it to an executable file.

I knew I could use Make, and wanted to learn how to use Make.

The other day I finally put together a first makefile:

TEX = pandoc
SRC = essay.md
FLAGS = --pdf-engine=xelatex metadata.yaml --lua-filter=/home/user/bin/smallscripts/count-para.lua --trace

essay.pdf : $(SRC)
    $(TEX) -o $@ $< $(FLAGS)

.PHONY: clean
clean :
    rm essay.pdf

Now I can run make to compile.

Appendix

For those who would like to see more.

  1. The metadata.yaml file in question looks like this:
    ---
    geometry:
    - margin=1in 
    documentclass: extarticle 
    fontsize: 14pt 
    linestretch: 1.25 
    ...
  1. You can find the script count-para.lua, which numbers paragraphs, there: https://git.yctct.com/small/tree/count-para.lua

Resources

https://web.archive.org/web/20081020060748if_/http://www.cs.colby.edu:80/maxwell/courses/tutorials/maketutor/

The man page of Make.


personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki publishing make pandoc

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2025 by yctct is licensed under CC BY-SA 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88