summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/colourchange
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/colourchange
Initial commit
Diffstat (limited to 'macros/latex/contrib/colourchange')
-rw-r--r--macros/latex/contrib/colourchange/README76
-rw-r--r--macros/latex/contrib/colourchange/colourchange.sty156
-rw-r--r--macros/latex/contrib/colourchange/colourchangedoc.pdfbin0 -> 233311 bytes
-rw-r--r--macros/latex/contrib/colourchange/colourchangedoc.tex93
4 files changed, 325 insertions, 0 deletions
diff --git a/macros/latex/contrib/colourchange/README b/macros/latex/contrib/colourchange/README
new file mode 100644
index 0000000000..3138fbff33
--- /dev/null
+++ b/macros/latex/contrib/colourchange/README
@@ -0,0 +1,76 @@
+This is the README for colourchange.sty.
+
+Changes colour of beamer structural elements (e.g. the bars of outerthemes).
+This is done either manually or automatically.
+
+Don't use a colour theme or full theme (which sometimes call colour themes).
+You should be OK calling inner themes and outer themes separately (although some look better than others at the moment: see bottom of readme).
+You need to compile twice for it to work.
+
+Requires packages etoolbox and calc.
+Also needs some other stuff that is loaded by beamer.
+Use with other classes at your own risk.
+
+%------------------------------
+% Summary of commands
+%------------------------------
+
+\selectcolourchanges{first}{second} takes two arguments: the starting colour and the final colour of the presentation.
+These should be colours already understood by beamer.
+Beamer uses xcolor, so you can define colours with xcolor commands and then use them in \selectcolourchanges.
+That's what I do for the defaults.
+
+\selectmanualcolour{colour}
+Changes the structure colour.
+Use between frames.
+Can't guarantee this won't do weird stuff if you also have slidechange or framechange on.
+
+Both commands also come with an american spelling version.
+\selectcolorchanges and \selectmanualcolor are defined to be the same as the above two commands.
+%------------------------------
+% Summary of options
+%------------------------------
+
+defaultstyle
+Turns on default inner and outerthemes.
+Or rather, it will do soon.
+That is, it turns on my favourite version of the theme, not the "beamer default" ones.
+This is just a shortcut for:
+\useoutertheme[footline=authorinstitutetitle]{miniframes}
+\useinnertheme{rectangles}
+Simple.
+
+draft
+The draft option turns off colour changing.
+Good for speeding up compilation when drafting.
+
+slidechange
+Colour changes every slide.
+
+framechange
+Colour changes every frame.
+
+%------------------------------
+% To do list
+%------------------------------
+
+Make sure it works with all base inner/outer themes.
+ - smoothbars, smoothtree do some shading-fu that breaks colourchange.sty's basic approach.
+Check it doesn't hopelessly break article or handout modes
+Make a .dtx
+
+%------------------------------
+% Other stuff
+%------------------------------
+
+Currently licensed under GPL v3. http://www.gnu.org/licenses/gpl-3.0.html
+
+Original author and current maintainer: Seamus Bradley
+tex@seamusbradley.net
+
+Many thanks to the tex.stackexchange.com community for their help.
+In particular, TH's answer to this question:
+http://tex.stackexchange.com/q/7126/215
+
+And Herbert's answer to this question:
+http://tex.stackexchange.com/q/7427/215
diff --git a/macros/latex/contrib/colourchange/colourchange.sty b/macros/latex/contrib/colourchange/colourchange.sty
new file mode 100644
index 0000000000..f53715295b
--- /dev/null
+++ b/macros/latex/contrib/colourchange/colourchange.sty
@@ -0,0 +1,156 @@
+% This is the colour change package.
+% By Seamus Bradley 2011.
+% tex@seamusbradley.net
+% Licensed under GPLv3.
+% http://www.gnu.org/licenses/gpl-3.0.html
+
+%%
+\ProvidesPackage{colourchange}[2011/03/15 v1.22]
+\RequirePackage{etoolbox}
+\RequirePackage{calc}
+
+% Some new ifs I use
+
+\newif\ifclch@defaultstyle
+\newif\ifclch@slidechange
+\newif\ifclch@framechange
+\newif\ifclch@draft
+\newif\ifclch@final
+
+% The default behaviour is "do nothing"
+
+\DeclareOption{defaultstyle}{%
+\clch@defaultstyletrue%
+}
+
+\DeclareOption{slidechange}{
+\clch@slidechangetrue
+\clch@framechangefalse
+}
+
+\DeclareOption{framechange}{
+\clch@framechangetrue
+\clch@slidechangefalse
+}
+
+\DeclareOption{draft}{
+\clch@drafttrue
+}
+
+\DeclareOption{final}{
+\clch@finaltrue
+}
+
+\ProcessOptions\relax
+
+% Default option
+
+\ifclch@defaultstyle
+\useoutertheme[footline=authorinstitutetitle]{miniframes}
+\useinnertheme{rectangles}
+\fi
+
+
+% This chunky command basically makes sure that all the colours are set each time the structure colour changes.
+
+\newcommand\setcolours{%
+\setbeamercolor*{palette primary}{use=structure,fg=white,bg=structure.fg}
+\setbeamercolor*{palette secondary}{use=structure,fg=white,bg=structure.fg!75!black}
+\setbeamercolor*{palette tertiary}{use=structure,fg=white,bg=structure.fg!50!black}
+\setbeamercolor*{palette quaternary}{fg=white,bg=structure.fg!80!black}
+\setbeamercolor*{sidebar}{use=structure,bg=structure.fg}
+\setbeamercolor*{palette sidebar primary}{use=structure,fg=structure.fg!10}
+\setbeamercolor*{palette sidebar secondary}{fg=white}
+\setbeamercolor*{palette sidebar tertiary}{use=structure,fg=structure.fg!50}
+\setbeamercolor*{palette sidebar quaternary}{fg=white}
+\setbeamercolor*{titlelike}{parent=palette primary}
+\setbeamercolor{itemize item}{bg=structure}
+\setbeamercolor*{block title}{bg=structure.fg,fg=white}
+\setbeamercolor*{block body}{bg=structure.fg!50!white}
+}
+
+%------------------------------
+% Manual change command
+%------------------------------
+
+\newcommand\selectmanualcolour[1]{%
+ \setbeamercolor{structure}{fg=#1}%
+ \setcolours
+}
+
+\let\selectmanualcolor\selectmanualcolour
+
+% All the work is bascially done by a few counters
+% Some are for with the slidechange option, and some for the frame change option
+% I'll let you guess which are which.
+
+\newcounter{clch@slidefrac}
+\newcounter{clch@slidetot}
+\newcounter{clch@currslide}
+\setcounter{clch@currslide}{1}
+
+\newcounter{clch@framefrac}
+\newcounter{clch@frametot}
+\newcounter{clch@currframe}
+\setcounter{clch@currframe}{1}
+
+% At the start of each slide, step the counter, and set the fraction counter
+% Only if the draft mode is off.
+\ifclch@draft
+\renewcommand\selectmanualcolour[1]{}
+\renewcommand\selectmanualcolor[1]{}
+\else
+\ifclch@slidechange
+
+ \newcommand\fractionate{
+ \setcounter{clch@slidetot}{\inserttotalslidenumber}
+ \setcounter{clch@slidefrac}{100 * \value{clch@currslide} / \value{clch@slidetot}}
+ }
+
+ \def\beamer@checkframetitle{\stepcounter{clch@currslide}%
+ \fractionate%
+ \@ifnextchar\bgroup\beamer@inlineframetitle{}}
+
+ \fi
+
+ \ifclch@framechange
+ \newcommand\fractionate{
+ \setcounter{clch@slidetot}{\inserttotalframenumber}
+ \setcounter{clch@slidefrac}{100 * \insertframenumber / \value{clch@slidetot}}
+ }
+
+ \preto\frame{\fractionate\setcolours}
+ \fi
+\fi
+
+% This command sets the fraction counter for the above command.
+% Why do I have to set clch@slidetot here too? Well, if I put it in \AtBeginDocument, it seems to break...
+% \inserttotalslidenumber is defined at the end (lines 61 et seq.)
+
+% The colour setting commands don't like having counter names in them directly, so this workaround is necessary...
+
+\definecolor{dred}{rgb}{0.9,0.15,0.15}
+\def\first@colour{blue}
+\def\second@colour{dred}
+\newcommand\setstruccol[1]{%
+ \setbeamercolor*{structure}{fg=\second@colour!#1!\first@colour}
+}
+
+\newcommand\setstruccolx{\setstruccol{\the\value{clch@slidefrac}}}
+
+\newcommand\selectcolourchanges[2]{%
+ \def\first@colour{#1}%
+ \def\second@colour{#2}}
+\let\selectcolorchanges\selectcolourchanges
+
+% At the beginning of the document, we need to set the colours up for the first time...
+
+\AtBeginDocument{\setstruccolx \setcolours}
+
+% We need to know how many slides there are, so I just ripped off the way beamer defines \inserttotalframenumber
+
+\def\inserttotalslidenumber{1}
+\AtEndDocument{
+ \immediate\write\@auxout{\string\@writefile{nav}%
+ {\noexpand\headcommand{\noexpand\def\noexpand\inserttotalslidenumber{\the\value{clch@currslide}}}}}
+}
diff --git a/macros/latex/contrib/colourchange/colourchangedoc.pdf b/macros/latex/contrib/colourchange/colourchangedoc.pdf
new file mode 100644
index 0000000000..af01cfa3e7
--- /dev/null
+++ b/macros/latex/contrib/colourchange/colourchangedoc.pdf
Binary files differ
diff --git a/macros/latex/contrib/colourchange/colourchangedoc.tex b/macros/latex/contrib/colourchange/colourchangedoc.tex
new file mode 100644
index 0000000000..4a01434bed
--- /dev/null
+++ b/macros/latex/contrib/colourchange/colourchangedoc.tex
@@ -0,0 +1,93 @@
+\documentclass{scrartcl}
+ %Warning: I use a modified vc script so this will not compile unless you remove the \GITTag from the footer or download the modified version from my website.
+\immediate\write18{./vc}
+\input{vc}
+\usepackage[T1]{fontenc}
+\usepackage{scrpage2}
+\pagestyle{scrheadings}
+\setkomafont{pagefoot}{\small\normalfont\sffamily}
+\ifoot[\GITTag\ \VCDateISO]{\GITTag\ \VCDateISO}
+\ofoot[\GITAbrHash]{\GITAbrHash}
+\usepackage{microtype}
+\usepackage{url}
+\usepackage{libertine}
+\usepackage{inconsolata}
+\author{Seamus Bradley}
+\title{The colourchange package}
+\usepackage{listings}
+\lstloadlanguages{[LaTeX]TeX} % I need to tell listings how I want code typeset. Here come some options:
+\lstset{%
+ basicstyle=\ttfamily\small,
+ commentstyle=\itshape\ttfamily\small,
+ showspaces=false,
+ showstringspaces=false,
+ breaklines=true,
+ breakautoindent=true,
+ captionpos=t,
+ frame=single,
+ escapeinside={(*}{*)},
+}
+\begin{document}
+\maketitle
+
+\vspace{-2\normalbaselineskip}
+\begin{center}
+ \small \url{tex@seamusbradley.net}\\
+ \url{http://www.seamusbradley.net/tex.php}
+\end{center}
+
+\section{Introduction}
+
+The \lstinline+colourchange+ package provides options for changing the colour of beamer's structural elements.
+There are two ways to do this: manual and automatic.
+
+\section{Manual}
+
+The command \lstinline+\selectmanualcolour+ sets the colour to its argument.
+It accepts any named colour understood by \lstinline+xcolor+.
+
+\section{Automatic}
+
+There are two options that automatically change the colour: \lstinline+slidechange+ and \lstinline+framechange+.
+Pass one of these to the package as an option and the colour of the structure will slowly change from one colour to another.
+To set what colours the transition should be between, use: \lstinline+\selectcolourchange{first}{second}+ which makes the colour transition from
+ \lstinline+first+ to \lstinline+second+ over the course of the presentation.
+
+You will need to compile twice to see the effect since \lstinline+colourchange+ needs to know how many slides there are so it knows how far
+ through the presentation it is at a given point.
+
+\section{Usage}
+I have been testing this by calling it as a standard package, I'm not sure how \lstinline+\usecolortheme+ deals with package options.
+So if you want to use the manual colour changing option, all you need is: \lstinline+\usepackage{colourchange}+.
+If you want one of the automatic colourchange options call \lstinline+\usepackage[slidechange]{colourchange}+ or
+ \lstinline+\usepackage[framechange]{colourchange}+.
+
+You can pass the option \lstinline+defaultstyle+ to the package, this sets up the structural elements (the inner and outer theme) so that they use the colours.
+Otherwise, you can use Beamer's own \lstinline+\useinnnertheme+ and \lstinline+\useoutertheme+ to use the themes Beamer defines.
+Call inner and outer themes separately.
+Some ``all inclusive'' themes call a colour theme themselves and this can lead to only some elements changing colour.
+
+Use the \lstinline+draft+ option to turn off the colour transitions.
+
+\section{Known problems}
+
+The \lstinline+smoothbars+ and \lstinline+smoothtrees+ outer themes do some funky stuff with shading and colours, so they aren't currently supported.
+All other outer and inner themes looked alright.
+Testing was, however, pretty basic: not all combinations were tested.
+
+\section{How it works}
+
+It's a pretty simple package really.
+Just like (some) basic beamer colour themes it defines all the components of the inner and outer themes
+ in terms of one ``master colour'' called \lstinline+structure+.
+Then all it does is use various ways of changing this colour.
+The manual option just gives you a way of changing this colour on the fly.
+The two automatic ways basically fiddle with beamer slide and frame creation internals to set the structure colour whenever a new frame/slide is created.
+See the \lstinline+.sty+ file for details.
+
+\end{document}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End: