Rich Shepard wrote, On 10/10/2007 09:21 AM:
  This is not LyX specific, but I'm hoping that some of you can provide
direction to help me find the solution I need.

  In brief: we're developing an approximate reasoning model (a type of
expert system) in Python and C, with data maintained in an embedded SQLite
database. I'd like to produce reports via LaTeX and pdflatex. To do so, I
need to write report-specific LaTeX templates that have replaceable
variables where the content goes. Then, the applicaion would
programmatically extract the required information from a database table and
fill in the template for the report.

  I cannot find how to create such a LaTeX template in "Guide to LaTeX" or
TLC2. LaTeX document classes are templates themselves, but are used to
manually fill in the document content. Can this content be provided
programmatically?

  Suggestions appreciated.

TIA,

Rich


I have done such a beast, therefore it can be done. :)
The method I used involved having a LaTeX file[1], which at an appropriate place[2] in the file, uses \input{MyVariableData.tex} and then when I want the data from a variable I just use \MyFirstVar at the appropriate place in the "template" file.

I had to be careful in my C program to properly escape LaTeX special chars before it wrote the data to MyVariableData.tex, i.e., at least "_", "*" and "\" become "\_", "{*}" and "\textbackslash{}".
There are probably others you need to look out for like "%" & "@".

in MyVariableData.tex there are lines of the form:
\def\MyFirstVar{{*}Data{*} for Var\_1}




then with a script passing all the appropriate options to LaTeX, dvips (I needed PostScript output) and an rm of LaTeX temporary data, I have the program create the postscript for sending to the printer.


Hope this helps.


[1] a full LaTeX document which uses a lot stuff from \usepackage{ifthen} \usepackage{soul} \usepackage{pstricks} \usepackage{pst-text} \usepackage{pst-eps} \usepackage[dvips]{graphicx} \usepackage[dvips]{geometry} I love the funky stuff you can do with LaTeX... like making CD labels with curved words on top of pictures. I started from:
http://www.aldil.org/projets/TeX_cd_label.html

[2] appropriate from the perspective that you may need some packages defined before the variable file is pulled in, and you need to pull in the variable file before you try to use one of it's variables in the main LaTeX file.


--
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter
http://www.crane.navy.mil/custfeedback

Reply via email to