# Animated scrolling marquee across an entire page.

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
\dimen2=\dimen1 %% \dimen2 will be the righthand padding
\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?

-

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

-
That works perfectly as a marquee (and is perhaps a cleaner solution than mine), however, how would it meet my requirement of "[scrolling] on top of some other text/images on the slide"? To do that I think one would have to use some sort of negative vspace hack or use the TikZ overlay hack that I originally used. Can you think of a better way? – ESultanik Aug 30 '10 at 12:15
Your tikzpicture solution was a good starting point. Just embed the animateinline environment into the tikzpicture to position it absolutely on the page. The \linewidth dimension had to be replaced by \textwidth to give the animation the correct size: (see the edited code above) – Alexander Aug 31 '10 at 9:20

The margin issue was due to an off-by-one error in the multiframe for-loop. Increasing {20} to {21} solves that problem. I guess the question now is: Is there a better, less-hackish way to do this? I am going to leave this question open for a while in case anyone has an answer to that.

-
It has been a few days, so I am going to assume no one has a better idea. – ESultanik Aug 26 '10 at 19:21
Could you leave a comment on Alexander's solution to explain why it doesn't solve your problem? – Juan A. Navarro Aug 30 '10 at 12:12