pbdl-book/make-pdf.sh

116 lines
2.8 KiB
Bash
Raw Normal View History

2021-04-04 07:48:21 +02:00
# source this file with "." in a shell
2021-06-30 17:03:07 +02:00
# do clean git checkout?
2021-06-29 18:02:09 +02:00
#DIR=/Users/thuerey/Dropbox/mbaDevelSelected/pbdl-book/
2021-06-30 17:03:07 +02:00
#DIR=/Users/thuerey/Dropbox/mbaDevelSelected/pbdl-book-cleanCheckout/
#cd ${DIR}
2021-06-29 18:02:09 +02:00
# warning - modifies notebooks!
python3.7 json-cleanup-for-pdf.py
2021-06-30 17:03:07 +02:00
#TEMP!!!! python3.7 ../pbdl-book/json-cleanup-for-pdf.py
2021-06-29 18:02:09 +02:00
2021-06-30 17:03:07 +02:00
# clean / remove _build dir ?
2021-06-29 18:02:09 +02:00
# GEN!
/Users/thuerey/Library/Python/3.7/bin/jupyter-book build . --builder pdflatex
cd _build/latex
2021-06-30 18:55:15 +02:00
mv book.pdf book-xetex.pdf
2021-06-29 18:02:09 +02:00
2021-06-30 17:03:07 +02:00
rm -f book-in.tex sphinxmessages-in.sty book-in.aux book-in.toc
2021-06-29 18:02:09 +02:00
mv book.tex book-in.tex
mv sphinxmessages.sty sphinxmessages-in.sty
2021-06-30 17:03:07 +02:00
mv book.aux book-in.aux
mv book.toc book-in.toc
2021-06-29 18:02:09 +02:00
2021-06-30 17:03:07 +02:00
#TEMP!!!! python3.7 ../../../pbdl-book/fixup-latex.py
2021-06-29 18:02:09 +02:00
python3.7 ../../fixup-latex.py
# generates book-in2.tex
# remove unicode chars
iconv -c -f utf-8 -t ascii book-in2.tex > book.tex
2021-06-30 17:03:07 +02:00
# run pdflatex?
pdflatex -recorder book
# pdflatex -recorder book
2021-06-29 18:02:09 +02:00
exit
# OLD VERSION
2021-04-04 07:48:21 +02:00
echo
2021-04-26 08:12:34 +02:00
echo Note: first comment out PG chapter in _toc
2021-04-04 07:48:21 +02:00
echo Note: manually quit first latex pass with shift-x
echo
2021-06-29 18:02:09 +02:00
#DIR=/Users/thuerey/Dropbox/mbaDevelSelected/pbdl-book/
DIR=/Users/thuerey/Dropbox/mbaDevelSelected/pbdl-book-cleanCheckout/
2021-04-22 04:26:01 +02:00
cd ${DIR}
#echo Note: make sure to copy latex helpers! cp ./latex-helpers/* ./_build/latex/
mkdir _build
mkdir _build/latex
cp ./latex-helpers/* ./_build/latex/
# first preliminary build to generate .tex file
2021-04-04 07:48:21 +02:00
/Users/thuerey/Library/Python/3.7/bin/jupyter-book build . --builder pdflatex
2021-04-04 15:54:19 +02:00
# fix up latex
# TODO, use py script later on...
2021-04-22 04:26:01 +02:00
cd ${DIR}/_build/latex
2021-04-04 07:48:21 +02:00
export JPYFILENAME=book.tex
rm ${JPYFILENAME}-in.bak
mv ${JPYFILENAME} ${JPYFILENAME}-in.bak
iconv -c -f utf-8 -t ascii ${JPYFILENAME}-in.bak > ${JPYFILENAME}
echo running SED
2021-04-26 08:12:34 +02:00
# ugly fix for double {{name}.jpg} includes, eg
# \sphinxincludegraphics{{physics-based-deep-learning-overview}.jpg}
# \sphinxincludegraphics[height=240\sphinxpxdimen]{{overview-pano}.jpg}
2021-04-04 07:48:21 +02:00
sed -i '' -e 's/sphinxincludegraphics{{/sphinxincludegraphics{/g' ${JPYFILENAME}
sed -i '' -e 's/}.png}/.png}/g' ${JPYFILENAME}
sed -i '' -e 's/}.jpg}/.jpg}/g' ${JPYFILENAME}
sed -i '' -e 's/}.jpeg}/.jpeg}/g' ${JPYFILENAME}
sed -i '' -e 's/sphinxpxdimen]{{/sphinxpxdimen]{/g' ${JPYFILENAME}
2021-04-04 15:48:58 +02:00
# dirty fix for chapters
2021-04-26 08:12:34 +02:00
# note, keep chapters? (chaXter) only move all other sections one level "up"?
2021-04-04 15:48:43 +02:00
# sed -i '' -e 's///g' ${JPYFILENAME}
2021-04-04 15:54:19 +02:00
sed -i '' -e 's/\\chapter{/\\chaXter{/g' ${JPYFILENAME}
sed -i '' -e 's/\\section{/\\chapter{/g' ${JPYFILENAME}
sed -i '' -e 's/\\chaXter{/\\subsection{/g' ${JPYFILENAME}
2021-04-04 15:48:43 +02:00
2021-04-04 15:54:19 +02:00
# include mathrsfs package for mathscr font
2021-04-04 07:48:21 +02:00
# ugly, -i doesnt work here:
sed '28i\
\\usepackage{mathrsfs} ' ${JPYFILENAME} > tmp-latex
echo renaming: tmp-latex ${JPYFILENAME}; ls -l tmp-latex ${JPYFILENAME}
rm ${JPYFILENAME}
mv tmp-latex ${JPYFILENAME}
2021-04-04 15:54:19 +02:00
# finally done
2021-04-04 07:48:21 +02:00
echo running LATEX
pdflatex book
echo running LATEX , 2nd pass
pdflatex book
cd ../..