Como criar automaticamente uma apresentação em PDF para cada tema Beamer disponível?

Como criar automaticamente uma apresentação em PDF para cada tema Beamer disponível?

Em vez de alterar o tema manualmente e compilá-lo para cada tema disponível, existe uma maneira mais fácil de fazer isso para que eu possa obter automaticamente uma apresentação em PDF para cada tema disponível?

Responder1

aqui está um script de shell que cria um documento principal main.tex com duas páginas de exemplo de todos os temas do TL2012 atual. Ele pode ser modificado para uso no Windows. Execute o script em um diretório vazio. O documento completo está emhttp://perce.de/temp/main.pdfe esta é a primeira página:

insira a descrição da imagem aqui

#!/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 

Responder2

Aqui está um pequeno perlscript (meu segundo em 2 dias, prometo que não estou obcecado... muito) que você pode executar da seguinte maneira

perl createBeamer.plx slides.tex

ou você pode chamá-lo com qualquer número de arquivos

perl createBeamer.plx file1.tex file2.tex file3.tex

Observe que existem algumas linhas necessárias em cada um dos seus .texarquivos, detalhadas abaixo.

Você só precisa especificar quais temas deseja usar no array @themese, então, você obterá muito pdfsao executar um script-magic:)

createBeamer.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";
    }
}

slides.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}

captura de tela

EDITAR

Se você quiser uma abordagem um pouco mais dinâmica, poderá ler os temas do projetor diretamente de sua localização

# 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);
              }

e apenas comente (ou remova) a definição anterior de @themes.

Claro, se você quiser torná-lo incrivelmente portátil, poderá realizar uma pesquisa de diretório a cada vez.

Responder3

A desvantagem desta abordagem: a lista de temas deve ser atualizada sempre que existe um novo tema no globo.

  1. batch.bataceita 2 argumentos: %1é para o nome do tema e %2para o nome do arquivo 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)
    
  2. automator.texdeve ser compilado com pdflatex --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}
    

Responder4

  1. Crie um modelo do Beamer usando \mythememacro:

    % 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}
    
  2. Crie um arquivo em lote para instalar todos os temas disponíveis do beamer:

    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
    
  3. Crie um arquivo em lote para compilar o modelo do Beamer com cada tema disponível:

    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)
    
  4. Crie outro arquivo de entrada TeX para criar o Álbum ou Catálogo do Beamer automaticamente:

    % 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}
    
  5. Execute pdflatex --shell-escape automator.texpara produzir o Catálogo Beamer.

    insira a descrição da imagem aqui

informação relacionada