When making presentations in LyX with the Beamer template, one often wants to make three PDFs every time: slides, handouts, and handouts+notes. Here are some scripts to do this. You will need Cygwin installed if you are on Windows.
Command-line version:
In Windows I've added this functionality to the right-click menu for LyX files. It requires the slightly modified script below. To edit the right-click menu I use the FileMenu Tools utility. In a new entry, set the program as a shell (I've tested git -- "C:\Program Files (x86)\Git\bin\sh.exe" and cygwin -- "C:\cygwin64\bin\mintty.exe"). For arguments put "absolute/path/to/beamer_outputs.sh %FILENAME1%".
Command-line version:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Creates three PDFs from a Beamer LyX document. | |
# Doesn't assume anything about existing options | |
# so makes all docs with new file suffixes. | |
# | |
# Added to Right-click menu with FileMenu Tools by lopesoft | |
# Pass in the filename with extension | |
filename=${1%%.*} | |
# Get the plain slides version | |
cp $filename.lyx $filename-slides.lyx | |
# Be careful if no options have been set | |
optLines="$(grep -c '\\options' $filename.lyx)" | |
if [ $optLines -eq 0 ] | |
then | |
sed -i 's/\(\\end_preamble\)/\1\n\\options /g' $filename-slides.lyx | |
fi | |
if [ $optLines -gt 1 ] | |
then | |
echo "Warning: More than one \\option line. This may not work" | |
fi | |
# Remove just the relevant options | |
sed -i 's/\(\\options .*\)notes=show,*/\1/g' $filename-slides.lyx | |
sed -i 's/\(\\options .*\)handout,*/\1/g' $filename-slides.lyx | |
# Make the other versions | |
cp $filename-slides.lyx $filename-handout.lyx | |
sed -i 's/\(\\options \)/\1handout,/g' $filename-handout.lyx | |
cp $filename-slides.lyx $filename-notes.lyx | |
sed -i 's/\(\\options \)/\1handout,notes=show,/g' $filename-notes.lyx | |
# export slides | |
lyx -e pdf2 $filename-slides.lyx | |
lyx -e pdf2 $filename-notes.lyx | |
lyx -e pdf2 $filename-handout.lyx | |
# clean up extra files | |
rm $filename-handout.lyx $filename-slides.lyx $filename-notes.lyx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Creates three PDFs from a Beamer LyX document. | |
# Doesn't assume anything about existing options | |
# so makes all docs with new file suffixes. | |
# | |
# Added to Right-click menu with FileMenu Tools by lopesoft | |
# Pass in the filename with extension | |
filename=${1%%.*} | |
# Get the plain slides version | |
cp $filename.lyx $filename-slides.lyx | |
# Be careful if no options have been set | |
optLines="$(grep -c '\\options' $filename.lyx)" | |
if [ $optLines -eq 0 ] | |
then | |
sed -i 's/\(\\\\end_preamble\)/\1\n\\\\options /g' $filename-slides.lyx | |
fi | |
if [ $optLines -gt 1 ] | |
then | |
echo "Warning: More than one \\option line. This may not work" | |
fi | |
# Remove just the relevant options | |
sed -i 's/\(\\\\options .*\)notes=show,*/\1/g' $filename-slides.lyx | |
sed -i 's/\(\\\\options .*\)handout,*/\1/g' $filename-slides.lyx | |
# Make the other versions | |
cp $filename-slides.lyx $filename-handout.lyx | |
sed -i 's/\(\\\\options \)/\1handout,/g' $filename-handout.lyx | |
cp $filename-slides.lyx $filename-notes.lyx | |
sed -i 's/\(\\\\options \)/\1handout,notes=show,/g' $filename-notes.lyx | |
# export slides | |
lyx -e pdf2 $filename-slides.lyx | |
lyx -e pdf2 $filename-notes.lyx | |
lyx -e pdf2 $filename-handout.lyx | |
# clean up extra files | |
rm $filename-handout.lyx $filename-slides.lyx $filename-notes.lyx |
No comments:
Post a Comment