# Polyglot TeX, Monoglot PDF

First, I do NOT want to write a document with multiple language in it. My goal is to have in a single TeX file in which I would write a section in say English and below the same section but translated in French. And when compiling, I could choose in which language to generate the PDF output.

Here is how I imagined it could have been implemented:

\documentclass{article}

\begin{document}

\begin{englishSection}
Hello world!
\end{englishSection}

\begin{frenchSection}
Bonjour le monde!
\end{frenchSection}

\end{document}


Which could generate either an output showing:

Hello world!

or another output showing:

Bonjour tout le monde!

This problem seems too obvious for me to not have a solution, but I could not find any. I would totally be fine with a solution as basic as having a variable in a file that is used to determine which part to compile. Or should I use complete other methodology? As my document will be mostly figures and very little text, I think it could be easier to keep formatting coherent by having both languages next to each other.

• You could create something based on the comment package. – Skillmon Jan 9 '18 at 21:02
• My suggestion (as long as only two languages are involved) is to usexifthen and to do switching with \ifthenelse{isEnglish}{Hello}{Bonjour}. – Oleg Lobachev Jan 9 '18 at 21:39
• \newif\ifusingfrench\usingfrenchfalse or \usingfrenchtrue. Then \ifusingfrench <French> \else <English>\fi and add british or american or french or whatever to the class call and load babel. – cfr Jan 10 '18 at 0:38
• Or you may consider the multiaudience package which is pretty flexible. – TeXnician Jan 10 '18 at 5:31
• @TeXnician Exactly what I wanted! I converted your comment into an answer. Also, do you know how to define the macro in texify parameters? I uses TeXworks and want to have one Typeset for each languages. I saw this line in the documentation: pdflatex -jobnane file-execs "\def\CurrentAudience{execs}\input{file}" but I couldn't make it work with texify – Puck Jan 10 '18 at 7:39

Thanks to TeXnician's comment, I could do what I wanted. Here is an example how to use multiaudience package to have multiple languages in same files:

\def\CurrentAudience{english}

\documentclass{article}

\usepackage[landscape]{geometry}
\usepackage{multiaudience}

\SetNewAudience{french}
\SetNewAudience{english}

\begin{document}
Common text for all languages

\begin{shownto}{french}
Bonjour tout le monde!
\end{shownto}

\begin{shownto}{english}
Hello world!
\end{shownto}

\end{document}


Where changing the first line to \def\CurrentAudience{french} set the compilation for French part.