Discussion:
powerpoint-style typewriter effect in LaTeX
(too old to reply)
onecubed
2010-04-24 15:36:16 UTC
Permalink
I want the elements in the PDF output of a LaTeX file appear in a time
sequence. The application is for teaching math. So for example by
press of a button the next step of some operation shows on screen,
essentially uncovering/covering something on the current page. So I
want to be able to put a block of text and use some command to control
the time or speed of their appearance. (This is not animation as much
as it is controlled appearance.) I guess the commands may look like
\cover{stuff}{time control options}
\uncover
\show_characters_sequentially { speed option} (for plain text)
Sample files, links etc, will be appreciated.
Joseph Wright
2010-04-24 15:41:39 UTC
Permalink
Post by onecubed
I want the elements in the PDF output of a LaTeX file appear in a time
sequence. The application is for teaching math. So for example by
press of a button the next step of some operation shows on screen,
essentially uncovering/covering something on the current page. So I
want to be able to put a block of text and use some command to control
the time or speed of their appearance. (This is not animation as much
as it is controlled appearance.) I guess the commands may look like
\cover{stuff}{time control options}
\uncover
\show_characters_sequentially { speed option}  (for plain text)
Sample files, links etc, will be appreciated.
You don't say what document class you use. If you are using beamer
(seems likely) there are lots of options: there is the animation
approach, using \pause and using <> syntax. On the other hand, you
might be using some other approach. Could you give us more detail.
--
Joseph Wright
onecubed
2010-04-24 17:25:12 UTC
Permalink
Post by Joseph Wright
Post by onecubed
I want the elements in the PDF output of a LaTeX file appear in a time
sequence. The application is for teaching math. So for example by
press of a button the next step of some operation shows on screen,
essentially uncovering/covering something on the current page. So I
want to be able to put a block of text and use some command to control
the time or speed of their appearance. (This is not animation as much
as it is controlled appearance.) I guess the commands may look like
\cover{stuff}{time control options}
\uncover
\show_characters_sequentially { speed option}  (for plain text)
Sample files, links etc, will be appreciated.
You don't say what document class you use. If you are using beamer
(seems likely) there are lots of options: there is the animation
approach, using \pause and using <> syntax. On the other hand, you
might be using some other approach. Could you give us more detail.
--
Joseph Wright
I am considering documentclass{article}. But I am flexible as I have
not made or seen such PDF files. (I have seen animated graphics on
PDF though.)
This is meant for students who are viewing the file on a monitor (as
opposed to a conference presentation).
My guess is that students pay more attention to a plain text if it
appears to be typed (as opposed to the normal case where the entire
page shows up at once). This is first on my wish list.
I have not used beamer but judging from its mention next to powerpoint
my guess is that it is meant for a small amount of text. Would it be
suitable for a whole chapter?
Second item on my wish list: If I can show steps of, say, long
division, step-by-step, there may be a bit more chance that students
can follow.
Martin Heller
2010-04-25 10:21:47 UTC
Permalink
Post by onecubed
My guess is that students pay more attention to a plain text if it
appears to be typed (as opposed to the normal case where the entire
page shows up at once). This is first on my wish list.
I doubt that the readability of a longer text passage is improved by
letting it scroll automatically.
Post by onecubed
I have not used beamer but judging from its mention next to powerpoint
my guess is that it is meant for a small amount of text. Would it be
suitable for a whole chapter?
No. The text will not be broken into pages. You have to specify the
contents page by page (frame by frame).
Post by onecubed
Second item on my wish list: If I can show steps of, say, long
division, step-by-step, there may be a bit more chance that students
can follow.
Beamer allows you to uncover a frame stepwise. Here is a small example:


\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\begin{frame}
\frametitle{Pythagorean Theorem}

\begin{theorem}
\begin{equation*}
{\color<2->{blue}a^2} +
{\color<3->{green}b^2} =
{\color<4->{red}c^2}
\end{equation*}
\end{theorem}

