1

I have a problem with as weird as the title suggests.

I defined two headline templates:

\defbeamertemplate*{headline}{nosections}{%
}
\defbeamertemplate*{headline}{sections}{%
   \setbeamercolor*{headline}{bg=white,fg=tuddunkelgrau}%
   \hskip52mm%
   \insertsectionnavigationhorizontal{0.5\paperwidth}{\hskip-8pt}{\hskip-8pt}
}

And I'm also using a the beamer grid

\setbeamertemplate{background}[grid][step=10mm]

to place some paths or arrows using tikz.

On slides with navigation bar the grid fits the tikz-coordinates, but on slides without navigation bar, the grid has an offset of the height of the navigation bar. If it would be the other way around, I could understand, but that way it does not make any sense to me. What goes wrong?


Full MWE

\documentclass{beamer}

\usepackage{tikz}

\defbeamertemplate*{headline}{nosections}{%
}
\defbeamertemplate*{headline}{sections}{%
   \setbeamercolor*{headline}{bg=white,fg=tuddunkelgrau}%
   \hskip52mm%
   \insertsectionnavigationhorizontal{0.5\paperwidth}{\hskip-8pt}{\hskip-8pt}
}


\setbeamertemplate{background}[grid][step=10mm]

\begin{document}

\setbeamertemplate{headline}[nosections]    
\begin{frame}

\begin{tikzpicture}[overlay, remember picture, shift={(current page.south west)},yscale=1]
    \draw[line width = 1pt] (5,5) -- (7,7); 
\end{tikzpicture}

\end{frame}

\end{document}

enter image description here


I could work around it by defining an navigation bar with zero width for the template which is supposed to have no bar:

\defbeamertemplate*{headline}{nosections}{%
   \setbeamercolor*{headline}{bg=white,fg=tuddunkelgrau}%
   \hskip52mm%
   \insertsectionnavigationhorizontal{0.5\paperwidth}{\hskip-8pt}{\hskip-8pt}
}

But that seems stupid to me, what's the right way?

PS: an alternative way of grid drawing is performance wise no option.

2
  • I think the problem is that \pgfpointorigin, which is used in the grid drawing, gets shifted, but don't know why.... Aug 31 '16 at 18:39
  • As a workaround, it is enough to give the empty headline the same height \defbeamertemplate*{headline}{nosections}{\vskip\headheight} Aug 31 '16 at 18:41
2

A short workaround is to make the empty headline the same height as the normal one:

\defbeamertemplate*{headline}{nosections}{\vskip\headheight}

The underlying problem seems to be that \pgfpointorigin is shifted. It is used in the definition of the grid as the following:

\defbeamertemplate{background}{grid}[1][]
{%
  \setkeys{beamer@backgroundgrid}{step=0.5cm,color=fg!10!bg}%
  \setkeys{beamer@backgroundgrid}{#1}%
  \begin{pgfpicture}{0cm}{0cm}{\the\paperwidth}{\the\paperheight}
    \beamer@bggc
    \pgfpathgrid[stepx=\beamer@bggw,stepy=\beamer@bggw]{\pgfpointorigin}{\pgfpoint{\the\paperwidth}{\the\paperheight}}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

If this pgfpicture is replaced by \begin{tikzpicture}[overlay, remember picture, shift={(current page.south west)},yscale=1], then the grid is positioned according to the page.

\documentclass{beamer}

\usepackage{tikz}

\defbeamertemplate*{headline}{nosections}{\vskip0pt}
\defbeamertemplate*{headline}{sections}{%
\setbeamercolor*{headline}{bg=white,fg=tuddunkelgrau}%
\hskip52mm%
\insertsectionnavigationhorizontal{0.5\paperwidth}{\hskip-8pt}{\hskip-8pt}%
}

\makeatletter
\defbeamertemplate{background}{mygrid}[1][]
{%
    \setkeys{beamer@backgroundgrid}{step=0.5cm,color=fg!10!bg}%
    \setkeys{beamer@backgroundgrid}{#1}%
    \begin{tikzpicture}[overlay, remember picture, shift={(current page.south west)},yscale=1]
        \beamer@bggc
        \pgfpathgrid[stepx=\beamer@bggw,stepy=\beamer@bggw]{\pgfpointorigin}{\pgfpoint{\the\paperwidth}{\the\paperheight}}
        \pgfusepath{stroke}
    \end{tikzpicture}%
}
\makeatother

\setbeamertemplate{background}[mygrid][step=10mm]

\begin{document}

\setbeamertemplate{headline}[sections]    
\begin{frame}
    \begin{tikzpicture}[overlay, remember picture, shift={(current page.south west)},yscale=1]
        \draw[line width = 1pt] (5,5) -- (7,7); 
    \end{tikzpicture}
\end{frame}

\setbeamertemplate{headline}[nosections]    
\begin{frame}
    \begin{tikzpicture}[overlay, remember picture, shift={(current page.south west)},yscale=1]
        \draw[line width = 1pt] (5,5) -- (7,7); 
    \end{tikzpicture}
\end{frame}

\end{document}
5
  • It depends how "a little tweaked" will turn out performance-wise. There are various solutions out here using tikz, which are terribly slow. But they are also using loops, not in this case. I will try. But if the \pgfpointorigin is the reason, couldn't it just set to zero again? Aug 31 '16 at 21:21
  • I'm finally using another fix, which is inspired by your comment and your answer, so it would be nice if you include it to your answer, so I can accept it. The problem ist not \pgfpointorigin but the fact, that \begin{pgfpicture} refers to the paperheight, but it should refer to paperheight-headheight. So my final fix was: using the original template. but with \begin{pgfpicture}{0cm}{0cm}{\the\paperwidth}{\the\paperheight-\headheight}.In case you see a way to fix that without creating a new template, ot would be even better. I tought about redefining the paperheight, but got errors. Sep 1 '16 at 8:42
  • @thewaywewalk But with this approach the frames with headline are wrong, aren't they? Sep 1 '16 at 8:47
  • Damn yes, you're right. Then I use on of your other two suggestions. Preferably your comment as it is shorter, so maybe you want to add this to the answer. Sep 1 '16 at 8:48
  • @thewaywewalk I added it. Sep 1 '16 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.