adding functionality for pdfmaking

some stuff should be factored out; currently doubled
a few more fragile errorchecking changes

tries at altering .coffee file for sum, unsuccessful