Possible Duplicate:
How to influence the name of the pdf file created with pdfLaTeX (from within the source code)?
I have a template as follows.
% template.tex
\documentclass{article}
\usepackage{pstricks}
\SpecialCoor
\usepackage[active,tightpage]{preview}
\setlength\PreviewBorder{0pt}
\PreviewEnvironment{pspicture}
\begin{document}
\InputIfFileExists{\InputFileName}{%
% if it is compiled with latex.exe, it will produce DVI output with \InputFileName as its name.
% if it is compiled with pdflatex.exe or xelatex.exe, it will produce PDF output with \InputFileName as its name.
}{%
% notify error!
}
\end{document}
If I execute either TeXDviPsPdf.bat subfile or TeXPdf.bat subfile in the DOS prompt,
rem TeXDviPsPdf.bat takes a file name without extension
latex "\def\InputFileName{%1}\input{template}"
dvips %1.dvi
ps2pdf %1.ps
acrord32 %1.pdf
rem TeXPdf.bat takes a file name without extension
xelatex "\def\InputFileName{%1}\input{template}"
acrord32 %1.pdf
where the subfile.tex contains code as follows
% subfile.tex
\input{pstricks}
\begin{pspicture}(1,1)
\psframe(1,1)
\end{pspicture}
I will obtain subfile.pdf rather than template.pdf.
Is it possible to produce a DVI or PDF output with a name specified in the TeX input file?
Note: I can actually rename it in the batch files, but I want to know whether it is possible to be done internally.
\InputIfFileExists{\input{...}}{}? The command has three arguments and the first should be a file name. Please, correct the example. – egreg Jul 31 '11 at 19:44