I recently created a makefile to use with my TeX documents and am quite happy with the discovery. When I create Beamer slides to use in class, I create both a set of slides and a handout to go along with them. I'd like to have a makefile that creates the slides, then changes one or two lines of the header of my TeX file (by uncommenting and commenting perhaps) to create a set of handouts (possibly by generating a new, intermediate TeX file). I'm guessing that a make file can't edit my TeX file, but that would be cool. Is it possible? Thanks!
[Tex/LaTex] Changing LaTeX headers via a makefile
beamermakefile
Related Solutions
The problem appears to be related to the \title
command. When I compile a document using \title
then it hangs, and when I compile it without then it works just fine. There's a bit of a tangled web of definitions and redefinitions going on that is a bit hard to track. One method that worked for me was to copy out the (re)definition of \title
from tufte-common.def
and stick it in after the call to beamerarticle
. Thus my main file looks like this:
\documentclass{tufte-handout}
\usepackage{beamerarticle}
\makeatletter
\renewcommand{\title}[2][]{%
\gdef\@title{#2}%
\begingroup%
% TODO store contents of \thanks command
\renewcommand{\thanks}[1]{}% swallow \thanks contents
\protected@xdef\thanklesstitle{#2}%
\endgroup%
\ifthenelse{\isempty{#1}}%
{\renewcommand{\plaintitle}{\thanklesstitle}}% use thankless title
{\renewcommand{\plaintitle}{#1}}% use provided plain-text title
\@ifpackageloaded{hyperref}{\hypersetup{pdftitle={\plaintitle}}}{}% set the PDF metadata title
}
\makeatother
\input{tufteMain}
Of course, that means that the title doesn't get "beamerified", but as this is only for the article version, that doesn't matter.
I tried storing the old definition of \title
before calling beamerarticle
and resetting it afterwards, but that didn't work:
\documentclass{tufte-handout}
\let\tufteTitle=\title
\usepackage{beamerarticle}
\let\title=\tufteTitle
\input{tufteMain}
still hung.
In general, TeX hangs like that when it enters an infinite loop, so my guess is that somehow the definition and redefinition of \title
mean that it ends up calling itself again and again. Also, when TeX enters an infinite loop then the logfile contains the last thing that it did okay, so removing stuff that has appeared in the logfile isn't an optimal strategy (you may happen on whatever it was that created the loop, but there's no guarantee).
You could do this by some sneaky border code
stuff which threw away the given path (which is a box around each subpage) and drew just the bottom line for the relevant pages but I don't think that would look all that great since the lines wouldn't join up and wouldn't be vertically centred (as the pages are slightly shrunken).
So here's an alternative which defines a "background" page which is put behind all the others and which takes up the whole page. On this we draw three horizontal lines. This is never written to by the pgfpages
page collection mechanism and is copied from (physical) page to (physical) page. The only downside is that if you have a total of 17 slides then the second physical page (which has only one logical page) still has all three lines drawn on it.
Here's the code:
\documentclass[xcolor=dvipsnames, handout]{beamer}
\usepackage{pgfpages}
\usepackage{pgffor}
\beamertemplatenavigationsymbolsempty
\pgfpagesdeclarelayout{16 on 1 with background}
{
\edef\pgfpageoptionheight{\the\paperheight}
\edef\pgfpageoptionwidth{\the\paperwidth}
\edef\pgfpageoptionborder{0pt}
}
{
\pgfpagesphysicalpageoptions
{%
logical pages=17,%
physical height=\pgfpageoptionheight,%
physical width=\pgfpageoptionwidth,%
first logical shipout=2,%
}
\pgfpageslogicalpageoptions{1}
{%
resized width=\pgfphysicalwidth,%
resized height=\pgfphysicalheight,%
center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight},%
border code={%
\pgfusepath{discard}%
\pgfpathmoveto{\pgfpoint{0pt}{.25\ht0}}%
\pgfpathlineto{\pgfpoint{\wd0}{.25\ht0}}%
\pgfpathmoveto{\pgfpoint{0pt}{.5\ht0}}%
\pgfpathlineto{\pgfpoint{\wd0}{.5\ht0}}%
\pgfpathmoveto{\pgfpoint{0pt}{.75\ht0}}%
\pgfpathlineto{\pgfpoint{\wd0}{.75\ht0}}%
\pgfusepath{stroke}%
},%
copy from=1,%
}%
\pgfpageslogicalpageoptions{2}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.125\pgfphysicalwidth}{.875\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{3}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.375\pgfphysicalwidth}{.875\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{4}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.625\pgfphysicalwidth}{.875\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{5}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.875\pgfphysicalwidth}{.875\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{6}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.125\pgfphysicalwidth}{.625\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{7}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.375\pgfphysicalwidth}{.625\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{8}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.625\pgfphysicalwidth}{.625\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{9}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.875\pgfphysicalwidth}{.625\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{10}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.125\pgfphysicalwidth}{.375\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{11}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.375\pgfphysicalwidth}{.375\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{12}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.625\pgfphysicalwidth}{.375\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{13}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.875\pgfphysicalwidth}{.375\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{14}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.125\pgfphysicalwidth}{.125\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{15}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.375\pgfphysicalwidth}{.125\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{16}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.625\pgfphysicalwidth}{.125\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{17}
{%
border shrink=\pgfpageoptionborder,%
resized width=.25\pgfphysicalwidth,%
resized height=.25\pgfphysicalheight,%
center=\pgfpoint{.875\pgfphysicalwidth}{.125\pgfphysicalheight}%
}%
}
\pgfpagesuselayout{16 on 1 with background}[a0paper,border shrink=5mm, landscape]
\begin{document}
\begin{frame}[plain]
\titlepage
\end{frame}
\foreach \k in {1,...,31} {
\begin{frame}{Frame \k}
This is frame \k
\end{frame}
}
\end{document}
Result:
Best Answer
This is the same sort of problem as asked the Passing parameters to a document question; what follows is adapted from my answer there.
Have the target in your Makefile clobber a file that is
\input
by your Latex document, which should set the header. Don't be fussy about Latex convention: saving characters by using\def
makes your makefile easier to read.For example, let the Makefile have:
Then
manuscript.tex
should begin with\input{params.tex}
, defining\hdrparam
for use in your header macros.