# What causes this beamer block to be slightly offset to the right?

I'm facing a problem with the block environment in beamer. Adding a tikzpicture seems to offset the following block slightly to the right. What is causing that behaviour and how can I prevent it?

\documentclass{beamer}
\usetheme{Berlin}

\usepackage{tikz}

\begin{document}

% as expected

\begin{frame}{Test}
\begin{block}{centered}
Test
\end{block}

\centering

\begin{tikzpicture}
\node [] (box){%
};
\end{tikzpicture}%

\begin{block}{not properly centered}
Test
\end{block}

\end{frame}

\end{document}


-
Maybe not an answer, but putting the tikz picture in a centred environment solves the problem. –  mas Mar 9 '14 at 13:55

The \centering declaration, not the \tikzpicture environment, is to blame for this undesirable horizontal offset you report; if you comment the tikzpicture out but leave \centering in, your second block gets gets offset to the right as well.

Edit: see percusse's comment and disregard my earlier divagations. Simply use a center environment instead of an unscoped \centering (which messes things up), here.

\documentclass{beamer}
\usetheme{Berlin}

\usepackage{tikz}

\begin{document}

\begin{frame}{Smoking the culprit (\texttt{\string\centering}) out\ldots}
\begin{block}{centered}
Test
\end{block}

\centering           %<---- this causes the horizontal offset...

%\begin{tikzpicture} %<--- not the tikzpicture
%\node [] (box){%
%};
%\end{tikzpicture}%

\begin{block}{not properly centered}
Test
\end{block}
\end{frame}

\begin{block}{centered}
Test
\end{block}

\begin{center}
\begin{tikzpicture}
\node [] (box){%
};
\end{tikzpicture}%
\end{center}

\begin{block}{not properly centered}
Test
\end{block}
\end{frame}

\end{document}

-
Thanks. I learned that \centering is better than the center environment because the center environment includes additional white space. See ftp.dante.de/tex-archive/info/l2tabu/english/l2tabuen.pdf (Section 3.1). Ahhh... I see there is a difference between the center and centering environment. –  Dr. Manuel Kuehner Mar 9 '14 at 15:03
@ManuelKuehner The \centering macro is appropriate in many cases, but in beamer, if you need to center something horizontally, a centering environment seems preferable to both \centering or a center environment. –  Jubobs Mar 9 '14 at 15:04
@ManuelKuehner Why are you centering? The blocks are centered by default. –  percusse Mar 9 '14 at 15:41
@percusse I think Manuel wants to center the tikzpicture. I've just realised that centering doesn't do that... –  Jubobs Mar 9 '14 at 15:55
Aah, OK sorry. I have a headerless and transparent block for such stuff. It keeps things scoped automatically and might be a safer approach than leaving \centering unscoped –  percusse Mar 9 '14 at 15:58