# Beamer Alt command working as Onslide

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}


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}


• 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