Skip to content

Instantly share code, notes, and snippets.

@hoto17296
Last active December 27, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoto17296/7356466 to your computer and use it in GitHub Desktop.
Save hoto17296/7356466 to your computer and use it in GitHub Desktop.
texコンパイルしてpdf作って開く一連の動作をまとめた
#!/bin/sh
error(){ echo "Error: $1" 1>&2 && exit 1; }
if [ $# -eq 0 ]; then error 'Too few arguments.'; fi
if [ $# -gt 2 ]; then error 'Too many arguments.'; fi
clean()
{
echo 'Clean:'
if [ $# -eq 0 ]
then rm -fv ./*.log ./*.aux ./*.dvi ./*.toc
else rm -fv ./$1.log ./$1.aux ./$1.dvi ./$1.toc
fi
}
if [ $1 = clean ]; then clean && exit; fi
if [ ! -r $1.tex ]; then error "Can't find $1.tex"; fi
if [ $# -eq 2 ]; then
i=$2
while [ $i -gt 1 ]; do
platex $1.tex || exit 1
i=$((i-1))
done
fi
platex $1.tex && \
dvipdfmx $1.dvi && \
open $1.pdf && \
clean $1
@hoto17296
Copy link
Author

texc

Usage

Compile hoge.tex and create pdf

$ texc hoge

Compile 3 times

$ texc hoge 3

Remove *.log *.aux *.dvi *.toc files

$ texc clean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment