# Cleanest way to prepare bilingual document and output only one language [duplicate]

I am currently preparing the presentation for my internship evaluation. As a French student evaluated by researchers that may or may not speak French, I would like to maintain two versions of my presentation, in French and in English.

I could just create two separate files but I am pretty sure that maintaining both of them would be complicated and that I would most likely forget to port corrections from any version to the other one as well. Thus, my preferred option would be to keep them in the same file (files, in fact: I have taken the habit of having separate files for each section of my documents and \include them all in at the end).

Here is a MWE showing how I managed to do it :

\documentclass{beamer}

\usepackage[T1]{fontenc}
\usepackage[english, french]{babel}
\usepackage{etoolbox}
\usepackage{blindtext}

%\includeonlylecture{english}
%\includeonlylecture{french}

\newcommand{\switch}[1]{%Use with "french" or "english" to switch between languages
%Security check
\ifstrequal{#1}{french}%
{}%
{\ifstrequal{#1}{english}%
{}%
}
\lecture{#1}{#1}
\selectlanguage{#1}
\ifstrequal{#1}{french}%
{%
\title{French title}
}%
{\ifstrequal{#1}{english}%
{%
\title{English title}
}%
{}%
}
}

\begin{document}

\switch{english}
\begin{frame}
\titlepage
\end{frame}

\switch{french}
\begin{frame}
\titlepage
\end{frame}

\switch{english}
\begin{frame}{English frame}
\blindtext
\end{frame}

\switch{french}
\begin{frame}{French frame}
\blindtext
\end{frame}

\end{document}


By using \switch with english or french and selecting the desired output language with \includeonlylecture, I managed to only output the corresponding half of the document.

I felt the need to redefine the title at each switch because the theme I use, JuanLesPins, shows the last title specified at the top of each slide.

My question is: is there a cleaner way to do what I'm trying to do, i.e. preparing two consecutive versions of each slide in two different languages and only output one of them?

## marked as duplicate by Martin Schröder, user13907, Maarten Dhondt, Andrew Swann, JesseJul 1 '15 at 13:49

• +1 for keeping all the content in both languages in one file – meduz Jun 30 '15 at 22:15
• @MartinSchröder It is indeed a duplicate, thanks. Nevertheless, I'd like to point out that touhami's answer is more complete as it gives two solutions and linked me to another answer that solved the problem with french accentuation when using the comment package. – Anab Jul 1 '15 at 11:46

It's very easy with comment package

\documentclass{beamer}
\usepackage{comment}

% for english
\includecomment{english}
\excludecomment{french}
%  for french
%\includecomment{french}
%\excludecomment{english}

\begin{french}
\usepackage[french]{babel}
\end{french}

\usepackage{blindtext}

\begin{french}
\title{Titre}
\author{Moi}
\end{french}

\begin{english}
\title{Title}
\author{Me}
\end{english}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\begin{frame}
\tableofcontents
\end{frame}

\begin{french}
\section{Bon}
\subsection{jour}

\begin{frame}{French frame}
\blindtext
\end{frame}
\end{french}

\begin{english}

\section{Hellow}
\subsection{world}

\begin{frame}{English frame}
\blindtext
\end{frame}
\end{english}

\end{document}


Here is the first solution Edited to fill the comment below

\documentclass{beamer}

\newif\iffrenchb

% uncomment next line for french
%\frenchbtrue

\newcommand{\iffrench}[2]{\iffrenchb #1\else #2\fi}
\newsavebox\efframe

\iffrench{
\usepackage[frenchb]{babel}
}{
\usepackage[english]{babel}
}

\usepackage{blindtext}

\iffrench{
\newenvironment{french}{\begin{frame}}{\end{frame}}
\newenvironment{english}{\begin{lrbox}{\efframe}}{\end{lrbox}}
}{
\newenvironment{english}{\begin{frame}}{\end{frame}}
\newenvironment{french}{\begin{lrbox}{\efframe}}{\end{lrbox}}
}

\iffrench{
\title{Titre}
\author{Moi}
}{
\title{Title}
\author{Me}
}
\begin{document}

\begin{frame}
\titlepage
\end{frame}

\begin{frame}
\tableofcontents
\end{frame}

\iffrench{
\section{Bon}
\subsection{jour}
}{
\section{Hellow}
\subsection{world}
}

\begin{french}
{French frame}
\blindtext
\end{french}

\begin{english}
{English frame}
\blindtext
\end{english}

\begin{french}
{French frame}
\blindtext
\end{french}

\begin{english}
{English frame}
\blindtext
\end{english}

\end{document}

• Thanks, but I see two problems with your solution: first, it does not set the default language (for example, your blind text is always the French one, even if french is not set to true) and it also does not handle well sections with the theme I use, JuanLesPins: I have to declare new sections inside the French/English frames and their names only appear at the slide after which they were declared. – Anab Jun 26 '15 at 11:55
• @Anab answer edited. – touhami Jun 27 '15 at 12:31
• @Anab another solution that use comment package – touhami Jun 27 '15 at 23:41
• I really like both of your solutions. However, I ran in a small issue with the first one: it seems not to handle accentuation. I have some occurrences of "é" in my French slides and the first one returns Package inputenc Error: Unicode char \u8:éme not set up for use with LaTeX. I use \usepackage[utf8]{inputenc} in my preamble to handle compatibility between the Mac and Windows I use and my documents are encoded in utf-8. – Anab Jun 29 '15 at 15:26
• Of course you need to load all packages necessary, as normal way. – touhami Jun 29 '15 at 15:55