Is there a way to automatically generate two different pdf files with one run of pdflatex?

I would like to produce a german and an english version of the same document. I know how to define a command acting as a switch (e.g. \germanenglish), which I could use like

\germanenglish{Deutscher Text}{english text}

Yet the best solution for now is defining a command in the preamble used to switch the switch. More convenient, however, would be a way of having latex produce


with one click.

  • Something like my answer here: tex.stackexchange.com/questions/258687/… ??? – user31729 Sep 15 '15 at 18:36
  • Of course, there are other answers as well, not only mine ... ;-) – user31729 Sep 15 '15 at 18:41
  • 4
    @ChristianHupfer -- of course two different pdf files can be generated from a single tex file, but, as far as i've seen, not at the same time, which is what is asked here. if "one run of pdflatex" could be considered to be what would be produced with two different arara directives specified at the top of the file, then yes, but that would actually be two separate runs of pdflatex, just done in one continuous "session". (nit picker at work.) – barbara beeton Sep 15 '15 at 19:08
  • Related: Polyglot note-keeping? – Mike Renfro Sep 15 '15 at 20:13

Thanks to the comments, I was able to solve the problem as follows:

\ProvidesPackage{altlang}[2015/09/20 Alternative Languages Package]





      \def\space{ }
      \immediate\write18{pdflatex --jobname=\myjobname\space \jobname.tex}



%% file myfile_de.tex



\lang{deutscher Text}{english text}

%% pdflatex-ing with shell-escape being enabled
%% will produce myfile_de.tex and myfile_en.tex

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.