Last active
March 5, 2022 06:14
-
-
Save kosugitti/b1bddd8f9fbb3f9f97a46d6f0569d0b6 to your computer and use it in GitHub Desktop.
本を作る時に一括コンパイルするためのバッチファイル
This file contains 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
#!/usr/bin/bash | |
#####################################################################text1 | |
## changePath | |
path="course_materials/tex" | |
filename="Dkiso1_book" | |
cd $path | |
## backup | |
cp ${filename}.tex ${filename}.old | |
########### upgrade patch | |
val=$(sed -n 4p ${filename}.tex ) | |
version=`echo $val | sed -E "s/lhead{version.//" | sed -E "s/}//"` | |
version=${version#\\} | |
if [[ ${version} =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | |
all=${BASH_REMATCH[0]} | |
major=${BASH_REMATCH[1]} | |
minor=${BASH_REMATCH[2]} | |
patch=${BASH_REMATCH[3]} | |
fi | |
plusOne=`expr "$patch" "+" "1"` | |
newVer=${major}.${minor}.${plusOne} | |
newval=`echo $val | sed -e "s/$version/$newVer/"` | |
#echo $val | sed -e "s/$val/$newval/" | |
## バージョンNo.を書き換える | |
echo "New version"$newVer | |
cat ${filename}.tex | (rm ${filename}.tex; sed "s/$val/$newval/" > ${filename}.tex) | |
echo "コンパイル始めます" | |
cp ${filename}.tex tmp.tex | |
echo "基礎テキストの最新バージョンは"$newVer "です。" >| ../../Book_versions1.md | |
## LateX Main | |
rm error.log | |
lualatex tmp | |
upbibtex tmp | |
lualatex tmp | |
lualatex tmp | |
upmendex -r -c -g -s ../../indexStyle.ist tmp | |
lualatex tmp | |
## Tex Warning Check | |
grep 'undefined' tmp.log > error.log | |
grep 'multiply' tmp.log >> error.log | |
grep 'Citation' tmp.log >> error.log | |
grep 'Overfull' tmp.log >> error.log | |
## cleanup | |
mv tmp.pdf ../../${filename}.pdf | |
mv tmp.log ../../${filename}.log | |
rm tmp.* | |
rm *.aux | |
rm *.dvi | |
rm *.toc | |
rm *.bbl | |
rm *.blg | |
rm *.out | |
rm *.fls | |
rm *.fdb_latexmk | |
rm *.synctex.gz | |
rm *.ltjruby | |
rm *.ilg | |
rm *.idx | |
rm *.ind | |
cd .. | |
cd .. | |
echo $(date) | |
echo 'データ解析基礎のテキストを改定しました。' | |
cat Book_versions1.md | |
cat course_materials/tex/error.log | |
cat syllabus/error.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment