GeneralChanging the output file name

LaTeX specific issues not fitting into one of the other forums of this category.
dmt
Posts: 82
Joined: Sat Mar 15, 2008 8:13 pm

Changing the output file name

Post by dmt »

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

Post by localghost »

You could build your final output with a special command line argument for (pdf)latex.

Code: Select all

pdflatex -job-name=name
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¹
dmt
Posts: 82
Joined: Sat Mar 15, 2008 8:13 pm

Re: Changing the output file name

Post by dmt »

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.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Changing the output file name

Post by localghost »

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.
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

Changing the output file name

Post by T3. »

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

Code: Select all

%& -job-name=somename
Cheers,

Tomek
dmt
Posts: 82
Joined: Sat Mar 15, 2008 8:13 pm

Re: Changing the output file name

Post by dmt »

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?
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

Changing the output file name

Post by T3. »

Only the first line is searched for additional switches and only if it starts with

Code: Select all

%&
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.
Can you post some code (like minimal example)? I don't see why this would be a problem.

Cheers,

Tomek
dmt
Posts: 82
Joined: Sat Mar 15, 2008 8:13 pm

Re: Changing the output file name

Post by dmt »

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.
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

Re: Changing the output file name

Post by T3. »

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
dmt
Posts: 82
Joined: Sat Mar 15, 2008 8:13 pm

Re: Changing the output file name

Post by dmt »

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