Option 1
Here's a perl
script that can be used in the current directory:
perl createslides.plx
or if you make it executable and add it to your path, then simply
createslides.plx
You can specify the image extensions in
my %imgextensions=("png"=>1,"jpg"=>1);
and turn them on and off with a 1
or 0
respectively
createslides.plx
#!/usr/bin/perl
use strict;
use warnings;
# list extensions to work with
my %imgextensions=("png"=>1,"jpg"=>1);
# open the current directory
my $dir = './';
opendir(DIR, $dir) or die $!;
my @lines=(); # @lines: stores lines for beamer
my $extension ='';
# setup the documentclass and preamble
push(@lines,"\\documentclass{beamer}\n");
push(@lines,"% for themes, etc.\n");
push(@lines,"\\mode<presentation>\n");
push(@lines,"{ \\usetheme{boxes} }\n");
push(@lines,"\\usepackage{graphicx}\n");
push(@lines,"\\begin{document}\n");
push(@lines,"\\section{Images in this Directory}\n");
# loop through filenames
while (my $filename = readdir(DIR))
{
# get the file extension
$filename =~ m/\.(.*)$/;
$extension=$1;
if(scalar($imgextensions{$extension}))
{
push(@lines,"\\begin{frame}\n");
push(@lines,"\\frametitle{$filename}\n");
push(@lines,"\\begin{center}\n");
push(@lines,"\\includegraphics[width=4in]{$filename}\n");
push(@lines,"\\end{center}\n");
push(@lines,"\\end{frame}\n");
}
}
# close directory
closedir(DIR);
# end the documentclass
push(@lines,"\\end{document}\n");
print(@lines);
# create slides.tex
open (MYFILE, '>slides.tex');
print MYFILE @lines;
close (MYFILE);
exit
Option 2 (first attempt, not as good as option 1)
Here's a perl
script to automate the task, which you can save as (for example) createslides.plx
You can call it with:
find . -type f \( -name "*.jpg" \) -print0|xargs -0 perl createslides.plx
or else with the following if you have multiple extensions:
find . -type f \( -name "*.png" -or -name "*.jpg" \) -print0|xargs -0 perl createslides.plx
createslides.plx
#!/usr/bin/perl
use strict;
use warnings;
my $filename='';
my @lines=(); # @lines: stores lines for beamer
# setup the documentclass and preamble
push(@lines,"\\documentclass{beamer}\n");
push(@lines,"% for themes, etc.\n");
push(@lines,"\\mode<presentation>\n");
push(@lines,"{ \\usetheme{boxes} }\n");
push(@lines,"\\usepackage{graphicx}\n");
push(@lines,"\\begin{document}\n");
push(@lines,"\\section{Images in this Directory}\n");
# loop through filenames
while (@ARGV)
{
# get filename from arguments
$filename = shift @ARGV;
push(@lines,"\\begin{frame}\n");
push(@lines,"\\frametitle{$filename}\n");
push(@lines,"\\begin{center}\n");
push(@lines,"\\includegraphics[width=4in]{$filename}\n");
push(@lines,"\\end{center}\n");
push(@lines,"\\end{frame}\n");
}
# end the documentclass
push(@lines,"\\end{document}\n");
print(@lines);
# create slides.tex
open (MYFILE, '>slides.tex');
print MYFILE @lines;
close (MYFILE);
exit
It will create a file slides.tex
- a sample output is included below:
\documentclass{beamer}
% for themes, etc.
\mode<presentation>
{ \usetheme{boxes} }
\usepackage{graphicx}
\begin{document}
\section{Images in this Directory}
\begin{frame}
\frametitle{./Tux.jpg}
\begin{center}
\includegraphics[width=4in]{./Tux.jpg}
\end{center}
\end{frame}
\end{document}
Your aim seems to be to present several different policies, while leaving the general description of the first two items as a constant. You can use a combination of \alt
and \only
`:
\documentclass{beamer}
\begin{document}
\begin{frame}[t]
\frametitle{Heuristic Policies}
\begin{columns}
\column{0.5\textwidth}
\begin{itemize}
\item<1-> These are methods aiming to give a good but not necessarily optimal solution to a problem.
\item<2-> There exist a number of such policies for bandit problems.
\alt<1-9>{
\item<3-9> Greedy policy:
\begin{itemize}
\normalsize
\item<4-9> choose arm with greatest expected reward
\item<5-9> ignores variability in prior distribution
\item<6-9> quite good for Bernoulli bandits, but less effective for normal bandits
\end{itemize}
}{\only<10-14>{\item<10-> Next policy:
\begin{itemize}
\normalsize
\item<11-14> comment 1
\item<12-14> comment 2
\item<13-14> comment 3\par
\rule{0pt}{2.7cm}
\end{itemize}}
\only<15-18>{\item<15-> Another policy:
\begin{itemize}
\normalsize
\item<16-18> Another comment 1
\item<17-18> Another comment 2
\item<18-18> Another comment 3\par
\rule{0pt}{2.7cm}
\end{itemize}}
}
\end{itemize}
\column{0.3\textwidth}
\vspace{-25pt}
\uncover<7->{\begin{figure}
\begin{center}
\includegraphics[height = 2.7cm, trim=-1cm 0cm 0cm 0cm,clip=true,width=3cm]{example-image-a}
\caption*{$(\alpha,\beta) = (1,1)$}
\end{center}
\end{figure}}
\vspace{-25pt}
\uncover<8->{
\begin{figure}
\begin{center}
\includegraphics[height = 2.7cm, trim=-1cm 0cm 0cm 0cm,clip=true,width=3cm]{example-image-a}
\caption*{$(\alpha,\beta) = (6,5)$}
\end{center}
\end{figure}}
\column{0.2\textwidth}
\only<9>{$\Rightarrow$ play this arm}
\only<13-14>{$\Rightarrow$ play this arm with probability $\varepsilon$\vspace{80pt}}
\only<14>{$\Rightarrow$ play this arm with probability $1-\varepsilon$}
\end{columns}
\onslide<10>{\null}
\end{frame}
\end{document}
To avoid the jumping of the first common two items I used some "invisible" rules.
An animated image of the resulting document:
Best Answer
This sort of works.
\usecolortheme{foo}
uses a packagebeamercolorthemefoo.sty
, which is why it can only be used in the preamble. But if you neuter the commands in the.sty
file which make it a package, and\input
it instead, you can get those commands anywhere you want. So:The trouble is that some of the themes have optional arguments and this is going to ignore them. You would have to reprogram
\DeclareOption
and\ProcessOptions
to do what you want outside of a package file. That could be possible with thepgfkeys
package.Also, there might be other commands that are specific to packages and need to be neutered. Grepping a few of the other color theme packages I see
\DeclareBeamerOption
and\ProcessBeamerOption
.I think a nice enhancement to beamer would be to change the theme implementation so that this could be done easily. You could have
\loadcolortheme{foo}
in the preamble which sets up and configures the theme, but doesn't call any of the\setbeamercolor
commands until\usecolortheme{foo}
is found. For backwards compatibility\usecolortheme
can check if the theme is loaded first.