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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
Function Get-OpenFile($initialDirectory) { [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog $OpenFileDialog.initialDirectory = $initialDirectory $OpenFileDialog.ShowDialog() | Out-Null $OpenFileDialog.filename $OpenFileDialog.ShowHelp = $true } $InputFile = Get-OpenFile $folderPath = Split-Path -parent $InputFile $NameWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($InputFile) $SaveFile = $folderPath + "\" + $NameWithoutExtension + "_NA.tex" (Get-Content $InputFile) | Foreach-Object { $_ -replace '\\pause', ' ' } | Foreach-Object { $_ -replace '\x3C\d\x2D\x3E', ' ' } | Foreach-Object { $_ -replace '\x3C\x2B\x2D\x3E', ' ' } | Foreach-Object { $_ -replace '\x5Conly\x3C\d*\x2D\x3E', ' ' } | Out-File -Encoding Default $SaveFile |
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.