Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I create a code in LaTeX using Beamer class to produce a Beamer presentation in 20x20 format, but in stackoverflow someone tell me that is horrible! Why? the code is:

\documentclass[12pt,xcolor=x11names]{beamer}
\usecolortheme[named=darkgray]{structure}
\usetheme{Warsaw}
\usepackage{fourier}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[spanish]{babel}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage{tikz}

\setbeamertemplate{navigation symbols}{}
\hypersetup{%
        pdfpagemode=FullScreen,%
        pdfstartpage=1,%
        colorlinks=false,%
        linkcolor=magenta,%
        pdftitle={Lorem Ipsum},%
        pdfauthor={Dolor, Et},%
        pdfsubject={Lorem},%
        pdfkeywords={lorem, ipsum, dolor}%
        }
\title{Dolor Ipsum}
\subtitle{Lorem Ipsum et}
\author{Dolor Et}
\date{}

\begin{document}
{
\setbeamercolor{background canvas}{bg=darkgray}
\begin{frame}[plain]
\transduration{5}
%\titlepage
\centerline{\textcolor{white}{\textbf{\large{Dolor Ipsum}}}}
\vspace{.3cm}
\centerline{\textcolor{white}{\textbf{\large{Lorem Ipsum}}}}
\vspace{1cm}
\centerline{\textcolor{black}{\textbf{Dolor Et}}}
%\centerline{\small\color[rgb]{0.01,0.33,0.58}
%\textbf{http://www.lorem.org}}
\end{frame}
}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image1.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image2.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image3.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image4.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image5.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image6.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image7.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image8.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image9.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image10.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image11.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image12.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image13.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image14.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image15.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image16.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image17.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image18.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image19.jpg} 
    };
\end{tikzpicture}
\end{frame}

\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{image20.jpg} 
    };
\end{tikzpicture}
\end{frame}

\end{document}
share|improve this question
add comment

3 Answers

up vote 12 down vote accepted

In both cases below, I assume your images are literally named imageN.jpg, where N is 1, 2, 3, ... , 20:

Option 1 (removes 180 lines of code, adds back 30, and lets you change the style of all frames in one place):

Add to the preamble

\newcommand{\myframe}[1]{
\begin{frame}[plain]
\transduration{20}
\begin{tikzpicture}[remember picture,overlay]   
    \node[at=(current page.center)] {
    \includegraphics[height=\paperheight]{#1}
    };
\end{tikzpicture}
\end{frame}
}

and replace each of your 20 frames with 20 \myframe{imageN.jpg} commands.

Option 2, replacing the 20 \myframe commands with a loop (saves another 17 lines):

\foreach \n in {1,...,20} {
  \myframe{image\n.jpg}
}

Also, in this particular example, the pdfpages package seems to be unused. Stripping out all the commented lines and the pdfpages package, and converting the original presentation to the looped version, what was 263 lines of code is now 58 lines long.


Here's a start at a lightning style beamer presentation class and demonstration:

beamer-lightning.cls

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{beamer-lightning}[2011/10/09 v0.1 Modified beamer class for ``lightning'' presentations]

\newcommand{\slideduration}{15}
\DeclareOption{ignite}{%
  \renewcommand{\slideduration}{15}%
}
\DeclareOption{pechakucha}{%
  \renewcommand{\slideduration}{20}%
}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{beamer}}
\ProcessOptions

\LoadClass{beamer}
\setbeamertemplate{navigation symbols}{}

\RequirePackage{hyperref}
\hypersetup{pdfpagemode=FullScreen}

