I have this so far, but formatting the latex string seems tedious. I am also aware of SageTeX but there, any type of errors simply cause a failure in compiling the pdf file without much information as to what caused the error, or the error messages are not very visible to me. Here is what I have so far.. link text