Skip to content

Instantly share code, notes, and snippets.

@keeferrourke
Created May 28, 2018 04:03
Show Gist options
  • Save keeferrourke/e740d420e55bc02ed48a5d80b4812de8 to your computer and use it in GitHub Desktop.
Save keeferrourke/e740d420e55bc02ed48a5d80b4812de8 to your computer and use it in GitHub Desktop.

Revisions

  1. keeferrourke revised this gist May 28, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion latexcompile
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    # the CC0 legalcode.

    if [ $# -eq 0 ]; then
    echo "usage: latexcompile FILE.tex"
    echo "usage: latexcompile FILE.tex [--open]"
    echo "cleanly compile LaTeX documents to PDF without cluttering the" \
    working directory."
    exit 2
  2. keeferrourke created this gist May 28, 2018.
    34 changes: 34 additions & 0 deletions latexcompile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    #!/bin/bash
    #
    # latexcompile
    # Keefer Rourke <[email protected]>
    #
    # To the extent possible under law, the person who associated CC0 with
    # latexcompile has waived all copyright and related or neighboring rights
    # to latexcompile.
    #
    # See <http://creativecommons.org/publicdomain/zero/1.0/> for a copy of
    # the CC0 legalcode.

    if [ $# -eq 0 ]; then
    echo "usage: latexcompile FILE.tex"
    echo "cleanly compile LaTeX documents to PDF without cluttering the" \
    working directory."
    exit 2
    fi
    BASE="${1%.*}"
    pdflatex $1 2>/dev/null 1>&2
    if [ $? -ne 0 ]; then
    echo "Compilation error. Check log."
    exit 1
    fi
    rm "$BASE.log" "$BASE.aux" "$BASE.out"
    if [ $2 == "--open" ] || [ $2 == "-o" ]; then
    xdg-open "$BASE.pdf"
    fi
    exit 0