2

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

  • 3
    You do pdflatex \def\filename{abc}\input{texfile} – Ulrike Fischer Jul 16 '12 at 13:52
2

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.

|improve this answer|||||
0

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.