[Tex/LaTex] Changing \mode in beamer makes a new paragraph. Is it possible to avoid it

beamerbeamerarticle

I want to write different text in the middle of a sentence in a beamer presentation and its corresponding beamerarticle. But it seems that \mode<...>{...} introduces a new paragraph and breaks the sentence.

Please look at the code and results:

\documentclass[ignorenonframetext]{beamer}
%\documentclass{article}
%\usepackage{beamerarticle}
\begin{document}
\begin{frame}{This is a frame}

This is some text in \texttt{beamer} and \texttt{article} modes. 

This is some text in \mode<article>{\texttt{article}}\mode<beamer>{\texttt{beamer}} mode.
\end{frame}
\end{document}

This is the result in beamer mode. It looks like \mode<beamer>{text} introduces \par (or something similar) before and after text.

while \mode<article>{text} just introduces \par after text.
enter image description here

In any case I would like t have some mechanism to alternate text without introducing paragraph breaks. Is it possible?

Best Answer

Here's an alternative way to achieve the same end: replace your \mode with \only. I tend to think of \mode as something for Big Chunks and don't think I've ever used it within a frame. That's purely subjective, but based on the question it would appear that inadvertently stumbled on a Good Practice.

Overlay specifications as used by \only, \alt, and \temporal (amongst others) can include "output type" specifications. Quite often I'll do some complicated overlay stuff, for example I might want to iterate through approximations of \pi. In my presentation, I'd want something like:

\only<+>{3}
\only<+>{3.2}
\only<+>{3.14}

But in handout or trans mode, these all get processed and the overlay specification collapses so that they all appear. That isn't what I want. So I actually do:

\only<+|handout: 0|trans: 0>{3}

and so on. This suppresses the text completely in handout and trans modes.

In your example, you can make use of this facility and have:

\documentclass[ignorenonframetext]{beamer}
%\documentclass{article}
%\usepackage{beamerarticle}
\begin{document}
\begin{frame}{This is a frame}

This is some text in \texttt{beamer} and \texttt{article} modes. 

This is some text in
\only<article>{\texttt{article}}\only<beamer>{\texttt{beamer}} mode.
\end{frame}
\end{document}

This produces:

Output of example using only instead of mode