Skip to content

Instantly share code, notes, and snippets.

@rsnemmen
Created March 9, 2018 16:26
Show Gist options
  • Select an option

  • Save rsnemmen/92b170a47648fb1daa4db407aeca52bf to your computer and use it in GitHub Desktop.

Select an option

Save rsnemmen/92b170a47648fb1daa4db407aeca52bf to your computer and use it in GitHub Desktop.
Shell script that converts a Markdown document with LaTeX math expressions to a nice PDF
#!/bin/sh
#
# Convert Markdown with LaTeX directives to a PDF file.
#
# Requirements: pandoc
#
# Run this inside your document folder:
# md2tex.sh <MARKDOWN FILE> <OUTPUT FILE>
#
# where:
# - <MARKDOWN FILE>: name of markdown document
# - <OUTPUT FILE>: PDF filename
#
# check if there were command-line arguments
if [ $# -eq 0 ]; then
echo "Usage: "
echo " mdtex.sh <MARKDOWN FILE> <OUTPUT FILE> "
exit 1
fi
pandoc --from=markdown --output=$2 $1 --variable=geometry:"margin=0.5cm, paperheight=500pt, paperwidth=400pt" --highlight-style=espresso --pdf-engine=xelatex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment