User Tools

Site Tools


latexslideshow

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
latexslideshow [2018/12/06 19:50]
abeverley created
latexslideshow [2018/12/06 19:53]
abeverley
Line 9: Line 9:
 I used the Imagemagick <​tt>​mogrify</​tt>​ command to bulk resize all the images. This command resizes all images to a maximum size of 1280x1024, but does not resize them if they are already smaller than that. I used the Imagemagick <​tt>​mogrify</​tt>​ command to bulk resize all the images. This command resizes all images to a maximum size of 1280x1024, but does not resize them if they are already smaller than that.
  
- mogrify -resize 1280x1024\>​ images/*+  ​mogrify -resize 1280x1024\>​ images/*
  
 ==Rename files sequentially== ==Rename files sequentially==
Line 15: Line 15:
 The following Perl script renames all the files sequentially. This makes it easier to include them in the Latex script. See [http://​stackoverflow.com/​questions/​3211595/​renaming-files-in-a-folder-to-sequential-numbers this Stackoverflow question] for more details. The following Perl script renames all the files sequentially. This makes it easier to include them in the Latex script. See [http://​stackoverflow.com/​questions/​3211595/​renaming-files-in-a-folder-to-sequential-numbers this Stackoverflow question] for more details.
  
-<​pre>​ +  ​#​!/​usr/​bin/​perl 
-#​!/​usr/​bin/​perl +   
- +  use strict; 
-use strict; +  use warnings; 
-use warnings; +   
- +  use File::Temp qw/​tempfile/;​ 
-use File::Temp qw/​tempfile/;​ +   
- +  my $dir = $ARGV[0] 
-my $dir = $ARGV[0] +      or die "​Please specify directory as first argument";​ 
-    or die "​Please specify directory as first argument";​ +   
- +  opendir(my $dh, $dir) or die "​can'​t opendir $dir: $!"; 
-opendir(my $dh, $dir) or die "​can'​t opendir $dir: $!"; +   
- +  # First rename any files that are already numeric 
-# First rename any files that are already numeric +  while (my @files = grep { /​^[0-9]+(\..*)?​$/​ } readdir($dh)) 
-while (my @files = grep { /​^[0-9]+(\..*)?​$/​ } readdir($dh)) +  
-+      for my $old (@files) { 
-    for my $old (@files) { +          my $ext = $old =~ /​(\.[^.]+)$/​ ? $1 : '';​ 
-        my $ext = $old =~ /​(\.[^.]+)$/​ ? $1 : '';​ +          my ($fh, $new) = tempfile(DIR => $dir, SUFFIX => $ext); 
-        my ($fh, $new) = tempfile(DIR => $dir, SUFFIX => $ext); +          close $fh; 
-        close $fh; +          rename "​$dir/​$old",​ $new; 
-        rename "​$dir/​$old",​ $new; +      
-    +  
-+   
- +  rewinddir $dh; 
-rewinddir $dh; +  my $i; 
-my $i; +  while (my $file = readdir($dh)) 
-while (my $file = readdir($dh)) +  
-+      next if $file =~ /​\A\.\.?​\z/;​ 
-    next if $file =~ /​\A\.\.?​\z/;​ +      my $ext = $file =~ /​(\.[^.]+)$/​ ? $1 : '';​ 
-    my $ext = $file =~ /​(\.[^.]+)$/​ ? $1 : '';​ +      rename "​$dir/​$file",​ sprintf("​%s/​%s%s",​ $dir, ++$i, $ext);  
-    rename "​$dir/​$file",​ sprintf("​%s/​%s%s",​ $dir, ++$i, $ext);  +  }
-} +
-</​pre>​+
  
 Save the above script and run: Save the above script and run:
  
- ./rename.pl images+  ​./rename.pl images
  
 You should now have all your images as 1.jpg, 2.jpg and so on. You should now have all your images as 1.jpg, 2.jpg and so on.
Line 59: Line 57:
 Save the following Latex script as <​tt>​slides.tex</​tt>​. Comments being with a <​tt>​%</​tt>​. Save the following Latex script as <​tt>​slides.tex</​tt>​. Comments being with a <​tt>​%</​tt>​.
  
-<​pre>​ +  ​\documentclass{beamer} 
-\documentclass{beamer} +  \usepackage[size=a4]{beamerposter} 
-\usepackage[size=a4]{beamerposter} +  \usepackage{pdfpages} 
-\usepackage{pdfpages} +   
- +  \usefonttheme{professionalfonts} % using non standard fonts for beamer 
-\usefonttheme{professionalfonts} % using non standard fonts for beamer +  \usefonttheme{serif} % default family is serif 
-\usefonttheme{serif} % default family is serif +  \usepackage{fontspec} 
-\usepackage{fontspec} +  \usepackage{pgffor} 
-\usepackage{pgffor} +  \setmainfont{Source Sans Pro Light} 
-\setmainfont{Source Sans Pro Light} +   
- +  \usepackage{graphicx} 
-\usepackage{graphicx} +   
- +  \begin{document} 
-\begin{document} +   
- +  % Uncomment the following to insert a title image without header and footer text 
-% Uncomment the following to insert a title image without header and footer text +  %    \begin{frame} 
-%    \begin{frame} +  %    \transduration{1.5} 
-%    \transduration{1.5} +  %    \transglitter 
-%    \transglitter +  %    \begin{figure} 
-%    \begin{figure} +  %        \includegraphics[height=20cm]{another-image-file} 
-%        \includegraphics[height=20cm]{another-image-file} +  %    \end{figure} 
-%    \end{figure} +  %    \end{frame} 
-%    \end{frame} +   
- +  \foreach \n in {1,​...,​11}{ 
-\foreach \n in {1,​...,​11}{ +      \begin{frame} 
-    \begin{frame} +      \transduration{1.5} % Duration between slides 
-    \transduration{1.5} % Duration between slides +      \transglitter % Transition effect 
-    \transglitter % Transition effect +  %    \includegraphics{logo}\hspace{2cm} % Optional: add a logo at the top of each slide 
-%    \includegraphics{logo}\hspace{2cm} % Optional: add a logo at the top of each slide +      {\LARGE\textbf{Here is a header for each page}}\newline 
-    {\LARGE\textbf{Here is a header for each page}}\newline +      \begin{figure} 
-    \begin{figure} +          \includegraphics[height=14cm]{images/​\n} 
-        \includegraphics[height=14cm]{images/​\n} +      \end{figure} 
-    \end{figure} +      Here is some small footer text 
-    Here is some small footer text +      \end{frame} 
-    \end{frame} +  
-+   
- +  \end{document}
-\end{document} +
-</​pre>​+
  
 Run the script. <​tt>​xelatex</​tt>​ is used so that fonts can be used: Run the script. <​tt>​xelatex</​tt>​ is used so that fonts can be used:
  
- xelatex slides.tex+  ​xelatex slides.tex
  
 This will produce <​tt>​slides.pdf</​tt>​. This file can be opened with Adobe Acrobat and shown in full screen to see the slideshow with transitions. As much as I dislike the proprietary Adobe viewer, it does show the slideshow well, which not many other PDF viewers seem to support. This will produce <​tt>​slides.pdf</​tt>​. This file can be opened with Adobe Acrobat and shown in full screen to see the slideshow with transitions. As much as I dislike the proprietary Adobe viewer, it does show the slideshow well, which not many other PDF viewers seem to support.
  
latexslideshow.txt · Last modified: 2018/12/06 20:06 by abeverley