Last active
July 16, 2022 10:17
-
-
Save naoh16/dc76f95f6146b67805988e9d0b4980f2 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/bash | |
# | |
# Document rendering tool with 'upLaTeX' on EDUSYS environment | |
# | |
# rev.5 S. Hara, 2022.07.16 * Print parts of errors/warnings | |
# rev.4 S. Hara, 2022.06.16 * fix bug related log files | |
# rev.3 S. Hara, 2022.03.23 * platex --> uplatex | |
# rev.2 S. Hara, 2019.01.21 * bash version | |
# rev.1 N. Watanabe, 2013.12.19 * csh version | |
# | |
# INSTALL on Ubuntu on WSL2 | |
# $ mkdir -p ~/.local/bin | |
# $ cd ~/.local/bin | |
# $ wget https:xxxxxxxxxx # <-- You can find Download URL at "view raw" | |
# $ chmod +x edu-uplatex2pdf | |
# $ exit # restart your terminal | |
# | |
TEXOPT="-interaction=nonstopmode -file-line-error -shell-escape" | |
TEXOPT1="${TEXOPT} -halt-on-error" | |
TEXOPT2="${TEXOPT} -halt-on-error -synctex=1" | |
if [ $# != 1 ]; then | |
echo 1>&2 "usage: $0 filename[.tex]" | |
exit 1 | |
fi | |
BASENAME=${1%.*} | |
if [ ! -f ${BASENAME}.tex ]; then | |
echo 1>&2 "Error: ${BASENAME}.tex: No such file" | |
exit 2 | |
fi | |
# | |
# Run uplatex 1st time | |
# | |
echo "**** RUN: uplatex ${TEXOPT1} ${BASENAME}.tex" | |
uplatex ${TEXOPT1} ${BASENAME}.tex | |
if [ $? -ne 0 ]; then | |
echo 1>&2 "" | |
echo 1>&2 "**** COMMENT FROM EDU-PLATEX ****" | |
echo 1>&2 "**** Error: Let's see ${BASENAME}.log, and solve errors." | |
echo 1>&2 " http://www.edu.cs.okayama-u.ac.jp/info/tool_guide/tex.html#id4" | |
echo 1>&2 "" | |
ls -la ${BASENAME}.log | |
grep --color -A2 -E '^(!|\*{3}).*' ${BASENAME}.log | |
grep --color -A2 -E '^[^:]+:[0-9]+:.*$' ${BASENAME}.log | |
rm -f ${BASENAME}.aux | |
exit 3 | |
fi | |
# | |
# Run uplatex 2nd time | |
# | |
echo "**** RUN: uplatex ${TEXOPT2} ${BASENAME}.tex" | |
uplatex ${TEXOPT2} ${BASENAME}.tex | |
if [ $? -ne 0 ]; then | |
echo 1>&2 "" | |
echo 1>&2 "**** COMMENT FROM EDU-PLATEX ****" | |
echo 1>&2 " Error: Let's see ${BASENAME}.log, and solve errors." | |
echo 1>&2 " http://www.edu.cs.okayama-u.ac.jp/info/tool_guide/tex.html#id4" | |
echo 1>&2 "" | |
ls -la ${BASENAME}.log | |
grep --color -A2 -E '^(!|\*{3}).*' ${BASENAME}.log | |
grep --color -A2 -E '^[^:]+:[0-9]+:.*$' ${BASENAME}.log | |
rm -f ${BASENAME}.aux ${BASENAE}.dvi | |
exit 4 | |
fi | |
# | |
# Render as PDF file | |
# | |
echo "**** RUN: dvipdfmx ${BASENAME}.dvi" | |
dvipdfmx ${BASENAME}.dvi | |
# | |
# Validation | |
# | |
if grep -q 'LaTeX Warning' ${BASENAME}.log; then | |
echo 1>&2 "" | |
echo 1>&2 "**** COMMENT FROM EDU-PLATEX ****" | |
echo 1>&2 " Warning: Let's see ${BASENAME}.log." | |
echo 1>&2 " We highly recommend to solve all warnings." | |
echo 1>&2 " http://www.edu.cs.okayama-u.ac.jp/info/tool_guide/tex.html#id5" | |
echo 1>&2 "" | |
ls -la ${BASENAME}.log | |
grep --color -E 'LaTeX Warning' ${BASENAME}.log | |
fi | |
if grep -q '^Overfull' ${BASENAME}.log; then | |
echo 1>&2 "" | |
echo 1>&2 "**** COMMENT FROM EDU-PLATEX ****" | |
echo 1>&2 " Warning: Let's see ${BASENAME}.log and find 'Overfull' message." | |
echo 1>&2 " We highly recommend to solve all 'Overfull' messages." | |
echo 1>&2 " http://www.edu.cs.okayama-u.ac.jp/info/tool_guide/tex.html#id5" | |
echo 1>&2 "" | |
ls -la ${BASENAME}.log | |
grep --color -E '^Overfull' ${BASENAME}.log | |
fi | |
if grep -q 'simple group' ${BASENAME}.log; then | |
echo 1>&2 "" | |
echo 1>&2 "**** COMMENT FROM EDU-PLATEX ****" | |
echo 1>&2 " Warning: Let's see ${BASENAME}.log and find 'simple group' message." | |
echo 1>&2 " We highly recommend to solve all 'simple group' messages." | |
echo 1>&2 " http://www.edu.cs.okayama-u.ac.jp/info/tool_guide/tex.html#id5" | |
echo 1>&2 "" | |
ls -la ${BASENAME}.log | |
grep --color -E 'simple group' ${BASENAME}.log | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment