5

I have a beamer presentation of which I have two language versions (german and english), more languages are upcoming. I keep both versions in one source and select the one to typeset with the comment package. But this gives me only a presentation with one language.

Can I create a presentation with multiple languages that allows me to switch between them on the fly (either per presentation or per slide)?

Martin Scharrer
  • 262,582

1 Answers1

4

Beamer supports an appendix with optional slides which can be jumped to using navigation items. You might have all slides of the default language first, then and end slide (maybe blank) and then as an appendix all slides of the second language. You could add navigation buttons from every slide to its translated slide and vice-versa, which allows you to jump between them easily. Also if you want to have the whole presentation in the second language simply start from the first slide of the appendix. This should also work in principle with more than two languages, but with increased complexity.

Note that you also can jump from one PDF to another one. So you could have two PDFs and add hyperlinks to the same page of the other PDF. See in the hyperref manual the section about \href[page=..]. The zref-abspos package provides you with the required absolute page number. You also need to choice the correct view for the link (fullscreen).

I made the following proof-of-concept file which works fine for me. I can jump to the translated version of the current slide, both in normal and fullscreen mode. This uses two PDFs.

% presentation-en.tex
% the main file
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english,ngerman]{babel}

\usepackage{comment}
\ifdefined\GERMAN
% Exchange for German version
\includecomment{german}
\excludecomment{english}
\else
\excludecomment{german}
\includecomment{english}
\fi

\makeatletter
\makeatother

% Needs: etc.
% \setlanguage{...}

\setbeamertemplate{navigation symbols}{\langnav}

\begin{german}
\newcommand{\langnav}{%
    \href[page=\value{page}]{presentation-en}{{\tiny EN}}
}
\selectlanguage{ngerman}
\end{german}
\begin{english}
\newcommand{\langnav}{%
    \href[page=\value{page}]{presentation-de}{{\tiny DE}}
}
\selectlanguage{english}
\end{english}


\begin{document}

\begin{german}
\begin{frame}{Apfelbäume}
   Diese Präsentation ist über Apfelbäume.

\end{frame}
\end{german}

\begin{english}
\begin{frame}{Apple trees}
    This presentation is about apple trees.

\end{frame}
\end{english}

\begin{german}
\begin{frame}{Äpfel sind lecker}
    Sehr sehr lecker!
   \only<2>{Man kann es gar nicht glauben!}

\end{frame}
\end{german}

\begin{english}
\begin{frame}{Apples are tasty!}
   So tasty!
   \only<2>{Can you believe it!}

\end{frame}
\end{english}

\end{document}
% presentation-de.tex
\def\GERMAN{}
\input{presentation-en}
Martin Scharrer
  • 262,582
  • That's nice, but it basically gives me both presentations concatenated (or in two PDFs). Can I get them on different "layers"? The problem I see with two files or two sections is that the source for the multiple versions of one frame get separated. I want to keep all versions of one slide together in the source. – Martin Schröder Jul 27 '11 at 13:14
  • No, different layers are not supported by PDF I think. You could maybe interleave the slides and make them jump over the following one by default. I would do it as shown in my updated answer, but maybe place the language environments inside the frame. You need to declare them [fragile] then I think, because comment uses verbatim mode. – Martin Scharrer Jul 27 '11 at 13:24
  • PDF can do layers; tikz can create them (view the microtype docu with Adobe). – Martin Schröder Jul 27 '11 at 13:30
  • @Martin Schroder: the layers that TikZ does are not (as far as I'm aware) anything to do with layers in PDF. The layering system in TikZ is done by stacking TeX-boxes and so is done before the stuff is written out to the PDF. – Andrew Stacey Jul 27 '11 at 13:33
  • @MartinSchröder: Interesting! I know about different graphical layers with TikZ, but didn't know that they can be dynamically changed in the PDF. – Martin Scharrer Jul 27 '11 at 13:34
  • @andrew: The microtype documentation proves you're wrong. :-) – Martin Schröder Jul 27 '11 at 13:46
  • @MartinSchröder: It proofs that normal TikZ layers are the same as dynamic PDF layers? Where? Can you please be more specific. The microtype manual doesn't even include the word 'layer'. I assume you mean the logo on the titlepage which changes dynamically when you move and click with the mouse on it. I found that by pure chance! I can't find the implementation for it in the DTX file. – Martin Scharrer Jul 27 '11 at 13:53
  • @MartinScharrer: I have to correct myself: It seems microtype does the layers itself (see the code for \mt@layer etc). That's a pity - I thought that there would be a package for LaTeX for this by now. ConTeXt can probably do what I want here since 2007. :-) – Martin Schröder Jul 27 '11 at 14:02
  • 1
    @MartinSchroder: Er ... the jury's out on that. I'd need to see the source of that documentation. Compiling the documentation from the package does not use TikZ/PGF, but then it doesn't produce any diagrams either. However, looking at the source of that document shows that it does have layers and these are implemented by a series of \pdfliteral commands. Search in microtype.dtx for the command \mt@layer. So I don't think that the PDF layers in the microtype documentation are done by TikZ. – Andrew Stacey Jul 27 '11 at 14:06
  • 1
    @Martin (good grief this is confusing! Can one of you please change your name?) The \mt@layer command looks fairly simple and I'm sure it could easily be modified to be used with TikZ. However, I just searched and was having a hard time finding a PDF viewer that could handle these layers, and also it wasn't clear what the point of them was. – Andrew Stacey Jul 27 '11 at 14:08
  • @Andrew: (none of us will rename ourself). AFAIK layers only work with Adobe software. Their use is the selective display of information. – Martin Schröder Jul 27 '11 at 14:10
  • @MartinScrhoder: (In that case, I'll rename myself to Martin to avoid confusion.) Right, so that probably explains the lack of a package to handle it. I'd take a look at the microtype implementation and hack it to do what you want. Shouldn't be too hard! – Andrew Stacey Jul 27 '11 at 14:15
  • @MartinSchröder: I fail to see the true benefit of such layers in that application. Simply define some \german{..} and \english{..} macros and compile the document twice into two different PDFs with the mentioned cross-hyperlinks. This allows to keep the source together and easily jump from one to the other. There won't be any less macros used inside the frames when you do this with layers. – Martin Scharrer Jul 27 '11 at 14:18
  • @Andrew: Thinking about it the animate package seems to use such layers. – Martin Scharrer Jul 27 '11 at 14:34