Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm starting to write a LaTeX-based reference manual, and have realised that a lot of my needs could be solved by writing a database and then producing the reference manual from that. Lots of my pages will be exactly the same, with slightly different information in them.

Is there a way to link LaTeX to a database, in a similar way to Database Report engines do - so that I can, for example, create a page per record in the database, including each field in different locations on the page?

share|improve this question
13  
Have you considered writing a script (e.g., in Python or Perl) that reads the database and outputs Latex source code? –  Jukka Suomela Oct 2 '10 at 23:01
add comment

7 Answers

up vote 13 down vote accepted

You may try latexdb. It connects LaTeX to a MySQL database.

share|improve this answer
add comment

You might want to check the answers to these questions:

Depending on what you want to do, you could look into the datatool package or pgfplotstable. Or if your needs are more complex (tex is not the most efficient language for doing sophisticated database manipulation), you should write a script to produce a latex formatted report directly from the database (as Jukka suggested).

share|improve this answer
add comment

Latexdb is a great idea, but works only with MySQL.

I have written a clone, first in Ruby, recently in .Net (works with Mono, too), with some nice improvements. See http://www.hoens.net/robin/nlatexdb

share|improve this answer
add comment

You can load dynamic libraries into Luatex, like the Lua-SQL database bridge. I've never done this kind of thing, mind, but there are people here who would know how to do this.

You can invoke Lua from Tex with appropriate directive, such as from Lualatex, to pull and process data from the database bridge.

share|improve this answer
add comment

Check out Sweave and R

share|improve this answer
add comment

I'd write some script to extract the data in XML format (perhaps the database already offers that?) and process the file directly with ConTeXt. ConTeXt is well suited for a) reading XML input (directly) and b) for generating datasheets or alike. For example ConTeXt now offers \asciimode that makes most funny characters normal (&,#,~,$), so don't have to deal with escaping characters beyond % { } and \.

share|improve this answer
    
I made a simple xml database. (See here [link] tex.stackexchange.com/questions/45114/…). Is it possible to write a simple ConTeXt(LuaLaTex) or LuaLaTeX code for this xml to illustrate your answer? –  kornaros Feb 24 '12 at 14:45
1  
@kornaros you should ask a new question. –  topskip Feb 24 '12 at 16:04
add comment

Assuming each record has at most 9 fields, then one possibility would be to define a macro like

\newcommand\handlerecord[8]{...}

and then write a script as Jukka Suomela suggested that basically writes out the preamble and then a bunch of \handlerecord{field1}{field2}... and ends it off with an \end{document}.

If you have more than 9 fields, you can use any of the answers to this question to define the \handlerecord macro.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.