\begin{center}
\newdimen\sidea
\newdimen\sideb
\newdimen\sidec
\begin{tikzpicture}
\pgfmathsetlength{\sidea}{+1cm};
\pgfmathsetlength{\sideb}{+1.5cm};
\pgfmathsetlength{\sidec}{sqrt(\sidea*\sidea+\sideb*\sideb)};
\useasboundingbox (-\sidea,-\sideb) rectangle
(\sidea+\sideb,\sidea+\sideb);
\draw (0pt,0pt) --node[midway,left] {$a$} (0pt,\sidea)
--node[midway,above right]{$c$} (\sideb,0pt)
--node[midway,below]{$b$} (0pt,0pt);
\draw<2->[blue] (0pt,0pt) rectangle (-\sidea, \sidea);
\draw<3->[green] (0pt,0pt) rectangle ( \sideb,-\sideb);
\draw<4->[red] ( \sideb,0pt)
--++ ( \sidea, \sideb)
--++ (-\sideb, \sidea)
--++ (-\sidea,-\sideb)
-- cycle;
\end{tikzpicture}
\end{center}

\end{frame}

\end{document}
onecubed
2010-04-27 16:15:49 UTC
Permalink
Post by Martin Heller
Post by onecubed
My guess is that students pay more attention to a plain text if it
appears to be typed (as opposed to the normal case where the entire
page shows up at once).  This is first on my wish list.
I doubt that the readability of a longer text passage is improved by
letting it scroll automatically.
I agree, for a lengthy text student may just stop reading. For the
text of an important summary or such it may help.
Post by Martin Heller
Post by onecubed
I have not used beamer but judging from its mention next topowerpoint
my guess is that it is meant for a small amount of text. Would it be
suitable for a whole chapter?
No. The text will not be broken into pages. You have to specify the
contents page by page  (frame by frame).
Post by onecubed
Second item on my wish list: If I can show steps of, say, long
division, step-by-step, there may be a bit more chance that students
can follow.
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
   \frametitle{Pythagorean Theorem}
   \begin{theorem}
     \begin{equation*}
       {\color<2->{blue}a^2} +
       {\color<3->{green}b^2} =
       {\color<4->{red}c^2}
     \end{equation*}
   \end{theorem}
\begin{center}
   \newdimen\sidea
   \newdimen\sideb
   \newdimen\sidec
   \begin{tikzpicture}
      \pgfmathsetlength{\sidea}{+1cm};
      \pgfmathsetlength{\sideb}{+1.5cm};
      \pgfmathsetlength{\sidec}{sqrt(\sidea*\sidea+\sideb*\sideb)};
      \useasboundingbox (-\sidea,-\sideb) rectangle
(\sidea+\sideb,\sidea+\sideb);
      \draw (0pt,0pt) --node[midway,left] {$a$} (0pt,\sidea)
                     --node[midway,above right]{$c$} (\sideb,0pt)
                     --node[midway,below]{$b$} (0pt,0pt);
      \draw<2->[blue]  (0pt,0pt) rectangle (-\sidea, \sidea);
      \draw<3->[green] (0pt,0pt) rectangle ( \sideb,-\sideb);
      \draw<4->[red]   ( \sideb,0pt)
                 --++ ( \sidea, \sideb)
                 --++ (-\sideb, \sidea)
                 --++ (-\sidea,-\sideb)
                 --   cycle;
   \end{tikzpicture}
\end{center}
\end{frame}
\end{document}
Thanks. I had to update my TeX quite a bit to run your file. It is
interesting.
I agree, for a lengthy text student may just stop reading.
Scrolling text may help for the text of an important summary or such.

I also got replies elsewhere, here is one from Alexander Grahn

