From 36026c8f551582752c820b7afa4957b5608f4a00 Mon Sep 17 00:00:00 2001 From: will king Date: Thu, 17 Aug 2023 14:30:06 -0700 Subject: [PATCH] updated compiletex, added tex2docx --- compiletex | 13 +++++++------ tex2docx.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100755 tex2docx.sh diff --git a/compiletex b/compiletex index 4bc5c8e..386978e 100755 --- a/compiletex +++ b/compiletex @@ -1,13 +1,14 @@ #!/bin/bash #Remove the .tex extention, it just messes up the bibliography -tex=${1%%\.tex} +tex="${1%%\.tex}" +flags="${@:2}" +echo "$flags" -pdflatex $tex -biber $tex -pdflatex $tex -pdflatex $tex -pdflatex $tex +latex "$flags" "$tex" +biber "$tex" +latex "$flags" "$tex" +pdflatex "$flags" "$tex" echo echo "Removing biliography database \n\t$tex" diff --git a/tex2docx.sh b/tex2docx.sh new file mode 100755 index 0000000..92dfca2 --- /dev/null +++ b/tex2docx.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Based on notes from https://medium.com/@zhelinchen91/how-to-convert-from-latex-to-ms-word-with-pandoc-f2045a762293 + +while [[ $# -gt 0 ]]; do + case $1 in + -f|--filename) + FILE_STEM="${2%.tex}" + shift # past argument + shift # past value + ;; + -h|--help) + echo "$0 -f|--filename FILENAME [-h|--help] [-b|--bibliography BIBLIOGRAPHY] " + exit 0 + ;; + -b|--bibliography-file) + BIBLIOGRAPHY="${2}" + shift # past argument + shift # past value + ;; + -*|--*) + echo "Unknown option $1" + exit 1 + ;; + *) + #POSITIONAL_ARGS+=("$1") # save positional arg + #shift # past argument + echo "Unknown option $1" + exit 1 + ;; + esac +done + + + +#if there is a bibliography +pandoc "${FILE_STEM}.tex" --bibliography="${BIBLIOGRAPHY}" -o "${FILE_STEM}.docx" +pandoc "${FILE_STEM}.tex" -o "${FILE_STEM}.docx"