Commit 033fe089 authored by Olivier's avatar Olivier
Browse files

M3: greatly simplified structure, following improvements in M2

* the input of multiple tex files is no longer necessary
* file names are simpler
* Tex code is compiled twice, to allow for references in PDF

Unfortunately, the README and the sample input and output folders
are falling behind; I hope to fix this when time permits
parent fa5cab8e
......@@ -3,61 +3,40 @@
# Input parameters
inputfolder='script_input'
outputfolder='script_output'
assignmentsourcefile="$inputfolder/assignment.tex"
solutionsourcefile="$inputfolder/solution.tex"
# Cleanup output folder
mkdir -v $outputfolder/old
rm -rvf $outputfolder/old/*
mv -vf $outputfolder/* $outputfolder/old/
# Create links to the source tex files in the current folder
# syntax: ln -s destination linkname
ln -svf "$assignmentsourcefile" assignment.tex
ln -svf "$solutionsourcefile" solution.tex
# Copy every tex file in the input folder into the output folder
cp -vf $inputfolder/*.tex $outputfolder/
cp -vf $inputfolder/*.png $outputfolder/
# Pick up all the files in input folder one by one
for parameterfile in "$inputfolder"/parameters_ID_*.tex; do
# What is the code number?
# Pick up parameter file name, strip all but number, call it $codenumber
codenumber=$(echo $parameterfile | sed "s/$inputfolder\/parameters_ID_//" | sed 's/\.tex//')
cd $outputfolder
for assignmentfile in assignment*.tex; do
echo "#"
echo "#"
echo "building PDFs with code number of $codenumber..."
# Define input and output file names for this problem ID
parameterfilepath=$(echo $inputfolder/parameters_ID_$codenumber.tex)
assignmentfilepath=$(echo $outputfolder/assignment_ID_$codenumber.pdf)
solutionfilepath=$(echo $outputfolder/solution_ID_$codenumber.pdf)
# Make a link called "parameters.tex" that points to the specific
# parameters file for this ID
ln -svf "$parameterfilepath" parameters.tex
# Add LaTeX variable at the end of parameters.tex, which is just
# the custom ID:
echo "\newcommand{\codenumber}{$codenumber}" >> parameters.tex
echo "building assignment PDF for $assignmentfile …"
# Empty up the tmp subfolder
rm -rf tmp/*
# Empty up the tmp subfolder, if it exists
rm -rvf tmp/*
# Make a tmp folder
mkdir -pv tmp
# Compile the actual PDF files:
# compile them with pdflatex
# then move the result to the output folder
pdflatex assignment.tex
mv -vf assignment.pdf $assignmentfilepath
pdflatex solution.tex
mv -vf solution.pdf $solutionfilepath
# Compile the actual PDF file:
pdflatex $assignmentfile
pdflatex $assignmentfile
# Cleanup after pdflatex: move temporary files to tmp subfolder
mv -vf *.aux *.bbl *.bcf *.blg *.ilg *.log *.nav *.nlo *.nls *.run.xml *.snm *.toc *.out *.fls *.fdb_latexmk *.spl *-blx.bib *-eps-converted-to.pdf *bib.bak tmp/
done
cd ../
# Remove remaining symlinks in main folder
rm -v parameters.tex assignment.tex solution.tex
# Remove tex files from output folder
rm -vf $outputfolder/*.tex
echo "end of script."
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment