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

\defbeamertemplate*{headline}{nosections}{%
}
\hskip52mm%
}


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}

}
\hskip52mm%
}

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

\begin{document}

\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}


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}{%
\hskip52mm%
}


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

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

• 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

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}

\hskip52mm%
}

\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}

\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}


• 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