\newenvironment{slide}[1]
  {\begin{frame}[environment=slide]
  \transduration{\slideduration}
  \frametitle{#1}}
  {\end{frame}}

\endinput

pk-example.tex

% class option ignite: 15 second slide duration
% class option pechakucha: 20 second slide duration
\documentclass[ignite]{beamer-lightning}
\usetheme{Boadilla}

\title{There Is No Largest Prime Number}
\subtitle{With an introduction to a new proof technique}
\institute[Alexandria]{Department of Mathematics \\
  University of Alexandria}
\author[Euclid]{Euclid of Alexandria \\ \texttt{euclid@alexandria.edu}}
\date[ISPN '80]{27th International Symposium of Prime Numbers}

\usepackage{pgffor} % for \foreach command below

\begin{document}

% The slide environment creates a slide with an automatic transition time
\begin{slide}
  \titlepage
\end{slide}

% For presentations where each slide is regular text and content:
\begin{slide}{What Are Prime Numbers?}
  \begin{definition}
    A \alert{prime number} is a number that has exactly two divisors.
  \end{definition}
  \begin{example}
    \begin{itemize}
      \item 2 is prime (two divisors: 1 and 2).
      \item 3 is prime (two divisors: 1 and 3).
      \item 4 is not prime (\alert{three} divisors: 1, 2, and 4).
    \end{itemize}
  \end{example}
\end{slide}

% For presentations where each slide is a giant image named
% imageN.png or similar:
\foreach \slidetitle in {
{Title 3, which has a comma}, Title 4, Title 5, Title 6, Title 7, Title 8,
Title 9, Title 10}
{
  \begin{slide}{\slidetitle}
  \begin{center}
  Here lies image\thepage{}.png
  \end{center}
  \end{slide}
}

% For presentations where each slide is a giant image named
% arbitrarily:
\foreach \slidetitle / \imagefile in {
{Title 11 (with embedded /)} / imagexi.png,
Title 12 / image12.pdf,
Title 13 / number13.jpg,
Title 14 / file14.png,
Title 15 / 15.png,
Title 16 / sixteen.pdf,
Title 17 / xvii.png,
Title 18 / 18.pdf,
Title 19 / 19.png,
Title 20 / twenty.pdf}
{
  \begin{slide}{\slidetitle}
  \begin{center}
  Here lies \imagefile
  \end{center}
  \end{slide}
}

\end{document}
share|improve this answer
    
Gracias. Lo primero que debo decir es que soy hablante de la lengua española (por eso del uso de babel=spanish y para los acentos de T1). Lamento escribir esto en español, pero es la única forma de que se entienda mi error. No puedo estar más que agradecido por sus comentarios, en particular, este perteneciente al Sr. Mike Renfo, de nuevo muchas gracias. Ha sido Ud. muy claro y eficiente. –  hsigrist Oct 11 '11 at 12:55
add comment

First they did not say horrible but horribly bloated which probably means that it is far more lengthy than it is supposed to be. Second, somebody asked how to change slides in every 20 seconds and you provided a 20-many slides which is repeated 20 times with literally identical code.

I don't know if this was your intention but I have to agree with the comment over SE that your answer does not contribute to the answer the OP is looking for. What you might have done is to use animate package to replay your 20-many images changing at the rate of one at every 20 seconds. I don't know what else might have been said.

share|improve this answer
add comment

I wouldn't go as far as calling your code "horrible," but I do notice, among other things:

  • packages fontenc, inputenc, babel, hyperref, and pdfpages needn't be loaded at all, and the lengthy \hypersetup{...} command can be omitted too;
  • you set up the macros \title, \subtitle, \author, and \date, but then they're not used;
  • AFAICT, all you need the tikz package for is to center the images on the respective pages. This can be done much more economically with a simple \centering instruction after the \transduration and before the \includegraphics commands;
  • On frame 1, you have several \centerline and \textbf commands. Remove them all, and simply insert \centering\bfseries at the top of the frame;
  • The option xcolor=x11names in the \documentclass statement is unnecessary because the only "colors" you use are white, black, gray and darkgray -- which are always available when xcolor is loaded;
  • I see Mike Renfro has, in the meantime, provided some comments on how to streamline looping over images 1 to 20. I have nothing to add to that, except to say that I fully agree with them. Aside: If you do use Mike Renfro's code, you will need to load the tikz package or, at the very least, the pgffor package (which is loaded by the tikz package) in order to load the \foreach macro.
share|improve this answer
    
The pgffor package also provides \foreach. –  Bruno Le Floch Oct 9 '11 at 2:40
    
Why don't you need babel? Is there no hyphenation in beamer? (I don't use beamer.) –  doncherry Oct 9 '11 at 9:09
    
@doncherry: Given that the document mainly consists of 20 images, I can't see where babel gets to do anything at all. Of course, I may be mistaken! –  Mico Oct 9 '11 at 12:49
1  
@BrunoLeFloch: Thanks for this. In fact, I believe, the tikz package also accesses the code in pgffor. Hence, loading pgffor instead of tikz might (marginally) accelerate execution of the program, right? –  Mico Oct 9 '11 at 12:50
    
Yes. tikz loads pgffor. –  Bruno Le Floch Oct 9 '11 at 12:55
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.