block
我在 中遇到了环境问题beamer
。添加tikzpicture
似乎会使以下块稍微向右偏移。是什么导致了这种行为?我该如何防止它?
\documentclass{beamer}
\usetheme{Berlin}
\usepackage{tikz}
\begin{document}
% as expected
\begin{frame}{Test}
\begin{block}{centered}
Test
\end{block}
\centering
\begin{tikzpicture}
\node [] (box){%
dsdsadsad
};
\end{tikzpicture}%
\begin{block}{not properly centered}
Test
\end{block}
\end{frame}
\end{document}
答案1
您报告的这个不良水平偏移应归咎于\centering
声明,而不是环境;如果您注释掉out 但保留in,那么您的第二个块也会向右偏移。\tikzpicture
tikzpicture
\centering
编辑: 看percusse 的评论忽略我之前的离题。在这里,只需使用center
环境而不是无范围\centering
(这会弄乱一切)。
\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){%
% dsdsadsad
%};
%\end{tikzpicture}%
\begin{block}{not properly centered}
Test
\end{block}
\end{frame}
\begin{frame}{Using a \texttt{center} environment instead}
\begin{block}{centered}
Test
\end{block}
\begin{center}
\begin{tikzpicture}
\node [] (box){%
dsdsadsad
};
\end{tikzpicture}%
\end{center}
\begin{block}{not properly centered}
Test
\end{block}
\end{frame}
\end{document}