I am afraid it will be hard to impossible to achieve the desired
effect,
because you want to animate the text in a letter by letter fashion and
(La)TeX does the so called `kerning' between letters for high
typographic
quality (See http://en.wikipedia.org/wiki/Kerning). A word by word
animation would be possible but still cumbersome to achieve. Maybe the
ocg package could help you. See
http://www.texample.net/weblog/2008/nov/02/creating-pdf-layers/

by the way now ocg package can be downloaded through MikTeX updater.

From what I understand these solutions create many layers, as
superimposed transparencies, and there cannot be easy communication
between these layers except for what you calculate and place. A letter
or symbol comes with say a color attribute but does not come with a
time attribute. So it cannot be turned on or off or change opacity.
The sequence happens as in a flip-book.

Thanks again.
Martin Heller
2010-04-27 22:44:00 UTC
Permalink
Post by onecubed
From what I understand these solutions create many layers, as
superimposed transparencies, and there cannot be easy communication
between these layers except for what you calculate and place. A letter
or symbol comes with say a color attribute but does not come with a
time attribute. So it cannot be turned on or off or change opacity.
The sequence happens as in a flip-book.
You can use Alexander Grahn's animate package to make animations in pdf.
But I don't know a good way to uncover an entire paragraph character by
character. This should work for a short sentence:

\documentclass{article}
\usepackage{xstring}
\usepackage[useocg]{animate}

\begin{document}

\newcommand\mystr{This is some text.}%
\StrLen{\mystr}[\mylen]%
\begin{animateinline}[poster=last,autoplay]{3}
\multiframe{\mylen}{iLetter=1+1}{%
\makebox[\widthof{\mystr}+2\fboxsep][l]{%
\StrLeft{\mystr}{\iLetter}%
}\newframe
}%
\end{animateinline}

\end{document}
Alexander Grahn
2010-04-28 07:42:55 UTC
Permalink
Post by Martin Heller
You can use Alexander Grahn's animate package to make animations in pdf.
But I don't know a good way to uncover an entire paragraph character by
\documentclass{article}
\usepackage{xstring}
\usepackage[useocg]{animate}
\begin{document}
\newcommand\mystr{This is some text.}%
\StrLen{\mystr}[\mylen]%
\begin{animateinline}[poster=last,autoplay]{3}
   \multiframe{\mylen}{iLetter=1+1}{%
     \makebox[\widthof{\mystr}+2\fboxsep][l]{%
       \StrLeft{\mystr}{\iLetter}%
     }\newframe
   }%
\end{animateinline}
\end{document}
What a cool example! Thanks for sharing it. To improve it a little, I
would omit the \newframe command. It makes the whole text blink when a
new letter is added. Also, option `useocg' is not necessary.

Alexander
onecubed
2010-04-30 15:22:02 UTC
Permalink
Post by Martin Heller
You can use Alexander Grahn's animate package to make animations in pdf.
But I don't know a good way to uncover an entire paragraph character by
\documentclass{article}
\usepackage{xstring}
\usepackage[useocg]{animate}
\begin{document}
\newcommand\mystr{This is some text.}%
\StrLen{\mystr}[\mylen]%
\begin{animateinline}[poster=last,autoplay]{3}
   \multiframe{\mylen}{iLetter=1+1}{%
     \makebox[\widthof{\mystr}+2\fboxsep][l]{%
       \StrLeft{\mystr}{\iLetter}%
     }\newframe
   }%
\end{animateinline}
\end{document}
Thanks. This gives me plenty to start experimenting with.
As you mentioned this works for a short sentence. For a longer one the
font starts to change in mid-flight! Would use of fixed-width fonts or
\tt simplify the task? It might even appear "more natural" if it uses
typewriter type.
Martin Heller
2010-04-30 16:18:12 UTC
Permalink
Post by onecubed
Thanks. This gives me plenty to start experimenting with.
As you mentioned this works for a short sentence. For a longer one the
font starts to change in mid-flight! Would use of fixed-width fonts or
\tt simplify the task? It might even appear "more natural" if it uses
typewriter type.
I don't know if it is better, but just try it:

