## LaTeX forum ⇒ General ⇒ Multiple documents from one source

LaTeX specific issues not fitting into one of the other forums of this category.
Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm

### Multiple documents from one source

Hi all,

I'm doing my CV in three languages. The idea is to have a single tex file with all info, each language properly separated by a command, e.g \fr{info in French}\en{info in English}. Then, a shell script would process the file three times, each time with the proper \frtrue command or so. I hope I'm clear enough.

Is this possible? How could I pass the \frtrue from command line? If there's a better approach for this job, please tell me how to do it. Thanks!

Keta

LaTeXguide.org • LaTeX-Cookbook.net

Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm

### Multiple documents from one source

OK, here's a first try, looks like it works correctly. Sorry if the French part is incorrect, I just used a web translator (sorry BTW if the English text is incorrect in first place ).

\newif\iffr
\newif\ifen

\entrue

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[french,english]{babel}

\newcommand{\langfr}[1]{%
\iffr\selectlanguage{french}#1\fi}
\newcommand{\langen}[1]{%
\ifen\selectlanguage{english}#1\fi}

\begin{document}

\section{%
\langfr{Bonjour!}
\langen{Hello!}}

\langfr{Ce texte est en français.\\
Règles typographiques françaises \textit{devraient} s'appliquer.}
\langen{This is text in English.\\
English typographic rules \textit{should} apply.}

\end{document}

This should typeset the English text. Changing \entrue with \frtrue would show the French part.

The idea is to have from \documentclass... downwards in a tex file, and the previous commands would be introduced by the shell script. How can this be done?

Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm

### Multiple documents from one source

I finally found a solution. By trial and error, I managed to find that commands can be passed between quotes. So for the previous example, calling the tex file temp.tex, the following script would create the 2 pdf:

#!/bin/bash
cd ~/TeXs/Temp # This is the directory where the file is.
pdflatex -jobname=script-fr -interaction=nonstopmode "\newif\iffr\newif\ifen\frtrue \input{temp}"
pdflatex -jobname=script-en -interaction=nonstopmode "\newif\iffr\newif\ifen\entrue \input{temp}"

Definitely not very elegant, but it works. I put it here, in case somebody else needs it.