LaTeX forum ⇒ GeneralMultiple 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

Postby Keta » Mon Jul 06, 2009 11:02 pm

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

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm

Multiple documents from one source

Postby Keta » Tue Jul 07, 2009 9:49 pm

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 :mrgreen: ).

\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

Postby Keta » Sat Jul 11, 2009 11:59 am

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.


Return to “General”

Who is online

Users browsing this forum: No registered users and 8 guests