# Will Styler # Markdown to LaTeX Dissertation Build Script # Captures the date for later use date=`date +"%m-%d-%y-%H%M"` # Move into the build folder cd ~/Documents/dissertation/0_build/ # Copy the scripts used to generate my models into the folder, for safe keeping cp ~/Documents/dissertation/4_correlations_and_ML/_run_ml.py . cp ~/Documents/dissertation/4_correlations_and_ML/_run_analyses.py . cp ~/Documents/dissertation/5_englishperc/_diss_perc_analysis.r . # Gather the files which together constitute a dissertation into one place. cat ~/Documents/dissertation/will_dissertation.md > disbuild.md # These two are actually TeX files, but I call them .md so I can edit them on an iPad cat ~/Documents/dissertation/will_diss_abstract.md > will_diss_abstract.tex cat ~/Documents/dissertation/will_diss_acknowledgements.md > will_diss_acknowledgements.tex # Run Pandoc to turn the markdown file with the bulk of the document into a .TeX file /usr/local/bin/pandoc -f markdown --latex-engine=xelatex -R -i disbuild.md -o pandocked.tex # Remove some of the junk that Markdown adds when converting to TeX. sed -i .bak 's/\[<+->\]//g' ~/Documents/dissertation/0_build/pandocked.tex sed -i .bak 's/\\def\\labelenumi{\\arabic{enumi}.}//g' ~/Documents/dissertation/0_build/pandocked.tex sed -i .bak 's/\\itemsep1pt\\parskip0pt\\parsep0pt//g' ~/Documents/dissertation/0_build/pandocked.tex # This turns the word "F0" into a pretty version, with a subscript. perl -pi -w -e 's/F0/F\$_{0}\$/g;' ~/Documents/dissertation/0_build/pandocked.tex # Concatenate the header file (with the preambles, TOC, etc), the pandoc-created TeX file, and the footer file (with the bibliography) into a single buildable TeX file cat ~/Documents/dissertation/0_build/header.tex ~/Documents/dissertation/0_build/pandocked.tex ~/Documents/dissertation/0_build/footer.tex > ~/Documents/dissertation/0_build/Stylerdissertation.tex # Build the TeX once without stopping for errors (as the hyperref plugin throws errors on the first run) /usr/texbin/xelatex -output-driver="/usr/texbin/xdvipdfmx" -interaction=nonstopmode -synctex=1 Stylerdissertation # Render the bibliography based on the prior file /usr/texbin/bibtex Stylerdissertation # Render the file twice more, to ensure that the bibliographical references are included and that the TOC reflects everything accurately /usr/texbin/xelatex -output-driver="/usr/texbin/xdvipdfmx" -synctex=1 Stylerdissertation /usr/texbin/xelatex -output-driver="/usr/texbin/xdvipdfmx" -synctex=1 Stylerdissertation # Open the PDF generated in my PDF reader of choice open /Applications/Skim.app ~/Documents/dissertation/0_build/Stylerdissertation.pdf # Copy the PDF and final TeX out of the build folder for accessibility cp Stylerdissertation.pdf ~/Documents/dissertation/styler_dis_draft.pdf cp Stylerdissertation.pdf ~/Documents/to_read/latest_diss.pdf # Archives a copy of the md and tex files by date, leaving a trail of prior drafts tar cfvz ~/Documents/dissertation/0_build/latest.tar.gz disbuild.md Stylerdissertation.tex _run_analyses.py _run_ml.py _diss_perc_analysis.r # Rename the archived version, including the date generated. mv ~/Documents/dissertation/0_build/latest.tar.gz ~/Documents/dissertation/0_build/backups/diss_bu_$date.tar.gz