On Tue, 25 Mar 2008, Rich Shepard wrote:
Has anyone done this? Our model is written in Python, so we can use the
open() and write() methods to squirt strings to a disk file.
After learning PyX (Python wrapper for TeX/LaTeX primarily for graphics),
and trying to use it to write the reports, I'm back to embedding LaTeX
markup in Python comments. Risking public humiliation (Hey! I'm used to that
since I testify at all sorts of government hearings.), I'm posting my first
abortive attempt to learn how to do the job. Small file attached; as long as
you have python installed on your system, it will run.
However, the output is not what I expected. I think it's really a Python
issue, not a LaTeX issue, so I've asked the local python geeks for help.
But, since I started this thread I thought to keep you all informed of
progress.
Rich
--
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
#!/usr/bin/env python
import os, sys, config
preamb = """
\documentclass[oneside,english]{article}
\usepackage{palatino}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[dvips] {geometry}
\geometry{verbose,letterpaper,tmargin=1.5cm,bmargin=1.5cm,lmargin=1.5cm,rmargin=1.5cm}
\pagestyle{empty}
\makeatletter
\date{}
\setlength\headsep{4.4cm}
\setlength{\textheight}{18.5cm}
\setlength{\textwidth}{25.0cm}
\usepackage{babel}
\makeatother
\begin{document}
"""
ending = """\end{document}"""
def econPairs():
pairData = [("Jobs","Tax base"),
("Jobs","Infrastructure"),
("Jobs","Schools"),
("Jobs","Housing"),
("Jobs","Medical care"),
("Jobs","Sustainability"),
("Jobs","Traffic volume"),
("Tax base","Infrastructure"),
("Tax base","Schools"),
("Tax base","Housing"),
("Tax base","Medical care"),
("Tax base","Sustainability"),
("Tax base","Traffic volume"),
("Infrastructure","Schools"),
("Infrastructure","Housing"),
("Infrastructure","Medical care"),
("Infrastructure","Sustainability"),
("Infrastructure","Traffic volume"),
("Schools","Housing"),
("Schools","Medical care"),
("Schools","Sustainability"),
("Schools","Traffic volume"),
("Housing","Medical care"),
("Housing","Sustainability"),
("Housing","Traffic volume"),
("Medical care","Sustainability"),
("Medical care","Traffic volume"),
("Sustainability","Traffic volume")]
ratingHead = """Importance
Value Definition
"""
ratingTab = """1 Equal importance
3 Weak importance of one over the other
5 Strong importance of one over the other
7 Demonstrated importance of one over the other
9 Absolute importance of one over the other
2, 4, 6, 8 Intermediate values between the two adjacent
definitions
"""
instructPara = """Using the table below, determine your preference for either
the first
item of the pair (on the left), or the second (on the
right). Use the
rating table to determine the strength of your preference,
then fully
fill in the rectangle for that preference strength on the
same line as
the component pairs. If you prefer the second more than the
first,
also completely fill in the last box on the right."""
title = "Economic Components"
out = open('omrPairs.tex', 'w')
out.write(preamb)
out.write(title)
out.write("""\vspace{6cm}""") # space below title to line up first line
with OMR form
out.write('Fill in the box under \'Economic\' on this line -->')
out.write("""vspace{1.5cm}""")
out.write('Record your position on the project here -->')
out.write("""\vspace{3cm}""")
for left,right in pairData:
out.write(left)
out.write("""\hspace{3cm}""")
out.write(right)
out.write(ending)
out.close()
if __name__ == "__main__":
econPairs()