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 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?

share|improve this question
    
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
add comment

1 Answer

up vote 16 down vote accepted

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.

share|improve this answer
    
Thanks, that's pretty clear. :-) <>---<> Although your proposed solution looks a bit... messy. Not nice for a tool demo. I suppose I could just write a simple script that accepts a clean parameter, but that's also not ideal. –  mhelvens Dec 17 '12 at 14:46
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.