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.

Here is a hypothetical scenario. I want to make a beamer presentation and a handout for that presentation. I start my file as follows:

\newif\ifhandout
\handouttrue
\ifhandout
\PassOptionsToClass{handout}{beamer}
\fi
\documentclass{beamer}

\ifhandout
\usepackage{pgfpages}
\pgfpagesuselayout{4 on 1}[a4paper,landscape,border shrink=5mm]
\fi

Now, what I'd like to add to this conditional-fu is a command that tells LaTeX to compile to handout-\jobname.pdf if the relevant statement is true. Is this sort of thing possible, or can I only do this from the command line?

I've not added the beamer tag because this is not a question about beamer. I couldn't think of any other tags that this might fall under.

share|improve this question
    
1  
@Martin I don't think so. I'm not asking about beamer, I'm asking about whether something is possible from within the .tex file. And the answers to that question don't answer my question. Indeed, I answered that other question... So I don't think it's a duplicate. –  Seamus Mar 23 '11 at 18:34
    
I see. Thanks for clarifying that. –  Martin Scharrer Mar 23 '11 at 18:37
add comment

2 Answers

up vote 7 down vote accepted

Depending on your environment, you could try doing it the other way around: have presentation.tex and presentation-handout.tex, the latter being a symlink to the former, and inspect \jobname to decide. Or have a wrapper file for the handut that does a few \RequirePackages and \AtBeginDocuments, this depends a lot on how much you need.

share|improve this answer
    
Could you explain how the evaluating \jobname thing would work? –  Seamus Mar 23 '11 at 18:18
1  
@Seamus: This is exactly what I do for my lectures. I explain my method in my answer: tex.stackexchange.com/questions/5899/… (the code is actually in another answer, but it's linked from that answer). –  Andrew Stacey Mar 23 '11 at 18:45
add comment

You can't change the jobname from inside the document. (Ok, you could do some \write18 trickery to compile the document with a different compiler instance...)

The simplest thing to do would to create a wrapper file for the handout:

% handout.tex
\PassOptionsToClass{handout}{beamer}
\input{presenation}

Where presentation.tex is your presentation file. Then you get presentation.pdf and handout.pdf. Note that if you use these commands on the command line the jobname will be the one of the \input file. You would need to use -jobname to change that.

share|improve this answer
    
On the command line, you can tell pdflatex where to compile to, right? Why can't you do that from inside the file? –  Seamus Mar 23 '11 at 18:34
    
@Seamus: Because the file might already be open? The PDF file isn't opened in the preamble yet, but the log file is most likely. –  Martin Scharrer Mar 23 '11 at 18:36
    
@Martin well I don't care where the log gets written. As long as I put it before documentclass, there's every chance the PDF file hasn't been opened yet. –  Seamus Mar 23 '11 at 18:38
    
@Seamus: In my tests the PDF isn't open (i.e. the old one isn't overwritten) until the first page is flushed out. But TeX doesn't care about that and fixes the \jobname at the beginning. –  Martin Scharrer Mar 23 '11 at 18:41
2  
@Seamus I think it's more a security issue than a technical problem - allowing the document to choose where the output file is written could cause possible damage when compiling a malicious input file. –  diabonas Mar 23 '11 at 21:30
show 2 more comments

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.