Automated Document Creation and Typesetting with LaTeX

Creating a new document class file and then using this class is usually considered the “correct” way to typeset a form or other document generated with data in \LaTeX. However, there’s also the quick-and-dirty method of creating a regular \LaTeX document every time in a script using some sort of string concatenation and then typesetting this, which also has its merits. When a class file is used, the class describes the document look and structure; a new \LaTeX document still needs to be created each time to define the data. Not writing a class file and placing the document look and structure typesetting code directly in the generation script isn’t as clean as the class method as it mixes styling with data, but it does make some things easier. The quick-and-dirty approach doesn’t require knowing the additional \LaTeX language features needed for creating a class, using only what would use in a normal document. In particular, it is useful for automatically generating documents that change in structure based on the input data or other more complicated logic. This can obviously all be implemented as a \LaTeX class since \TeX is a Turing-complete language, but general purpose scripting languages such as Python are easier to use for this, particularly since most programmers use them much more often than they create complicated \LaTeX classes. The quick-and-dirty approach trades the class method’s cleaner design for ease of script creation. However, if the form will ever be created by hand, the class method is definitely superior.

This entry was posted in and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *