How to influence the name of the pdf file created with pdfLaTeX (from within the source code)?
I'm afraid you cannot alter the output name from within the LaTeX source: the \jobname
primitive can be read but not altered. You can arrange two-file solutions which allow one LaTeX file to 'call' another, but I am not sure that will answer your problem here.
You can specify additional parameters (like jobname
) at the very beginning of your main file (even before \documentclass
):
%& -job-name=newfilenameialwayswanted
It slightly depends on your compiler but it should work.
An additional comment: If you use an IDE, this may cause troubles for file opening hotkeys (the file they will try to open will not be there), in this case, you can look for an option like "output profile" (TeXnicCenter name) - you can also change the filename this way.
So there're no totally convenient ways to change your output filename from source, but it is possible.
You can do as follows.
\documentclass[preview,border=12pt]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{template.tex}
\documentclass[preview,border=12pt]{standalone}
\begin{document}
Hello World
\end{document}
\end{filecontents*}
\usepackage{pgffor,graphicx}
\foreach \outputfilename in {a,b,c}{\immediate\write18{pdflatex -jobname=\outputfilename\space template}}
\begin{document}
The files we created automatically are:
\foreach \outputfilename in {a,b,c}{\fbox{\includegraphics[scale=2]{\outputfilename}}\endgraf}
\end{document}