Using Powershell to clean up the animations your LaTeX file

In a previous post, I talked how to animate your Beamer presentations and how to print them as slides and article for the audience. One problem with a presentation with animations is that every element of an animation means one more slide. If you want to give the presentation to the audience so they can write on their slides using their ipad or touch screen notebook, they will complain that only one of the animated slides is complete.

The easiest way to remedy this, replace all overlays, \pause, etc. from your LaTeX file and print it like this. One could do this easily in Emacs and write a macro for this. This time I chose another way to do this using Powershell, the awesome windows scripting language.

First, I define a function that will show me a file picker. Then I will use this file picker to get the LaTeX-file that should be cleaned up. From the file chosen, I save the path in a variable $FolderPath and get the name of the file. This information is used to save the file as the original name with “_NA” (for no animation).

Then I read the content and replace all occurences of \pause, <+-.> <digit-> and \only by a space using regular expressions. After this I save the file in the original place using the _NA-addition. The only thing I had problems with was the encoding (Powershell saved it in the wrong format), so I had to add “–Encoding Default” as option.

That’s all. Of course, this could be done with any scripting language.

Leave a Reply

Your email address will not be published. Required fields are marked *