conversations
list
source
string
stack
string
[ { "from": "system", "value": "Change the docstring for the pp() function.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# encoding: utf-8\nimport os\n\n\ndef pp(texCode, mode=1):\n \"\"\"@todo: Docstring for pp.\n pp is 'pretty print'. It is a wrapper to the latex\n command, that additionally writes it to a fixed tex file\n and compiles it. That pdf file can remain open in a pdf\n viewer which support automatically reload. This gives\n sort of a \"live view\" of the whatever sage objects you\n want, from the shell.\n :returns: Exit status of the pdflatex command.\n \"\"\"\n\n texFileOut = \"output/sage_output.tex\"\n\n if mode == 1:\n head = '\\\\documentclass[a4paper]{article}\\n\\\\usepackage{breqn}\\n\\\\begin{document}\\n\\\\begin{dmath*}\\n'\n foot = '\\n\\\\end{dmath*}\\n\\\\end{document}'\n if mode == 2:\n head = '\\\\documentclass{standalone}\\n\\\\begin{document}\\n\\\\begin{equation}\\n'\n foot = '\\n\\\\end{equation}\\n\\\\end{document}'\n\n f = open(texFileOut, \"w\")\n f.write(head + latex(texCode) + foot)\n f.close()\n\n r = os.system('pdflatex ' + texFileOut + ' > /dev/null ')\n\n return r\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding: utf-8\nimport os\n\n\ndef pp(texCode, mode=1):\n \"\"\"Pretty printing for sage objects. \n pp is 'pretty print'. It is a wrapper to the latex()\n function, that additionally writes it to a fixed .tex file\n and compiles it. That pdf file can remain open in a pdf\n viewer which support automatically reload. This gives\n sort of a \"live view\" of the whatever sage objects you\n want, from the shell.\n mode=1 uses the 'article' class and 'dmath' environment\n mode=2 uses the 'standalone' class and 'equation'\n :returns: Exit status of the pdflatex command.\n \"\"\"\n\n texFileOut = \"output/sage_output.tex\"\n\n if mode == 1:\n head = '\\\\documentclass[a4paper]{article}\\n\\\\usepackage{breqn}\\n\\\\begin{document}\\n\\\\begin{dmath*}\\n'\n foot = '\\n\\\\end{dmath*}\\n\\\\end{document}'\n if mode == 2:\n head = '\\\\documentclass{standalone}\\n\\\\begin{document}\\n\\\\begin{equation}\\n'\n foot = '\\n\\\\end{equation}\\n\\\\end{document}'\n\n f = open(texFileOut, \"w\")\n f.write(head + latex(texCode) + foot)\n f.close()\n\n r = os.system('pdflatex ' + texFileOut + ' > /dev/null ')\n\n return r\n" } ]
sage
chosen
README.md exists but content is empty.
Downloads last month
39