4

I was told to use the standalone package, which I use, but it does not seem to center the figure. What options to do I miss?

Concretely, here is the main file:

\documentclass{beamer}
\usepackage{standalone}
\usepackage{tikz}
\usecolortheme{wolverine}

\begin{document}
  \begin{frame}\frametitle{Title}
               \framesubtitle{Subtitle}
       \centering
       \includestandalone[
          mode=tex,
          width=1.3\textwidth,
          height=0.8\textheight
       ]{circle}
   \end{frame}
\end{document}

While the included file is as simple as:

\documentclass[crop,preview,tikz]{standalone}
\begin{document}%
  \begin{tikzpicture}%
     \draw (0,0) circle (1cm);% 
  \end{tikzpicture}% 
\end{document}

Unfortunately, this simple circle does not seem to be centered on the page.

Output, showing that the included picture is not centered on the page

~

Clarification: I do not mind the distortions, and the 130% scale is to demonstrate that the elongated circle is not centered, or else we would have the same overflow on both sides.

I believe that the output demonstrates that the included picture is vertically centered though.

BTW, this Tikz figure in Beamer shifting way to the right of the frame seems to be related, but \noindent and setting the \parindent to zero, do not seem to help here.

Yossi Gil
  • 15,951
  • 1
    width=1.3\textwidth <- the width of the pic is now 130 % of the printable space. And as you can see, the circle isn't a circle, since the height is much smaller. Use the option keepaspectratio. – Johannes_B Dec 19 '13 at 08:30
  • Edited the question to clarify. – Yossi Gil Dec 19 '13 at 08:36
  • 1
    It's impossible to center something wider than textwidth because all paragraphs start after left margin. If your box is wider than text width it will take part of right margin as in your example. Try with width=\textwidth (or shorter) and will see how your figure is centered. – Ignasi Dec 19 '13 at 08:56

1 Answers1

4

You can call the frame (absolute) center:

\begin{filecontents}{circle}
    \documentclass[crop,preview,tikz]{standalone}
    \begin{document}% 
    \begin{tikzpicture}% 
        \draw (0,0) circle
        (1cm);% 
        \end{tikzpicture}% 
        \end{document}
    \end{circle}
\end{filecontents}
\documentclass{beamer}
\usepackage{standalone}
\usepackage{tikz}
\usecolortheme{wolverine}

\begin{document}
\begin{frame}
    \frametitle{Title}
    \framesubtitle{Subtitle}
    \begin{figure}
    \centering
    \includestandalone[
        mode=tex,
        width=1.3\textwidth,
        height=0.8\textheight
    ]{circle}
\end{figure}
\end{frame}
\begin{frame}
    \frametitle{Title}
    \framesubtitle{Subtitle}
    \begin{tikzpicture}[remember picture,overlay]
        \node at (current page.center) {%
    \includestandalone[
        mode=tex,
        width=1\textwidth,
        height=0.8\textheight
    ]{circle}
};
\end{tikzpicture}

\end{frame}
\end{document}

A little y shifting would be necessary, though. This needs multiple run, two at least, maybe even three.

But to tell the truth, this seems to be a pretty awkward and annoying solution.

As suggested in your linked thread, a figure environment prevents the shifting. This might be a better solution.

Johannes_B
  • 24,235
  • 10
  • 93
  • 248
  • If you use 1\textwidth then the normal centering command works aswell. Third comment at the question explains the issue. – Ulle Dec 19 '13 at 09:11