2

I try to have command working as \alt but with the behaviour of \onslide, I mean that doesn't move things around when appears.

I try the following solution, but at some point, there is a sliding from one line to the next. On my example, there is enough room for the word zeros but not for \dots.

Any idea to achieve that ?

\documentclass{beamer}

\newcommand{\Alt}[2][\dots]{\only<.-.>{#1}\onslide<+->{{#2}}}

\begin{document}
\begin{frame}[t]
\begin{enumerate}[<+->]

\item Ne pas oublier qu'un décimal peut s'écrire avec des
    \alt<+->{zéros inutiles si besoin.}{\dots}

\item Ne pas oublier qu'un décimal peut s'écrire avec des
    \Alt{zéros inutiles si besoin.}

\item Ne pas x x x oublier qu'un décimal peut s'écrire avec des
    \Alt{zéros inutiles si besoin.}

\end{enumerate}

Must not move.

\end{frame}
\end{document}

enter image description here

Tarass
  • 16,912
  • See: https://tex.stackexchange.com/questions/13793/beamer-alt-command-like-visible-instead-of-like-only – PatrickT Feb 02 '22 at 17:12

1 Answers1

3

To avoid the problem with shrinking and stretching inter-word spaces, you could use \RaggedRight and to prevent the linebreak in front of the dots, try \nolinebreak

\documentclass{beamer}
\usepackage{ragged2e}

\begin{document}
\begin{frame}[t]
\begin{enumerate}[<+->]
\RaggedRight

\item Ne pas x xxx x oublier qu'un décimal peut s'écrire avec des
\only<.>{\nolinebreak\dots }\visible<+->{zéros inutiles si besoin.}

\end{enumerate}

Must not move.

\end{frame}
\end{document}

enter image description here

  • The first slide is not a problem, as I have found asolution at the second, but this solution as an issue as you can see on the third slide. In termes of room, onslide, uncover and visible work the same: visible doesn't solve the problem on third slide. thank you. – Tarass Sep 30 '17 at 15:59
  • @Tarass now I see what your problem is. Can you test my edited answer? – samcarter_is_at_topanswers.xyz Sep 30 '17 at 16:33
  • \RaggedRight is a problem because it cuts words, and I prefer not in a presentation. Even so, des moves now from one line the other. I excpect better ;-) Thank you for the lead \nolinebreak, I'll try in this direction. – Tarass Sep 30 '17 at 16:55
  • \nolinebreak\dots{} with a space at the end works fine. Add it in your answer. As you have found the clue of \nolinebreack. – Tarass Sep 30 '17 at 16:58
  • @Tarass I added the space to my answer (it does not make any difference for me) – samcarter_is_at_topanswers.xyz Sep 30 '17 at 17:38
  • It will If you don't use raggedright. I prefer not to use it. Btw add also {} otherwise the space it eaten. – Tarass Sep 30 '17 at 18:19
  • \newcommand{\Alt}[2][\nolinebreak\dots\xspace]{\only<.>{#1}\onslide<+->{{#2}}} works just fine. – Tarass Sep 30 '17 at 18:46