latexslideshow
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
latexslideshow [2018/12/06 19:53] – abeverley | latexslideshow [2018/12/06 20:06] (current) – abeverley | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | =====LatexSlideshow===== | ||
+ | |||
I found myself in a situation recently, where somebody wanted to create a Powerpoint slideshow for a hundred or so photos, all with the same header and footer. I thought it might be a lot easier to produce the file using Latex, and indeed it was. This is what I did. | I found myself in a situation recently, where somebody wanted to create a Powerpoint slideshow for a hundred or so photos, all with the same header and footer. I thought it might be a lot easier to produce the file using Latex, and indeed it was. This is what I did. | ||
The steps shown here include resizing and renaming the photos first. | The steps shown here include resizing and renaming the photos first. | ||
- | I am assuming that you have all your images in the directory | + | I am assuming that you have all your images in the directory |
- | ==Resize photos== | + | ===== Resize photos |
- | I used the Imagemagick | + | I used the Imagemagick |
- | mogrify | + | '' |
- | ==Rename files sequentially== | + | ===== Rename files sequentially |
- | The following Perl script renames all the files sequentially. This makes it easier to include them in the Latex script. See [http:// | + | The following Perl script renames all the files sequentially. This makes it easier to include them in the Latex script. See [[http:// |
- | | + | < |
- | + | # | |
- | use strict; | + | |
- | use warnings; | + | |
- | + | ||
- | use File::Temp qw/ | + | |
- | + | ||
- | my $dir = $ARGV[0] | + | |
- | or die " | + | |
- | + | ||
- | opendir(my $dh, $dir) or die " | + | |
- | + | ||
- | # First rename any files that are already numeric | + | |
- | while (my @files = grep { / | + | |
- | { | + | |
- | for my $old (@files) { | + | |
- | my $ext = $old =~ / | + | |
- | my ($fh, $new) = tempfile(DIR => $dir, SUFFIX => $ext); | + | |
- | close $fh; | + | |
- | rename " | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | rewinddir $dh; | + | |
- | my $i; | + | |
- | while (my $file = readdir($dh)) | + | |
- | { | + | |
- | next if $file =~ / | + | |
- | my $ext = $file =~ / | + | |
- | rename " | + | |
- | } | + | |
+ | use strict; | ||
+ | use warnings; | ||
+ | |||
+ | use File::Temp qw/ | ||
+ | |||
+ | my $dir = $ARGV[0] | ||
+ | or die " | ||
+ | |||
+ | opendir(my $dh, $dir) or die " | ||
+ | |||
+ | # First rename any files that are already numeric | ||
+ | while (my @files = grep { / | ||
+ | { | ||
+ | for my $old (@files) { | ||
+ | my $ext = $old =~ / | ||
+ | my ($fh, $new) = tempfile(DIR => $dir, SUFFIX => $ext); | ||
+ | close $fh; | ||
+ | rename " | ||
+ | } | ||
+ | } | ||
+ | |||
+ | rewinddir $dh; | ||
+ | my $i; | ||
+ | while (my $file = readdir($dh)) | ||
+ | { | ||
+ | next if $file =~ / | ||
+ | my $ext = $file =~ / | ||
+ | rename " | ||
+ | } | ||
+ | </ | ||
Save the above script and run: | Save the above script and run: | ||
- | | + | '' |
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. | ||
- | ==Convert to slideshow PDF== | + | ===== Convert to slideshow PDF ===== |
+ | |||
+ | Save the following Latex script as '' | ||
+ | |||
+ | < | ||
+ | \documentclass{beamer} | ||
+ | \usepackage[size=a4]{beamerposter} | ||
+ | \usepackage{pdfpages} | ||
+ | |||
+ | \usefonttheme{professionalfonts} % using non standard fonts for beamer | ||
+ | \usefonttheme{serif} % default family is serif | ||
+ | \usepackage{fontspec} | ||
+ | \usepackage{pgffor} | ||
+ | \setmainfont{Source Sans Pro Light} | ||
+ | |||
+ | \usepackage{graphicx} | ||
+ | |||
+ | \begin{document} | ||
- | Save the following | + | % Uncomment |
+ | % | ||
+ | % \transduration{1.5} | ||
+ | % \transglitter | ||
+ | % \begin{figure} | ||
+ | % \includegraphics[height=20cm]{another-image-file} | ||
+ | % \end{figure} | ||
+ | % \end{frame} | ||
- | \documentclass{beamer} | + | \foreach \n in {1, |
- | \usepackage[size=a4]{beamerposter} | + | \begin{frame} |
- | \usepackage{pdfpages} | + | \transduration{1.5} % Duration between slides |
- | + | \transglitter % Transition effect | |
- | \usefonttheme{professionalfonts} % using non standard fonts for beamer | + | % \includegraphics{logo}\hspace{2cm} % Optional: add a logo at the top of each slide |
- | \usefonttheme{serif} % default family is serif | + | {\LARGE\textbf{Here is a header for each page}}\newline |
- | \usepackage{fontspec} | + | \begin{figure} |
- | \usepackage{pgffor} | + | \includegraphics[height=14cm]{images/ |
- | \setmainfont{Source Sans Pro Light} | + | \end{figure} |
- | + | Here is some small footer text | |
- | \usepackage{graphicx} | + | \end{frame} |
- | + | } | |
- | \begin{document} | + | |
- | + | ||
- | % Uncomment the following to insert a title image without header and footer text | + | |
- | % \begin{frame} | + | |
- | % \transduration{1.5} | + | |
- | % \transglitter | + | |
- | % \begin{figure} | + | |
- | % \includegraphics[height=20cm]{another-image-file} | + | |
- | % \end{figure} | + | |
- | % \end{frame} | + | |
- | + | ||
- | | + | |
- | \begin{frame} | + | |
- | \transduration{1.5} % Duration between slides | + | |
- | \transglitter % Transition effect | + | |
- | % \includegraphics{logo}\hspace{2cm} % Optional: add a logo at the top of each slide | + | |
- | {\LARGE\textbf{Here is a header for each page}}\newline | + | |
- | \begin{figure} | + | |
- | \includegraphics[height=14cm]{images/ | + | |
- | \end{figure} | + | |
- | Here is some small footer text | + | |
- | \end{frame} | + | |
- | } | + | |
- | + | ||
- | \end{document} | + | |
- | Run the script. | + | \end{document} |
+ | </ | ||
+ | Run the script. | ||
- | xelatex slides.tex | + | '' |
- | This will produce | + | This will produce |
latexslideshow.1544125995.txt.gz · Last modified: 2018/12/06 19:53 by abeverley