Files
Masters_Thesis/03-cs6513-paper/build.sh
T
2026-10-28 17:43:53 +00:00

51 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build a CS6513 IEEE .tex file (-> matching .pdf).
# Usage:
# ./paper/build.sh # builds main.tex (the submission)
# ./paper/build.sh ref_draft # builds ref_draft.tex (personal reference)
# ./paper/build.sh main.tex # .tex extension optional
set -euo pipefail
cd "$(dirname "$0")"
# Which document to build (default: main). Accept an optional first arg, with or
# without a trailing ".tex".
MAIN="${1:-main}"
MAIN="${MAIN%.tex}"
if [ ! -f "$MAIN.tex" ]; then
echo "No such file: $MAIN.tex (in $(pwd))" >&2
exit 1
fi
# Pick up a TeX toolchain that may be installed but not on PATH (MacTeX / TeX Live).
for d in /Library/TeX/texbin /usr/local/texlive/*/bin/* /opt/homebrew/bin; do
if [ -d "$d" ]; then PATH="$d:$PATH"; fi
done
export PATH
if command -v latexmk >/dev/null 2>&1; then
echo "Building with latexmk..."
latexmk -pdf -interaction=nonstopmode -halt-on-error "$MAIN.tex"
elif command -v pdflatex >/dev/null 2>&1; then
echo "Building with pdflatex (two passes to resolve \\cite references)..."
pdflatex -interaction=nonstopmode -halt-on-error "$MAIN.tex"
pdflatex -interaction=nonstopmode -halt-on-error "$MAIN.tex"
elif command -v tectonic >/dev/null 2>&1; then
echo "Building with tectonic..."
tectonic "$MAIN.tex"
else
cat >&2 <<'EOF'
No LaTeX engine found (looked for latexmk, pdflatex, tectonic).
Install one, then re-run this script:
Tectonic (lightest, self-contained ~30MB, fetches packages on demand):
brew install tectonic
BasicTeX (small TeX Live ~100MB; may need `sudo tlmgr install` for extras):
brew install --cask basictex
MacTeX (full TeX Live ~4GB, everything included):
brew install --cask mactex-no-gui
EOF
exit 1
fi
echo "OK -> $(pwd)/$MAIN.pdf"