
En lugar de cambiar el tema a mano y compilarlo para cada tema disponible, ¿existe una forma más sencilla de hacerlo de modo que pueda obtener una presentación en PDF para cada tema disponible automáticamente?
Respuesta1
Aquí hay un script de shell que crea un documento principal main.tex con dos páginas de ejemplo de todos los temas del TL2012 actual. Se puede modificar para usarlo en Windows. Ejecute el script en un directorio vacío. El documento completo está enhttp://perce.de/temp/main.pdfy esta es la primera página:
#!/bin/sh
DIR=`kpsewhich beamerthemeBerlin.sty`
DIR=`dirname $DIR`
#THEME=`echo $DIR | sed -e 's/beamertheme//'`
CreateExaDocument() {
cat <<End_Of_File > $THEMESHORT.tex
\\documentclass{beamer}
\\usetheme{$THEMESHORT}
\\title{A Beamer test with Theme ``$THEMESHORT''}
\\author{Me}
\\date{today}
\\institute{Zentraleinrichtung Datenverarbeitung}
\\begin{document}
\\maketitle
\\begin{frame}{Frametitle}{Framesubtitle}
foo bar baz
\\end{frame}
\\end{document}
End_Of_File
}
for FILE in `ls --hide=compatibility $DIR` ; do
THEME=`basename $FILE .sty`
THEMESHORT=`echo $THEME | sed -e 's/beamertheme//'`
echo $THEMESHORT
CreateExaDocument
pdflatex $THEMESHORT
pdflatex $THEMESHORT
rm *.aux *.toc *.log *.out *.nav *.snm
done
# now we crate a new PDF doc with all examples
rm -f main.pdf
echo "\\documentclass[a4paper]{article}" > main.tex
echo "\\usepackage{graphicx,geometry}" >> main.tex
echo "\\geometry{margin=10mm}" >> main.tex
echo "\\parindent=0pt" >> main.tex
echo "\\begin{document}" >> main.tex
for FILE in `ls *.pdf` ; do
echo "\\frame{\\includegraphics[width=0.49\\linewidth,page=1]{$FILE}}" >> main.tex
echo "\\hfill\\frame{\\includegraphics[width=0.49\\linewidth,page=2]{$FILE}}" >> main.tex
echo "\\par\\bigskip" >> main.tex
done
echo "\\end{document}" >> main.tex
pdflatex main #--output-directory=/tmp main
pdflatex main #--output-directory=/tmp main
rm *.aux *.log
Respuesta2
Aquí tienes un pequeño perl
script (el segundo en 2 días, prometo que no me obsesiono... mucho) que puedes ejecutar de la siguiente manera
perl createBeamer.plx slides.tex
o puedes llamarlo con cualquier número de archivos
perl createBeamer.plx file1.tex file2.tex file3.tex
Tenga en cuenta que hay algunas líneas necesarias en cada uno de sus .tex
archivos, que se detallan a continuación.
Solo necesita especificar qué temas desea usar en la matriz @themes
, y luego obtendrá una gran cantidad pdfs
al ejecutar un script: magia:)
crearBeamer.plx
#!/usr/bin/perl
use strict;
use warnings;
my @themes=("default","Rochester","CambridgeUS","Boadilla","Warsaw","AnnArbor");
my $tmptheme='';
my $filename='';
while (@ARGV)
{
# get filename from arguments
$filename = shift @ARGV;
# make sure file exists
if(-e $filename)
{
# strip .tex extension
$filename =~ s/\.tex//;
# loop through the themes
foreach $tmptheme (@themes)
{
system("pdflatex","\\def\\mytheme{$tmptheme}\\input{$filename}");
system("cp","$filename.pdf","$filename$tmptheme.pdf");
}
}
else
{
print "File does NOT exist, please try again\n";
}
}
diapositivas.tex
\documentclass{beamer}
\ifdefined\mytheme
\usetheme{\mytheme}
\else
% default theme
\usetheme{Warsaw}
\fi
\begin{document}
\begin{frame}
\frametitle{Fingernails are pretty}
hello world
\end{frame}
\end{document}
EDITAR
Si desea un enfoque un poco más dinámico, puede leer los temas del proyector directamente desde su ubicación.
# location of themes
my $directory="/usr/local/texlive/2012/texmf-dist/tex/latex/beamer/themes/theme/";
opendir (DIR, $directory) or die $!;
while (my $file = readdir(DIR)) {
# remove beamertheme from the name
$file =~ s/beamertheme//;
# remove .sty extension
$file =~ s/\.sty//;
# store it
push(@themes,$file);
}
y simplemente comente (o elimine) la definición anterior de @themes
.
Por supuesto, si desea que sea increíblemente portátil, puede realizar una búsqueda en el directorio cada vez.
Respuesta3
El inconveniente de este enfoque: la lista de temas debe actualizarse cada vez que existe un nuevo tema en el mundo.
batch.bat
acepta 2 argumentos:%1
es para el nombre del tema y%2
para el nombre del archivo a incluir.rem batch.bat echo off del %1.pdf pdflatex -draftmode -interaction=batchmode --jobname=%1 "\newcommand\mytheme{%1}\input{%2}" pdflatex -interaction=batchmode --jobname=%1 "\newcommand\mytheme{%1}\input{%2}" for %%x in (aux log out toc nav snm) do (del %1.%%x)
automator.tex
debe compilarse conpdflatex --shell-escape automator
.% automator.tex \documentclass{article} \usepackage{filecontents} \begin{filecontents*}{dummy.tex} \documentclass{beamer} \usetheme{\mytheme} \title{Beamer Tutorial} \subtitle{in less than 10 minutes} \author{Garbage Collector} \date{\today} \begin{document} \maketitle \begin{frame}{Introduction} \end{frame} \end{document} \end{filecontents*} \usepackage{tikz} \begin{document} \foreach \x in {default,Rochester,CambridgeUS,Boadilla,Warsaw,AnnArbor} {\immediate\write18{batch \x\space dummy}} \end{document}
Respuesta4
Cree una plantilla de Beamer usando
\mytheme
macro:% template.tex \documentclass{beamer} \usetheme{\mytheme} \title{Beamer Tutorial} \subtitle{using \mytheme\ theme} \author{Garbage Collector} \date{\today} \begin{document} \maketitle \begin{frame}{Introduction} Stick together team and hold this position! \end{frame} \begin{frame}{Special Relativity} \[E\neq mc^2\] \end{frame} \begin{frame}{General Relativity} \[pV=nRT\] \end{frame} \end{document}
Cree un archivo por lotes para instalar todos los temas de proyector disponibles:
rem makelist.bat echo off rem %1: output file name with extension dir /b C:\texlive\2012\texmf-dist\tex\latex\beamer\themes\theme\*.sty > %1 dir /b C:\texlive\2012\texmf-dist\tex\latex\beamer\themes\theme\compatibility\*.sty >> %1
Cree un archivo por lotes para compilar la plantilla de Beamer con cada tema disponible:
rem createslide.bat echo off rem %1: theme name rem %2: Beamer input file name with or without extension del %1.pdf pdflatex -draftmode -interaction=batchmode --jobname=%1 "\newcommand\mytheme{%1}\input{%2}" pdflatex -interaction=batchmode --jobname=%1 "\newcommand\mytheme{%1}\input{%2}" for %%x in (aux log out toc nav snm) do (del %1.%%x)
Cree otro archivo de entrada TeX para crear un álbum o catálogo Beamer automáticamente:
% automator.tex \documentclass{article} \usepackage{pdfpages} \makeatletter \def\trim beamertheme{} \def\theme{\expandafter\trim \filename@base} \def\MakeThemeList#1{\immediate\write18{makelist #1}} \newread\reader % #1: theme list filename, #2: beamer template filename \def\CreateAPresentationForEachTheme#1#2{% \openin\reader=#1\relax \loop \read\reader to \themestyle \unless\ifeof\reader \filename@parse{\themestyle}% \immediate\write18{createslide \theme\space #2}% \repeat \closein\reader} % #1: theme list filename \def\CreateAlbum#1{% \openin\reader=#1\relax \loop \read\reader to \themestyle \unless\ifeof\reader \filename@parse{\themestyle}% \includepdf[pages=-,nup=2x2,delta=10pt 10pt,landscape]{\theme}% \repeat \closein\reader} \makeatother \begin{document} \MakeThemeList{themelist.txt} \CreateAPresentationForEachTheme{themelist.txt}{template.tex} \CreateAlbum{themelist.txt} \end{document}
Ejecutar
pdflatex --shell-escape automator.tex
para generar el catálogo Beamer.