Created
December 26, 2018 18:54
-
-
Save tk3369/0a36659bab1e0c3bb5a4d105d56af1b4 to your computer and use it in GitHub Desktop.
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 | |
# | |
# Generate PDF file from ipynb notebook. | |
# Several tricks are done to post-process the latex files. | |
if [ $# -ne 1 ]; then | |
echo "Usage: `basename $0` filename" | |
exit 1 | |
fi | |
file="$1" | |
if [ ! -f "$file" ]; then | |
echo "Error: file not found $file" | |
exit 2 | |
fi | |
texfile=`echo "$file" | sed -e 's/ipynb/tex/g'` | |
jupyter nbconvert --to latex --template booktemplate.tplx $file | |
if [ $? -eq 0 ]; then # successful conversion | |
# deal with copyright | |
mv "$texfile" "bak_$texfile" | |
sed -e 's/©/\\textcopyright /g' < "bak_$texfile" > "$texfile" | |
# deal with dollar signs with the extra slash | |
mv "$texfile" "bak_$texfile" | |
sed -e 's/\\textbackslash{}\\\$/\\$/g' < "bak_$texfile" > "$texfile" | |
xelatex $texfile | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment