[Tex/LaTex] Animated scrolling marquee across an entire page.

animationsbeamerpdftikz-pgf

I would like to have a scrolling marquee across the entire width of a page. I am intending this for a Beamer presentation, but the solution doesn't necessarily have anything to do with beamer. I would rather not use Beamer's built-in \animate command because (1) I would like to have control over the frame rate; and (2) I would like the slide to appear as a single page in the PDF. I therefore started playing around with the animate package for PDF animations. The tricky part is that I would like to have the marquee scroll on top of some other text/images on the slide. My first instinct was to do something like this:

\begin{amimateinline}[autoplay,
                      begin={\begin{tikzpicture}[overlay]},
                      end={\end{tikzpicture}}]{10}
  \multiframe{20}{rmarqueexpos=1.0+-0.05}{
    \node at ($(current page.west)!\rmarqueexpos!(current page.east)$) {The marquee text!};
  }
\end{animateinline}

The problem with this approach is that animateinline apparently expects its contents to be a non-zero-width box, and tikzpicture overlays are not apparently typeset as a box (I'm assuming they act like floats).

My second, more successful approach was to put the animateinline inside of an overlaid node that is centered on (current page.center). The difficulty there is that animateinline apparently also expects each frame of the animation to be the same width. Therefore, I have to pad the right and left sides of the marquee with whitespace to make it work.

Here is the closest I have gotten so far:

\documentclass{article}
\pagestyle{empty}
\usepackage{tikz}
\usepackage{animate}
\begin{document}
  \LARGE Lorem ipsum dolor sit amet, consectetur adipiscing
  elit. Vivamus nibh nibh, porttitor eu porttitor ac, tincidunt ut
  massa. Nullam quis semper erat. Ut non massa eu est aliquam suscipit
  at vel mi. Fusce commodo porttitor metus rhoncus bibendum. Ut
  fermentum pharetra lacus, id ornare dolor pretium tempor. Sed
  scelerisque mollis nisi quis malesuada. Mauris vitae nisi vitae
  augue gravida ultrices et nec metus. Quisque egestas, libero vel
  tempor dignissim, dolor tellus lacinia felis, nec imperdiet tortor
  ipsum dapibus ipsum. Quisque sodales eleifend molestie. Duis ac
  tortor velit. Nullam non justo a nunc tempus dignissim. Praesent
  condimentum ullamcorper mi, ut molestie odio placerat at. Duis
  consectetur consequat luctus. Nullam neque sem, sodales non porta
  ut, commodo vitae justo. Aenean eu facilisis quam. Sed dui nulla,
  venenatis a ullamcorper ac, blandit non dolor.

  \begin{tikzpicture}[remember picture,overlay]
    \node at (current page.center) {
      \begin{animateinline}[autoplay]{10}
        \multiframe{20}{rmarqueexpos=1.0+-0.05}{    
          \setbox0=\hbox{\scalebox{2}{\Huge The marquee text!}}
          \dimen0=\wd0 % The width of the marquee
          \dimen1=\textwidth %% \dimen1 will be the lefthand padding
          \advance\dimen1 by \dimen0
          \dimen2=\dimen1 %% \dimen2 will be the righthand padding
          \advance\dimen2 by -\rmarqueexpos\dimen1
          \advance\dimen2 by -\dimen0
          \hspace*{-\dimen0}\hspace*{\rmarqueexpos\dimen1}\box0\hbox to \dimen2{}
        }
      \end{animateinline}
    };
  \end{tikzpicture}
\end{document}

The problem with that is that the margins are a bit off (probably due to my hacked padding).
Edit: I solved this problem: It was just an off-by-one error in the multiframe for-loop. See my answer for details.

What am I doing wrong (besides being crazy enough to try and do an animated marquee in TeX)?
Is there a better way to do this?

Best Answer

try this (edited, see comment below):

\documentclass{article}
\usepackage{tikz}
\usepackage{animate}

\newlength\diffPos %diff between two positions
\def\markeetext{\scalebox{2}{\Huge+++ The marquee text +++}}

\begin{document}
  \LARGE Lorem ipsum dolor sit amet, consectetur adipiscing
  elit. Vivamus nibh nibh, porttitor eu porttitor ac, tincidunt ut
  massa. Nullam quis semper erat. Ut non massa eu est aliquam suscipit
  at vel mi. Fusce commodo porttitor metus rhoncus bibendum. Ut
  fermentum pharetra lacus, id ornare dolor pretium tempor. Sed
  scelerisque mollis nisi quis malesuada. Mauris vitae nisi vitae
  augue gravida ultrices et nec metus. Quisque egestas, libero vel
  tempor dignissim, dolor tellus lacinia felis, nec imperdiet tortor
  ipsum dapibus ipsum. Quisque sodales eleifend molestie. Duis ac
  tortor velit. Nullam non justo a nunc tempus dignissim. Praesent
  condimentum ullamcorper mi, ut molestie odio placerat at. Duis
  consectetur consequat luctus. Nullam neque sem, sodales non porta
  ut, commodo vitae justo. Aenean eu facilisis quam. Sed dui nulla,
  venenatis a ullamcorper ac, blandit non dolor.

  \begin{tikzpicture}[remember picture, overlay]
  \node
  at (current page.center) {%
    \begin{animateinline}[autoplay,loop]{5}
      \setlength{\diffPos}{%
        (\textwidth+\widthof\markeetext)*\real{0.025}}%
      \multiframe{40}{dTextPos=\textwidth+-\diffPos}{%
         \makebox[\textwidth][l]{%
            \hspace{\dTextPos}%
            \makebox[0pt][l]\markeetext%
         }%
      }%
    \end{animateinline}
  };
  \end{tikzpicture}

\end{document}

Alexander

Related Question