On 11/08/2010 03:38 PM, Venable wrote:
Hi all,

I frequently want to produce three almost-identical PDF versions of
the same underlying set of beamer slides:

presentation-notes.pdf, which is a handout (specify handout in
Document Settings - Class Options - Custom field) but in which I
include various noteitems to myself (Document Settings - LaTeX
Preamble: \setbeameroption{show notes})

presentation-handout.pdf, which, like the notes, is in handout form
but suppresses the notes, i.e. comments out or removes
\setbeameroption{show notes} from the preamble

presentation-slides.pdf which also has no note items but is not a
handout  (specify handout in Document Settings - Class Options -
Custom field).

This is somewhat tedious to do by hand - save-as, change name, change
the preamble, change the purpose in the Document Class, save again,
export to pdf - and I have made a few version control mistakes.

Is it possible to automate this via a command sequence, module or some
sort of script?

I have fiddled around but have been stymied by (a) the paucity of
simple, annotated examples of LFUN command sequences, scripts and the
like and (b) my own incompetence. Primarily the latter.

I don't think there are LFUNs for changing these sorts of things, at least,
not in any easy way. So the script option is likely to be the best. Since you are
only changing something pretty simple, it shouldn't be too bad.

(i) The options are recorded in the \options line of the LyX header. Find this line and then add or remove options as necessary. If it isn't there, you have to add it
just before the \use_default_options line.

(ii) Preamble stuff is in the \begin_preamble...\end_preamble block. So you can
add the other thing there.

I'd suggest you start with the presentation-slides version, since it's a matter of adding things to the others. Write a little script that will add these things, and
then run "lyx -e pdf2" on the files you create, plus the original.

The scripts below are dirty and ugly, but may work. Put them all in the same
directory, save them with the names indicated, and run:
    mkbeamer.sh yourfile.lyx

Richard

====

#!/usr/bin/perl
#this is b-handout.pl

while (<>) {
  chomp;
  if ($_ == "\\end_preamble") {
    print "\\set_beamer_option{show notes}\n$_\n";
  } else { print "$_\n"; }
}

====

#!/usr/bin/perl
#this is b-notes.pl
$found_options = 0

while (<>) {
  chomp;
  if ($_ == "\\end_preamble") {
    print "\\set_beamer_option{show notes}\n$_\n";
  } else if ($_ == "\\options") {
    $found_options = 1;
    $_ += ",handout" unless m/handout/;
    print "$_\n";
  } else if (!$found_options && $_ == "\\use_default_options") {
    print "\\options handout\n$_\n";
  } else { print "$_\n"; }
}

====

#!/bin/bash
#this is mkbeamer.sh

INFILE=$1;

# I always put this in so I can remember what I'm supposed to do
# the next time
if [ -z "$INFILE" ]; then
    echo "mkbeamer.sh LYX-BEAMER-FILE";
    exit 1;
fi

# strip extension
BASE=${INFILE%.lyx};
if [ "$BASE" = "$INFILE" ];
    echo "$INFILE is not a LyX file!";
    exit 1;
fi

NOTES="$BASE-notes.lyx";
HANDOUT="$BASE-handout.lyx";

perl b-notes.pl <$INFILE >$NOTES
perl b-handout.pl <$INFILE >$HANDOUT

lyx -e pdf2 $INFILE
lyx -e pdf2 $NOTES
lyx -e pdf2 $HANDOUT



Reply via email to