Created
June 24, 2016 10:19
-
-
Save paralleltree/b26d5d7b6a7a4d41023094075a06d334 to your computer and use it in GitHub Desktop.
generate a pdf file from the tex file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
## tex to pdf | |
# ex.) pdfgen sample.tex | |
# ex.) pdfgen sample.tex | xargs evince | |
test $# -eq 1 || { | |
NAME="$(basename $0)" | |
echo "$NAME - generate a pdf file from the tex file" >&2 | |
echo "Usage: $NAME [tex-file]" >&2 | |
exit 1 | |
} | |
SRC=$* | |
NAME=$(basename "$SRC" ".tex") | |
ENCODE=$(nkf -g "$SRC") | |
case "$ENCODE" in | |
UTF-8) KANJI="utf8";; | |
EUC-JP) KANJI="euc";; | |
Shift-JIS) KANJI="sjis";; | |
ISO-202-JP) KANJI="jis";; | |
esac | |
PLATEX="platex" | |
CLASS=$(sed -n '/documentclass/p' "$SRC" | sed '/%.*documentclass/d' | sed -n '1p') | |
case $CLASS in | |
*{u*) PLATEX-"uplatex" | |
esac | |
DIR=/tmp | |
DVI="$DIR/$NAME.dvi" | |
PDF="$DIR/$NAME.pdf" | |
$PLATEX -output-directory="$DIR" -kanji=$KANJI "$SRC" >&2 | |
dvipdfmx -o $PDF $DVI >&2 | |
echo $PDF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment