TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to swap code blocks as animation. But I cannot put verbatim inside \onslide or \visible.

I tried using a savebox, the problem is the second code blockis typesetted below the first one. I want the code blocks to show in same location.

My code:




\begin{Verbatim}[frame=single, fontsize=\fontsize{7pt}{8pt}\selectfont]
class int(object)
 |  int(x[, base]) -> integer
 |  Convert a string or number to an integer, if possible.  A floating point
 |  argument will be truncated towards zero (this does not include a string
 |  representation of a floating point number!)  When converting a string, use
 |  the optional base.  It is an error to supply a base when converting a
 |  non-string.  If base is zero, the proper base is guessed based on the
 |  string content.  If the argument is outside the integer range a
 |  long object will be returned instead.
\begin{Verbatim}[frame=single, fontsize=\fontsize{7pt}{8pt}\selectfont]
class int(object)
 |  int(x[, base]) -> integer

share|improve this question

It works with \only<> instead of onslide<>.

share|improve this answer
Would you be amenable to using Beamer's semiverbatim environment instead of fancyvrb's Verbatim? Beamer and verbatim reportedly don't play nice with each other; see stackoverflow.com/questions/1396631/… and tex.stackexchange.com/questions/18073/beamer-and-verbatim-sync. – Jubobs Mar 1 '13 at 11:59
You could also use listings with blocks: see my answer to Using \only on a block - beamer. – Claudio Fiandrino Mar 1 '13 at 12:42
@Jubobs semiverbatim cannot be put inside onslide. – ATOzTOA Mar 1 '13 at 13:05
@ATOzTOA Yes, it can. Try \begin{frame} \onslide<2>{ \begin{semiverbatim} jsudfhsdfhsdf \end{semiverbatim} } \end{frame} – Jubobs Mar 1 '13 at 13:10
@Jubobs Sorry, my mistake, it compiles. But, semiverbatim won't keep my newlines, also the second slide will come below the first one... back to my original problem... – ATOzTOA Mar 1 '13 at 13:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.