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.

In testing my answer to this question, I initially wrote the file

%& eplain
% code to answer question here
\bye

and compiled with pdftex e. Much to my surprise, the penultimate line of output was

Output written on e.dvi (1 page, 352 bytes).

If I change the first line to \input eplain or add the command line argument -output-format=pdf, then I get a pdf.

This same behavior can be observed by by starting a LaTeX file with %& latex and compiling with either pdflatex or pdftex so it's unrelated to eplain.

share|improve this question
2  
You are doing two different things. Using \input simply loads the relevant .tex file, whereas first-line parsing switches engine alias. Remember that almost all of the *tex execuatables are aliases for pdfTeX with the appropriate format. So the first line you are using effectively switch the command line to eplain. –  Joseph Wright Oct 15 '10 at 7:23
    
@Joseph Wright: I think your description is backward. The name of the executable is used as the name of the format. I didn't realize that there were different .fmt files for latex and pdflatex though. It doesn't really seem necessary to have them since one can choose the output format independently of the format file. –  TH. Oct 15 '10 at 12:43

1 Answer 1

up vote 7 down vote accepted

Well, because that is what it is supposed to do. the %& line allows you to switch to another format than the one matching the executable name, so your line above is exactly as running eplain e or pdftex -fmt eplain e. Read the first few lines of pdftex --help.

share|improve this answer
    
I did read that, actually. The relevant line reads, "If the first line of TEXNAME is %&FMT, and FMT is an existing .fmt file, use it." What I wasn't aware of is that the .fmt file dictates the output format since, as I said to Joseph, they can be selected independently. –  TH. Oct 15 '10 at 12:46
1  
The PDF output format has to be explicitly set on the format, or how else do you thing pdf(latex)tex would default to PDF, while latex defaults to dvi. I myself don't even like the different executable per format, this what command line switches are for, but this is not what TeX world is accustomed to. –  Khaled Hosny Oct 15 '10 at 13:50
    
@Khaled Hosny: If that were true, then -output-format=pdf would not work with explicit formats. For example, there is no pdfeplain.fmt, yet as I mentioned, I can get pdf files by passing the command line argument while using the eplain.fmt. –  TH. Oct 15 '10 at 17:38
    
@Khaled Hosny: In fact, just setting \pdfoutput=1 is sufficient to get pdf output. I had assumed (incorrectly) that that's essentially what pdftex would do by default I didn't expect the format files to be setting that at all. –  TH. Oct 15 '10 at 17:46
    
I think you are confusing things up (or may be I'm saying it in a confusing way), I'm not saying the only way to get PDF output is to set it in the format; I'm saying it is the only way to get it by default, this does not mean you can not override it by command line switches or TeX primitives. –  Khaled Hosny Oct 15 '10 at 18:50

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.