#!/bin/bash # This script combines all markdown files to a LaTeX file. # Check if pandoc is installed if ! [ -x "$(command -v pandoc)" ]; then echo 'Error: pandoc is not installed.' >&2 exit 1 fi # Check if pandoc-citeproc is installed if ! [ -x "$(command -v pandoc-citeproc)" ]; then echo 'Error: pandoc-citeproc is not installed.' >&2 exit 1 fi FILES=`find . -maxdepth 1 -type f -regex ".*[0-9]+_.*\.md" -print | sort` echo "Converting $FILES to LaTeX..." pandoc -s -S --bibliography=references/references.bib --filter pandoc-citeproc --latex-engine=xelatex -o "out/combined.md.tex" $FILES echo "Done." # convert latex to pdf echo "Converting LaTeX to PDF..." xelatex -output-directory=out main.tex echo "Done."