Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetroff committed Nov 29, 2014
0 parents commit 2a821e7
Show file tree
Hide file tree
Showing 10 changed files with 546 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
output
18 changes: 18 additions & 0 deletions COPYING
@@ -0,0 +1,18 @@
Copyright (c) 2014 Matthew Petroff

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55 changes: 55 additions & 0 deletions beamer.tex
@@ -0,0 +1,55 @@
\documentclass{beamer}
\usepackage[utf8]{inputenc}

\usetheme{#THEME}
\usecolortheme{#COLOR_THEME}

\title[Short Paper Title]{Presentation Title}
\subtitle{Presentation Subtitle}
\author[Author, Another]{F.~Author\inst{1} \and S.~Another\inst{2}}
\institute[Some University]
{
\inst{1}%
Department of Computer Science\\
University of Somewhere
\and
\inst{2}%
Department of Theoretical Philosophy\\
University of Elsewhere}
\date[Short Occasion]{Date / Occasion}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\section{First Section}

\subsection[Short First Subsection Name]{First Subsection Name}

\begin{frame}{This is the slide title.}{This is the slide subtitle.}
\begin{block}{Remark}
Sample text
\end{block}

\begin{itemize}
\item
An item
\item
Another item
\begin{itemize}
\item Something
\begin{itemize}
\item Something else
\end{itemize}
\end{itemize}
\begin{enumerate}
\item Thing A
\item Thing B
\item Thing C
\end{enumerate}
\end{itemize}
\end{frame}

\end{document}
165 changes: 165 additions & 0 deletions generate.py
@@ -0,0 +1,165 @@
#!/usr/bin/env python

# generate.py - Generates a Beamer theme matrix
# Copyright (c) 2014 Matthew Petroff
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import subprocess
import tempfile
import os
import shutil

# Options
themes = ['default', 'AnnArbor', 'Antibes', 'Bergen', 'Berkeley', 'Berlin',
'Boadilla', 'CambridgeUS', 'Copenhagen', 'Darmstadt', 'Dresden',
'EastLansing', 'Frankfurt', 'Goettingen', 'Hannover', 'Ilmenau',
'JuanLesPins', 'Luebeck', 'Madrid', 'Malmoe', 'Marburg', 'Montpellier',
'PaloAlto', 'Pittsburgh', 'Rochester', 'Singapore', 'Szeged', 'Warsaw']
colorThemes = ['default', 'albatross', 'beaver', 'beetle', 'crane', 'dolphin',
'dove', 'fly', 'lily', 'monarca', 'orchid', 'rose', 'seagull', 'seahorse',
'spruce', 'whale', 'wolverine']
thumbSize = 200 # Changing thumbnail size requires additonal CSS changes
fullSize = 1000



# Always behave the same no matter where script was called from
scriptDir = os.path.dirname(os.path.realpath(__file__))



#
# Generate LaTeX outputs
#

with open(os.path.join(scriptDir, 'beamer.tex')) as inFile:
texSource = inFile.read()

outputDir = os.path.join(scriptDir, 'output')
try:
os.mkdir(outputDir)
except OSError:
pass # Directory already exists
os.chdir(outputDir)

tempDir = tempfile.mkdtemp()

# Create PDF for given theme / color combination and optionally copy result
def createPDF(theme, colorTheme, copy=True):
outFilename = os.path.join(tempDir, theme + '-' + colorTheme + '.tex')
with open(outFilename, 'w') as outFile:
out = texSource.replace('#THEME', theme).\
replace('#COLOR_THEME', colorTheme)
outFile.write(out)

subprocess.call(['pdflatex', '-output-directory=' + tempDir, outFilename])
result = outFilename[:-3] + 'pdf'
if copy:
shutil.copy(result, colorTheme + '.pdf')
return colorTheme + '.pdf'

# Create PNG from PDF
def createImage(pdf, prefix, width):
subprocess.call(['pdftoppm', '-scale-to', str(width), '-png', pdf, prefix])

# First LaTeX run
createPDF('default', 'default', False)

# Create samples
for theme in themes:
themeDir = os.path.join(outputDir, theme)
try:
os.mkdir(themeDir)
except OSError:
pass # Directory already exists
os.chdir(themeDir)
thumbs = []
for colorTheme in colorThemes:
pdf = createPDF(theme, colorTheme)
createImage(pdf, pdf[:-4] + '-thumb', thumbSize)
createImage(pdf, pdf[:-4] + '-full', fullSize)
thumbs.append(pdf[:-4] + '-thumb-1.png')
thumbs.append(pdf[:-4] + '-thumb-2.png')
os.remove(pdf) # Clean up
subprocess.call(['convert'] + thumbs + ['+append', 'thumbs.png'])
subprocess.call(['pngquant', '-f', '--ext', '.png', 'thumbs.png'])

# Clean up
for thumb in thumbs:
os.remove(thumb)

# Optimize
subprocess.call('optipng *.png', shell=True)



#
# Create web page
#

htmlTable = '<table class="theme-grid">'
for theme in themes:
htmlTable += '<tr>'
for i in range(len(colorThemes)):
colorTheme = colorThemes[i]
htmlTable += '<td><div class="iblock"><div class="table">' \
+ '<div class="table-row"><div class="table-cell">' \
+ '<a href="' + theme + '/' + colorTheme \
+ '-full-1.png" data-sbox=' + theme + colorTheme \
+ ' title="Theme: ' + theme + ', Color Theme: ' \
+ colorTheme + '">' \
+ '<div class="beamer-thumb" style="background: url(\'' + theme \
+ '/thumbs.png\') -' + str(i * 2 * thumbSize) \
+ 'px 0;"></div></a></div><div class="table-cell">' \
+ '<a href="' + theme + '/' + colorTheme \
+ '-full-2.png" data-sbox=' + theme + colorTheme \
+ ' title="Theme: ' + theme + ', Color Theme: ' + colorTheme \
+ '"><div class="beamer-thumb beamer-right" ' \
+ 'style="background: url(\'' + theme + '/thumbs.png\') -' \
+ str((i * 2 + 1) * thumbSize) \
+ 'px 0;"></div></a></div></div></div></div></td>\n'
htmlTable += '</tr>'
htmlTable += '</table>'

topHeader = ''
for colorTheme in colorThemes:
topHeader += '<td>' + colorTheme + '</td>\n'
leftHeader = ''
for theme in themes:
leftHeader += '<tr><td><div>' + theme + '</div></td></tr>\n'

os.chdir(outputDir)
with open(os.path.join(scriptDir, 'matrix.html')) as inFile:
htmlSource = inFile.read()
with open('index.html', 'w') as outFile:
out = htmlSource.replace('#TABLE', htmlTable).\
replace('#TOP_HEADER', topHeader).replace('#LEFT_HEADER', leftHeader)
outFile.write(out)

with open(os.path.join(scriptDir, 'style.css')) as inFile:
cssSource = inFile.read()
with open('style.css', 'w') as outFile:
out = cssSource.replace('#TABLE_WIDTH', str(425 * len(colorThemes)) + 'px')
outFile.write(out)

includesDir = os.path.join(scriptDir, 'includes')
shutil.copy(os.path.join(includesDir, 'bootstrap.min.css'), '.')
shutil.copy(os.path.join(includesDir, 'slenderbox.css'), '.')
shutil.copy(os.path.join(includesDir, 'slenderbox.js'), '.')
10 changes: 10 additions & 0 deletions includes/bootstrap.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions includes/slenderbox.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions includes/slenderbox.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions matrix.html
@@ -0,0 +1,102 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Another Beamer Theme Matrix</title>
<meta name="description" content="This theme matrix shows examples of all variations of the Beamer LaTeX package's default themes and color themes.">
<meta name="keywords" content="LaTeX, Beamer, theme, matrix">
<link rel="stylesheet" href="bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="style.css"/>
<link type="text/css" rel="stylesheet" href="slenderbox.css"/>
</head>
<body>


<!-- Welcome / help screen -->
<div class="modal in" id="help" tabindex="-1" role="dialog">
<div class="modal-backdrop in" id="modal-backdrop" onclick="closeHelp()"></div>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" onclick="closeHelp()"><span>&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Another Beamer Theme Matrix</h4>
</div>
<div class="modal-body">
<p>
As you probably know, <a href="http://bitbucket.org/rivanvx/beamer/">Beamer</a>
is a <span class="latex">L<sup>a</sup>T<sub>e</sub>X</span> package for
creating presentation slides. This matrix shows examples of all variations of
the default themes and color themes.
</p>
<p>
The matrix&rsquo;s rows list the default Beamer themes, and the matrix&rsquo;s columns list
the default Beamer color themes. In a <span class="latex">L<sup>a</sup>T<sub>e</sub>X</span>
document&rsquo;s preamble, set the theme using <code>\usetheme{Berlin}</code> and set
the the color theme using <code>\usecolortheme{crane}</code>, where
<code>Berlin</code> and <code>crane</code> are replaced with the theme and
color theme of your choosing.
<p>
<p>
The code used to generate this page is available on
<a href="https://github.com/mpetroff/beamer-theme-matrix">GitHub</a>. This page
was inspired by the <a href="http://www.hartwork.org/beamer-theme-matrix/">
original Beamer Theme Matrix</a>.
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="closeHelp()">Close</button>
</div>
</div>
</div>
</div>


<!-- Headers -->
<div id="top-header">
<table>
<tr>
#TOP_HEADER
</tr>
</table>
</div>
<div id="left-header">
<table>
#LEFT_HEADER
</table>
</div>
<div id="top-left-block"><div id="help-button" onclick="openHelp()"></div></div>


<!-- Main content -->
#TABLE


<!-- Scripts -->
<script type="text/javascript" src="slenderbox.js"></script>
<script>
document.addEventListener('scroll', function() {
var topHeader = document.getElementById('top-header');
topHeader.style.left = (50 - window.scrollX) + 'px';

var leftHeader = document.getElementById('left-header');
leftHeader.style.top = (50 - window.scrollY) + 'px';
}, false);

function openHelp() {
var help = document.getElementById('help');
help.style.display = 'block';
document.body.classList.add('modal-open');
document.getElementById('modal-backdrop').style.height = help.scrollHeight + 'px';
}
// Show help on page load (this way the page still works without JavaScript)
openHelp();

function closeHelp() {
document.getElementById('help').style.display = 'none';
document.body.classList.remove('modal-open');
}
</script>


</body>
</html>
26 changes: 26 additions & 0 deletions readme.md
@@ -0,0 +1,26 @@
# Another Beamer Theme Matrix

As you probably know, [Beamer](http://bitbucket.org/rivanvx/beamer/) is a LaTeX
package for creating presentation slides. This matrix shows examples of all
variations of the default themes and color themes. The matrix's rows list the
default Beamer themes, and the matrix's columns list the default Beamer color
themes.

## Building Theme Matrix

To build the theme matrix, run `generate.py`. It has been tested on both Python
2.7 and Python 3.4 under Linux Mint 17. Besides Python, `pdflatex`, `pdftoppm`,
`convert`, `pngquant`, and `optipng` are needed on the path.

## License

Another Beamer Theme Matrix is distributed under the MIT License. For more
information, read the file `COPYING`.

## Credits

Another Beamer Theme Matrix was built by [Matthew Petroff](//mpetroff.net)
using [Bootstrap](http://getbootstrap.com/) and
[Slenderbox](https://github.com/mpetroff/slenderbox). The information icon
is from [Font Awesome](http://fontawesome.io/). This matrix was inspired by the
[original Beamer Theme Matrix](http://www.hartwork.org/beamer-theme-matrix/).

0 comments on commit 2a821e7

Please sign in to comment.