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:52] – 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 warnings; |
- | | + | use File::Temp qw/ |
- | | + | my $dir = $ARGV[0] |
- | or die " | + | or die " |
- | | + | opendir(my $dh, $dir) or die " |
- | | + | # First rename any files that are already numeric |
- | while (my @files = grep { / | + | while (my @files = grep { / |
- | { | + | { |
- | for my $old (@files) { | + | for my $old (@files) { |
- | my $ext = $old =~ / | + | my $ext = $old =~ / |
- | my ($fh, $new) = tempfile(DIR => $dir, SUFFIX => $ext); | + | my ($fh, $new) = tempfile(DIR => $dir, SUFFIX => $ext); |
- | close $fh; | + | close $fh; |
- | rename " | + | rename " |
- | } | + | } |
- | } | + | } |
- | + | ||
- | rewinddir $dh; | + | |
- | my $i; | + | |
- | while (my $file = readdir($dh)) | + | |
- | { | + | |
- | next if $file =~ / | + | |
- | my $ext = $file =~ / | + | |
- | 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} | + | Save the following Latex script as '' |
- | \usepackage[size=a4]{beamerposter} | + | |
- | \usepackage{pdfpages} | + | |
- | | + | < |
- | \usefonttheme{serif} % default family is serif | + | \documentclass{beamer} |
- | \usepackage{fontspec} | + | \usepackage[size=a4]{beamerposter} |
- | \usepackage{pgffor} | + | \usepackage{pdfpages} |
- | \setmainfont{Source Sans Pro Light} | + | |
- | | + | \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} |
- | % Uncomment the following to insert a title image without header and footer text | + | \begin{document} |
- | % | + | |
- | % \transduration{1.5} | + | |
- | % \transglitter | + | |
- | % \begin{figure} | + | |
- | % \includegraphics[height=20cm]{another-image-file} | + | |
- | % \end{figure} | + | |
- | % \end{frame} | + | |
- | \foreach \n in {1,...,11}{ | + | % Uncomment the following to insert a title image without header and footer text |
- | \begin{frame} | + | % |
- | \transduration{1.5} | + | % |
- | \transglitter | + | % |
- | % | + | % \begin{figure} |
- | {\LARGE\textbf{Here is a header for each page}}\newline | + | % |
- | | + | % |
- | \includegraphics[height=14cm]{images/\n} | + | % |
- | \end{figure} | + | |
- | Here is some small footer text | + | |
- | | + | |
- | | + | |
- | | + | \foreach \n in {1, |
+ | \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 | ||
+ | | ||
+ | } | ||
- | Run the script. | + | \end{document} |
+ | </ | ||
+ | Run the script. | ||
- | xelatex slides.tex | + | '' |
- | This will produce | + | This will produce |
latexslideshow.1544125950.txt.gz · Last modified: 2018/12/06 19:52 by abeverley