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

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

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

  1. \newif\iffr
  2. \newif\ifen
  3.  
  4. \entrue
  5.  
  6. \documentclass{article}
  7.  
  8. \usepackage[T1]{fontenc}
  9. \usepackage[utf8]{inputenc}
  10.  
  11. \usepackage[french,english]{babel}
  12.  
  13. \newcommand{\langfr}[1]{%
  14. \iffr\selectlanguage{french}#1\fi}
  15. \newcommand{\langen}[1]{%
  16. \ifen\selectlanguage{english}#1\fi}
  17.  
  18. \begin{document}
  19.  
  20. \section{%
  21. \langfr{Bonjour!}
  22. \langen{Hello!}}
  23.  
  24. \langfr{Ce texte est en français.\\
  25. Règles typographiques françaises \textit{devraient} s'appliquer.}
  26. \langen{This is text in English.\\
  27. English typographic rules \textit{should} apply.}
  28.  
  29. \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

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:

  1. #!/bin/bash
  2. cd ~/TeXs/Temp # This is the directory where the file is.
  3. pdflatex -jobname=script-fr -interaction=nonstopmode "\newif\iffr\newif\ifen\frtrue \input{temp}"
  4. 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 6 guests