This question might be too general, but is something I thought about because I needed this in several different situations.

What I would like is to have a document of "problems" which I can solve. In general, this would be one page with a description of the problem, next the progress on the problem, some random thoughts and references.

Of course, I can just make a document with these sections and so on and so forth, but what if I decide say in a year that I actually want a different structure for my document? How I would do it is a save this as a file, say Super Cool Problem Bro.tex and then use in my main document \include{Super Cool Problem Bro.tex} in the page where I would like this.

So, maybe I have written all these files with my particular choices and I would like to do something simple like replace all the titles Literature with List of Relevant and Irrelevant Literature? This should be possible with some nice regex, but it does not feel like a good solution. What if I would like to add a section or switch the order?

So, I, naively, would make some kind of (flat file) database which has this data about my problems and then I would use a python script to generate my .texfiles from this according to my specifications. Right, but then I would be using python to generate the files and not LaTeX. Maybe there is some package or easy option which I am missing. It is also quite annoying to figure out after you are done there is a much easier option to go with. If you are doing research in mathematics this is quite common, but then the types of goals are different :-).

For the references at the bottom of each problem document I would be using chapterbib, which seems to be the right way to go (but of course, the stuff I describe above is what I am really wondering about).

Edit: Would "hacking" amsref be a good idea? They have bibliographies in the file itself which I could use as the "database". That could be remapped to an environment.

  • For collecting classified content in large quantities which you can then select, group and assemble into different documents, I think a database is indeed the best solution. For customising section titles and such, probably TeX macro names which can be configured by a document class or package are a better choice (analogously to the key words "Table of Contents" or "Abstract" used by LaTeX). Commented Jun 30, 2012 at 9:44
  • @StephanLehmke Excellent. Thanks. Then my question is just: what is the most efficient way to do this. Is there some LaTeX package that can grab data from a (certain) database?
    – JT_NL
    Commented Jun 30, 2012 at 9:56
  • Maybe the answers to this question can help? Is it possible to connect a database to LaTeX to produce data-driven documents? Commented Jun 30, 2012 at 12:29
  • @StephanLehmke Thanks. All these solutions are "too big", I mean, then it would be better to write a script that spits out these things. The problem is that I also want to compile these files through LaTeX to see how they look and, putting them in an XML file is not going to make that much easier. So perhaps the macro names can solve this. The problem is that I also might want to change the order... Good old copy pasting does the trick, but I'd like something more usable.
    – JT_NL
    Commented Jul 3, 2012 at 0:35
  • Writing a simple script from scratch which will spit out some LaTeX source is a perfectly good solution in my opinion. Every relevant programming language has some facilities for accessing databases, and generating the LaTeX code is mostly a matter of printing some text to a file. I doubt you'll be having much trouble with this. Commented Jul 3, 2012 at 6:32

1 Answer 1


The following is a simplified MWE of my syllabi generation method. I have about 40 subfiles with up to 100+ alternate paragraphs I put together for any individual syllabus. I chose this approach 1) I want to only use LaTeX (albeit, some TeX commands). 2) I wanted to separate content from format. 3) I wanted to be able to make very large formatting changes each year with having to reenter the content. And 4) I did not want to have more that one copy of any text, but especially those paragraphs in a syllabus which must be the same in all courses I teach.

In the MWE I have provided two files. The first is where you would have a separate copy of this file for each of the different 'problems'. The second is the file where you define the format for the presenting of that specific data.

Now each data file is as follows:

\long\def\parta{Content of part a.  Content of part a.  Content of part a.  Content of part a.}
\long\def\partb{Content of part b.  Content of part b.  Content of part b.  Content of part b.}
\long\def\partc{Content of part c.  Content of part c.  Content of part c.  Content of part c.}
\long\def\partd{Content of part d.  Content of part d.  Content of part d.  Content of part d.}
\endinput % the is so that I can use the area below for comments without their being input or included.

Tailor these different parts to contain the different information in the problems.
Personally in my academic syllabi I have about 100+ of these canned paragraphs of which I then choose the ones needed for a specific syllabus.

It is important to note that this is only content without any section or paragraph titles and minimal format information. What is important is that each part is what I consider 'atomic' (indivisible) content.
Usually these are the independent paragraphs (tables, lists, etc) of the syllabus (for me).

e.g. For my syllabi, I have a file for: 1) each academic year, 2) each semester, 3) my personal professional details, 4) my department policy for that year, 5) that years academic calendar 6) each course. And some additional files.

I do not call the individual definitions parta, partb ... But, I use clear descriptive titles. However, I abide bye the strict rule of "atomic" pieces.

These are the data files and with careful use of usually \input (which just loads the definitions) or occasionally \include (which starts new page) I can build other documents. Note: I deliberately use \long\def rather than \newcommand because I am treating this as data and not a parametric commands. (If you plan to have parameters for these files then you should use the \newcommand and \renewcommand structure.

And here is an example 'master' file.

First version of the document using data
\input{bigdocdata} %Just change the file name used here to use data from a different problem
\item[Cool Title] \textbf{\parta}
\item[Cooler Title] \textit{\partd}
\item[Coolest Title] \texttt{\tiny\partb}
Another document using the same data


And the compiled output is: enter image description here

  • Excellent. Wonderful! I will experiment a bit with this! :-).
    – JT_NL
    Commented Jul 14, 2012 at 19:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .