# Can/Should I use '\jobname' to pass information from outside LaTeX?

I'm creating a parameterized document.

I want to pass a string into the document from outside at 'compile time'. In particular: a comma-separated list. This list will then be used by LaTeX to resolve internal conditionals. So, depending on the list, some parts of the document will be included and others will not.

Preferably, I'd like to pass the list as a simple command line parameter. My first thought would be to use the -jobname parameter and retrieve the info from the \jobname macro:

> pdflatex input.tex -jobname "a, b, e, g"


Is this an acceptable solution? Could it break anything? Are there perhaps popular packages out there that require \jobname to contain the input filename?

Or to generalize my question: how would you pass such information into the document?

• Great question, would like to see an answer (currently I'm using the Mako engine to generate LaTeX with custom values). – m0nhawk Dec 17 '12 at 14:38
• I guess if I make the assumption that the user (which may not be me) has Python, that opens up a world of nice solutions. :-) – mhelvens Dec 17 '12 at 14:48
• I usually make use of a template engine when I have to generate a .tex document from a datasource. I wrote a humble post in our community blog about merging data and structure, hope it can be of service. :) – Paulo Cereda Dec 17 '12 at 15:28
• @PauloCereda Looks interesting! But any actual template engine would be overkill for what I have in mind. – mhelvens Dec 17 '12 at 15:46

This will most likely break everything, \jobname is used for all kinds of things like aux files and having commas and spaces in file names is tricky. Just use
  pdflatex \def\mycommand{a,b,c}\input myfile

possibly needing to quote the \ or {} depending on your commandline processor.