# Multiple PDF generation with one tex file

I'm writing my cv using moderncv, and I want to make it in 2 languages. I wrote a common part, which both languages will have, and specific ones, where I put the translated content. I also want to make 2 versions: one with contact information, and another without it.

In short: I want my cv in 4 versions: 2 languages, each one with and without contact information.

I looked for an automated way to do that, just for fun. The ideal answer would be a single main .tex file producing all the 4 versions. I found 2 answers here in tex.sx, this and this, where I think my ideal can be made combining both.

My main.tex have this code now

\ifx\conditionmacro\undefined
\immediate\protect\write18{%
pdflatex --jobname="cv-pt" "\includeonly{pt/personal,pt/contact,pt/content}\input{main}"
}%
\immediate\protect\write18{%
pdflatex --jobname="cv-pt-web" "\includeonly{pt/personal,pt/omitted,pt/content}\input{main}"
}%
\immediate\protect\write18{%
pdflatex --jobname="cv-en" "\includeonly{en/personal,en/contact,en/content}\input{main}"
}%
\immediate\protect\write18{%
pdflatex --jobname="cv-en-web" "\includeonly{en/personal,en/omitted,en/content}\input{main}"
}%
\expandafter\stop
\fi

\input{personal}

\include{pt/contact}
\include{pt/omitted}

\include{en/contact}
\include{en/omitted}

\begin{document}

\makecvtitle

\include{pt/content}
\include{en/content}

\end{document}


I could get this working only once without knowing how. I wish someone here can help me doing it.

I really really really don't want to use a Makefile or shell script to do this. =)

Thanks!

-
Are you sure you do not want to use a Makefile. Maybe try this: bitbucket.org/michipili/bsdmakepscripts/wiki/… and look for “Several documents in the same directory”. –  user40989 Feb 24 '14 at 8:13
possible duplicate of Can one TeX file output to multiple PDF files? –  g.rocket Oct 12 '14 at 22:35
@g.rocket: I used as reference, but its problem is different, so it's not a duplicate. –  paulochf Oct 12 '14 at 23:05

This way should work:

\documentclass{moderncv}

% other stuff here

\ifx\conditionmacro\undefined
\immediate\write18{%
pdflatex --jobname="cv-pt" "\gdef\string\conditionmacro{1}\string\input\space\jobname"
}%
\immediate\write18{%
pdflatex --jobname="cv-pt-web" "\gdef\string\conditionmacro{2}\string\input\space\jobname"
}%
\immediate\write18{%
pdflatex --jobname="cv-en" "\gdef\string\conditionmacro{3}\string\input\space\jobname"
}%
\immediate\write18{%
pdflatex --jobname="cv-en-web" "\gdef\string\conditionmacro{4}\string\input\space\jobname"
}%
\expandafter\stop
\fi

\ifnum\conditionmacro=1 \includeonly{pt/personal,pt/contact,pt/content}\fi
\ifnum\conditionmacro=2 \includeonly{pt/personal,pt/omitted,pt/content}\fi
\ifnum\conditionmacro=3 \includeonly{en/personal,en/contact,en/content}\fi
\ifnum\conditionmacro=4 \includeonly{en/personal,en/omitted,en/content}\fi

\begin{document}

\makecvtitle

\include{pt/personal}
\include{pt/contact}
\include{pt/omitted}
\include{pt/content}

\include{en/personal}
\include{en/contact}
\include{en/omitted}
\include{en/content}

\end{document}

-
Worked! Can't forget to mention the whitespace/newline after \conditionmacro=X. –  paulochf Feb 24 '14 at 17:06