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 need to be able to change the value of a parameter inside a LaTeX document without having to change it manually. I'll explain:

There is one main program that executes another smaller one. This smaller program computes some things and creates a .txt-file with a specific name and all its results inside. Then the main program executes the LaTeX file I have to create which will process the created .txt-file into a nice pdf (using commands such as \openin\txtfile=\filename.txt and the package datatool).
Problem is that LaTeX needs to know the name of the newly created .txt-file. The main program knows the name it and will call the LaTeX file by using the cmd command > latex texfile.tex. But this won't change the value of \filename in any way.

Is there actually any possible way to change a value (of \filename) inside the LaTeX file using the cmd? Because I have absolutely no clue and Google doesn't help me either...

share|improve this question
3  
You do pdflatex \def\filename{abc}\input{texfile} –  Ulrike Fischer Jul 16 '12 at 13:52
    
Thanks will try it :) –  Didii Jul 16 '12 at 15:17
add comment

2 Answers

up vote 2 down vote accepted

Thanks to Ulrike Fischer for the solution:

> pdflatex \cmd\input{texfile}

\cmd can be any command LaTeX recognizes. And input{texfile} pastes all contents of texfile.tex into the cmd.

share|improve this answer
add comment

Potentially you might want to change the jobname

latex -jobname=$filename texfile.tex

where $filename is the name of your .txt file. Then inside your .tex file you could use

\openin\txtfile=\jobname

This approach would change the name of the final output and all auxiliary files from texfile.* to $filename.*, which may or may not be desirable.

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.