General ⇒ Changing the output file name
Changing the output file name
Is there a command I can put in the .tex file that will specify the output file name when making a pdf file? (I'm using LEd and MikTex on Windows if that matters).
I'm making an exam with the exam class, and have it set up to make two version by just changing one line, one with answers, and one without answers. However, it's sort of a pain right now since they both write to the same file name, so I have to do one, then rename the file by hand then make the next one. It would be very convenient if there was a way to automate this (the exam class has a nice conditional command for when answers are printed that I could use if there was a rename output command).
I'm making an exam with the exam class, and have it set up to make two version by just changing one line, one with answers, and one without answers. However, it's sort of a pain right now since they both write to the same file name, so I have to do one, then rename the file by hand then make the next one. It would be very convenient if there was a way to automate this (the exam class has a nice conditional command for when answers are printed that I could use if there was a rename output command).
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Changing the output file name
You could build your final output with a special command line argument for (pdf)latex.
For further information have a look at the documentation for pdfTeX on the MiKTeX documentation page [1].
I'm not familiar with LEd. Perhaps it offers to create an own build profile similar to TeXnicCenter.
[1] pdftex
Best regards
Thorsten¹
Code: Select all
pdflatex -job-name=name
I'm not familiar with LEd. Perhaps it offers to create an own build profile similar to TeXnicCenter.
[1] pdftex
Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Changing the output file name
I just press a button on LEd to generate the pdf ... I don't deal with command lines at all. If that is the only way to do it then it is probably easier to just keep renaming the file.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Changing the output file name
I guess somewhere in the Configuration menu there will be the possibility to create such an additional button with this special call of the compiler. Perhaps the Help function in the program itself or the Support area on the homepage has some information about that.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Changing the output file name
If you don't like the command line approach, you can use the very first line of your master document to pass additional switches to latex:dmt wrote:I just press a button on LEd to generate the pdf ... I don't deal with command lines at all. If that is the only way to do it then it is probably easier to just keep renaming the file.
Code: Select all
%& -job-name=somename
Tomek
Re: Changing the output file name
Cool, that almost works. The problem is if I have to put that in the first line I don't have access to the conditional statement from the exam class.
If I put an extra % in front of the that line will it be ignored?
If I put an extra % in front of the that line will it be ignored?
Changing the output file name
Only the first line is searched for additional switches and only if it starts with
Cheers,
Tomek
Code: Select all
%&
Can you post some code (like minimal example)? I don't see why this would be a problem.dmt wrote:The problem is if I have to put that in the first line I don't have access to the conditional statement from the exam class.
Cheers,
Tomek
Re: Changing the output file name
Really? I haven't tried it, but i just assumed I couldn't use a conditional statement defined in the exam class before I even declared which class I was using ... I'll give it a try and see what happens. I have been just adding an extra % for now.
---
Yeah, it didn't work .... doesn't matter so much it's not a big deal to just comment or uncomment the first two lines depending on which version I'm running. Thanks.
---
Yeah, it didn't work .... doesn't matter so much it's not a big deal to just comment or uncomment the first two lines depending on which version I'm running. Thanks.
Re: Changing the output file name
I'm afraid I don't understand what's the problem. The first line with switches is treated as a regular comment during typesetting. How does that interfere with conditionals? Could you provide some more details? Perhaps there is another way to accomplish what you want.
Cheers,
Tomek
Cheers,
Tomek
Re: Changing the output file name
I meant I wanted to put that first inside a conditional statement itself, so that whether or not it executes i dependent on another setting. This would mean only uncommenting one line to switch "states". It's not a big deal to uncomment two lines instead though.