# Beamer/Beamerarticle: \mode<article> is ignored after <presentation> was set, and vice versa

I have a problem with latex ignoring text after \mode<presentation> or \mode<article> was set.

## MWE description

I have a large document that changes modes often, and I also \include some more latex files. I've reduced it to the following MWE.

\documentclass{article}
\usepackage{beamerarticle}

%\documentclass{beamer}

\begin{document}

1. Text without a mode being set. This should be shown
in both presentation and article mode.

\mode
<presentation>
\begin{frame}
2. This is text inside a frame. It should only appear in presentation
\end{frame}

\mode
<article>
3. Text outside a frame. Only in article.

\mode
<all>
\include{in}

\end{document}


With the file in.tex closely following the example in the beamer user guide ver. 3.26, p. 210

\mode*
4. This is some text outside a frame. Shouldn't be shown in presentation mode.

\begin{frame}
5. This is text inside a frame. This is expected to show in article mode.
\end{frame}

\mode<all>


## Problem description

There are two cases to be considered here, compiling with \documentclass{beamer}, or with \documentclass{article} and \usepackage{beamerarticle}.

As I understand the relevant documentation, I should get the results as described in the body of the MWE. Instead, I get the following:

• Case "article"

• Everything after \mode<presentation> seems to be ignored. I get a single page with sentence 1. Switching back to \mode<article> does not produce sentence 3, and the \include command does not seem to be processed.
• Case "beamer"

• Sentence 1. and 2. get typest, the included file is ignored, even though it should be processed in all modes.

Experimentation with the third flavour of the mode command and ignorenonframetext has yielded the same results, please see the output here and here (can't include directly due to lack of reputation). I am using the second mode flavour for \include to work, and because I need to do fancy things like set backgrounds on some slides.

## Question

What am I missing here? As far as I can tell I have structured the document correctly. Am I misunderstanding how modes are set and processed? Is this a bug in beamer or beamerarticle? I would like to achieve the result as described in the MWE.

I am compiling this document on Arch Linux with texlive 2012, which at the moment represents rev. 28273.

-
Do you have those spaces at the start of the line before \mode in your document? As the manual says, the line has to consist of \mode or \mode* alone for 'change mode' command to work. Also, I think you want \input not \include. –  Joseph Wright Feb 7 '13 at 9:23
@JosephWright My guess is that \include will be needed for a more complex document e.g. because article mode ignores \includeonlylecture. –  fheub Feb 7 '13 at 9:43
@JosephWright Thank you! That was exactly what was wrong with it. I've re-read that section of the manual probably 10 times and saw the remark about how not even a comment was allowed, but that whitespace would also screw it up never even crossed my mind. If you want to convert your comment to an answer, I'll happily accept it, otherwise I'll just type it up myself. @fheub I do actually have \input in my main document, so that I can \include further stuff from there. That just got lost somewhere in creating the MWE and cross-checking with the userguide, where they use \include. –  halcyon Feb 7 '13 at 10:09

When using the \mode command in the 'ongoing' sense (without a braced argument), the command has to be on a line on its own with no comments or whitespace. This is becuase the line needs to be compared 'verbatim-like' with the check value. Thus

Some text
\mode
<all>


will work but

Some text
\mode
<all>


will fail. (\mode* is also allowed, but again with nothing else on the line.) The example in the question works correctly if the whitespace is tidied up.

-