\documentclass{article}
\usepackage{xstring}
\usepackage{animate}

\begin{document}

\newcommand\mystr{Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae,
felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna.}%
\StrLen{\mystr}[\mylen]%
\noindent
\begin{animateinline}[poster=last,autoplay]{3}
\multiframe{\mylen}{iLetter=1+1}{%
\begin{minipage}[t][\textwidth]{\textwidth}
\raggedright\ttfamily
\StrLeft{\mystr}{\iLetter}%
\end{minipage}%
}%
\end{animateinline}

\end{document}
onecubed
2010-05-03 14:52:11 UTC
Permalink
Post by Martin Heller
\documentclass{article}
\usepackage{xstring}
\usepackage{animate}
\begin{document}
\newcommand\mystr{Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae,
felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna.}%
\StrLen{\mystr}[\mylen]%
\noindent
\begin{animateinline}[poster=last,autoplay]{3}
   \multiframe{\mylen}{iLetter=1+1}{%
     \begin{minipage}[t][\textwidth]{\textwidth}
       \raggedright\ttfamily
       \StrLeft{\mystr}{\iLetter}%
     \end{minipage}%
   }%
\end{animateinline}
\end{document}
?

I noticed a "memory" effect on the resulting PDF file.
PDFLATEX the file. to get pdf output 1
edit by adding a few words at the end, save.
PDFLATEX again and view
the content of the first pdf shows in entirety.
the second pdf file will gradually write over the first one
causing a boldening of the font.
At the end of the first file the entire text reverts to original
lighter font.
Martin Heller
2010-05-03 20:18:59 UTC
Permalink
Post by onecubed
I noticed a "memory" effect on the resulting PDF file.
PDFLATEX the file. to get pdf output 1
edit by adding a few words at the end, save.
PDFLATEX again and view
the content of the first pdf shows in entirety.
the second pdf file will gradually write over the first one
causing a boldening of the font.
At the end of the first file the entire text reverts to original
lighter font.
Compile with pdfLaTeX twice.
onecubed
2010-05-07 20:34:02 UTC
Permalink
Post by Martin Heller
Post by onecubed
I noticed a "memory" effect on the resulting PDF file.
PDFLATEX the file. to get pdf output 1
edit by adding a few words at the end, save.
PDFLATEX again and view
the content of the first pdf shows in entirety.
the second pdf file will gradually write over the first one
causing a boldening of the font.
At the end of the first file the entire text reverts to original
lighter font.
Compile with pdfLaTeX twice.
Thanks.

As I step back and look I see that plain text is essentially a linear
1D content so there is a solution. But a mathematical text is 2D and
cannot be ordered easily. While LaTeX can handle the structure of a
document there is really no comparable pedagogical structure for a
formula. TeX does not know that in 5^x the number 5 is written first
and then x gets to be written. The output is to be seen all at once
and aided by hearing "5 raised to the power x".
My interest is in accessibility. What if a person cannot hear or see?
My guess is that when a deaf person sees a page of formulas he does
not see where it all starts and how it progresses especially because
there is not sufficient verbal or ASL reinforcement.
If TeX had the inherent capability of ordering a formula in a linear
fashion then that capability could be harvested to have the formula
appear in a time sequence thereby aiding a deaf person in following
the elements in that 2D medium. And like a screen-reader, a LaTeX-
reader would be able to read a formula to a blind person.

I have seen few accessibility references for TeX, e.g.
http://www.tug.org/pipermail/texhax/2006-June/006366.html
My guess is that whatever helps the deaf also helps the average
student.

Do I make sense? Is there any research supporting my guess? Should I
use a new heading/new post to see what is available? What is an
appropriate title/group for such a question?
Martin Heller
2010-05-07 22:07:29 UTC
Permalink
Post by onecubed
As I step back and look I see that plain text is essentially a linear
1D content so there is a solution. But a mathematical text is 2D and
cannot be ordered easily. While LaTeX can handle the structure of a
document there is really no comparable pedagogical structure for a
formula. TeX does not know that in 5^x the number 5 is written first
and then x gets to be written. The output is to be seen all at once
and aided by hearing "5 raised to the power x".
you can use /ActualText and get Acrobat reader to read it out using the
Read out loud tool.

See:
<http://thread.gmane.org/gmane.comp.tex.pdftex/4100>

onecubed
2010-04-27 16:39:59 UTC
Permalink
Post by Martin Heller
Post by onecubed
My guess is that students pay more attention to a plain text if it
appears to be typed (as opposed to the normal case where the entire
page shows up at once).  This is first on my wish list.
I doubt that the readability of a longer text passage is improved by
letting it scroll automatically.
I agree, for a lengthy text student may just stop reading. For the
text of an important summary or such it may help.
Post by Martin Heller
Post by onecubed
I have not used beamer but judging from its mention next topowerpoint
my guess is that it is meant for a small amount of text. Would it be
suitable for a whole chapter?
No. The text will not be broken into pages. You have to specify the
contents page by page  (frame by frame).
Post by onecubed
Second item on my wish list: If I can show steps of, say, long
division, step-by-step, there may be a bit more chance that students
can follow.
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
   \frametitle{Pythagorean Theorem}
   \begin{theorem}
     \begin{equation*}
       {\color<2->{blue}a^2} +
       {\color<3->{green}b^2} =
       {\color<4->{red}c^2}
     \end{equation*}
   \end{theorem}
\begin{center}
   \newdimen\sidea
   \newdimen\sideb
   \newdimen\sidec
   \begin{tikzpicture}
      \pgfmathsetlength{\sidea}{+1cm};
      \pgfmathsetlength{\sideb}{+1.5cm};
      \pgfmathsetlength{\sidec}{sqrt(\sidea*\sidea+\sideb*\sideb)};
      \useasboundingbox (-\sidea,-\sideb) rectangle
(\sidea+\sideb,\sidea+\sideb);
      \draw (0pt,0pt) --node[midway,left] {$a$} (0pt,\sidea)
                     --node[midway,above right]{$c$} (\sideb,0pt)
                     --node[midway,below]{$b$} (0pt,0pt);
      \draw<2->[blue]  (0pt,0pt) rectangle (-\sidea, \sidea);
      \draw<3->[green] (0pt,0pt) rectangle ( \sideb,-\sideb);
      \draw<4->[red]   ( \sideb,0pt)
                 --++ ( \sidea, \sideb)
                 --++ (-\sideb, \sidea)
                 --++ (-\sidea,-\sideb)
                 --   cycle;
   \end{tikzpicture}
\end{center}
\end{frame}
\end{document}
Thanks. I had to update my TeX quite a bit to run your file. It is
interesting.
I agree, for a lengthy text student may just stop reading.
Scrolling text may help for the text of an important summary or such.

I also got replies elsewhere, here is one from Alexander Grahn

I am afraid it will be hard to impossible to achieve the desired
effect,
because you want to animate the text in a letter by letter fashion and
(La)TeX does the so called `kerning' between letters for high
typographic
quality (See http://en.wikipedia.org/wiki/Kerning). A word by word
animation would be possible but still cumbersome to achieve. Maybe the
ocg package could help you. See
http://www.texample.net/weblog/2008/nov/02/creating-pdf-layers/

by the way now ocg package can be downloaded through MikTeX updater.

From what I understand these solutions create many layers, as
superimposed transparencies, and there cannot be easy communication
between these layers except for what you calculate and place. A letter
or symbol comes with say a color attribute but does not come with a
time attribute. So it cannot be turned on or off or change opacity.
The sequence happens as in a flip-book.

Thanks again.
Loading...