21

I have a beamer presentation with several TikZ diagrams that spread across the entire frame, i.e., use the full screen size. I am using the overlay option to make sure the picture captures the entire frame:

\begin{tikzpicture}[overlay, remember picture]
  ...
\end{tikzpicture}

The problem is that these diagrams are messed up on the notes pages, that can't align them properly.

Is there a way to make a TikZ picture spread across the full page? I tried using a node that is as large as the entire frame, but it was displayed with some margin between it and the top and left edges of the frame.

Edit

When not using an overlay or background template, the result is shifted to the right:

\begin{frame}
  \begin{tikzpicture}
    \node[minimum width=\paperwidth, minimum height=\paperheight, anchor=north west] (a) {};
    \draw [very thick] (a.north west) -- (a.south east);
    \draw [very thick] (a.north east) -- (a.south west);
  \end{tikzpicture}
\end{frame}

The X is not on from the corners

Thorsten
  • 12,872
  • It would probably help if you could include a minimal example that shows how you include the node. If you say \node at (current page.north west) [anchor=north west] {...};, there shouldn't be a gap. – Jake Jan 17 '12 at 08:50
  • @Jake I'd have to look in the manual to be sure (gosh, I'm lazy) but I think that to use the current page node then you have to use overlay. – Andrew Stacey Jan 17 '12 at 09:22
  • @AndrewStacey: From the code snippet, it seems Little Bobby Tables uses overlay for his tikzpicture. – Jake Jan 17 '12 at 09:36
  • Yes, but he wants to get rid of it (at least, that's my understanding of the problem). – Andrew Stacey Jan 17 '12 at 09:50
  • Just looked. The pgf manual says that both overlay and remember picture have to be specified to use the current page node. – Andrew Stacey Jan 17 '12 at 09:57
  • LBT: By "notes" do you mean the handout version? Are you using any pgfpages stuff when generating them? I find that messes up remember picture stuff, but there's a work-around. The alternative option is to have a frame style with no margins, in which case your question is "How do I define a beamer frame style with no margins and use it only on specific frames". Either way, a MWE would help considerably ... – Andrew Stacey Jan 17 '12 at 09:59
  • Although the top-voted answer uses remember picture,overlay some of the others to this question might be of use: http://tex.stackexchange.com/questions/3915/image-on-full-slide-in-beamer-package – Andrew Stacey Jan 17 '12 at 10:17
  • @AndrewStacey Ok, how I define a beamer frame style with no margins and use if only on specific frames? See edit, it seems like this is the problem. – Little Bobby Tables Jan 17 '12 at 12:19
  • Try \begin{frame}[plain] ...\end{frame} – percusse Jan 17 '12 at 12:25
  • @percusse I did, a plain frame still has margins, apparently. – Little Bobby Tables Jan 17 '12 at 12:34
  • @LittleBobbyTables Sorry to post this many follow up questions but are you using a theme with a sidebar ? Eye-balling the shift amount, it really looks like there is an invisible sidebar sitting on the left. – percusse Jan 17 '12 at 19:13
  • @percusse I am using the default (plain, I suppose) theme. – Little Bobby Tables Jan 18 '12 at 13:52
  • You might want to check my answer to this related post, where I compile stuff from different answers to get a really empty frame in a non idiosyncratic way, where no residual left margin in a plain frame needs hacked over. – benjamin Oct 19 '16 at 09:04

3 Answers3

9

If you wrap your tikzpicture in \makebox[\textwidth][c]{...}, the picture will be properly centered and stretch across the whole width.

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\begin{frame}
 \makebox[\textwidth][c]{\begin{tikzpicture}
    \node[minimum width=\paperwidth, minimum height=\paperheight, anchor=north west] (a) {};
    \draw [very thick] (a.north west) -- (a.south east);
    \draw [very thick] (a.north east) -- (a.south west);
  \end{tikzpicture}
  }
\end{frame}

\end{document}
Jake
  • 232,450
  • That seems to work. I'll try it around a bit, I'm concerned that the \makebox command might be too fragile to handle complex pictures. If not, that's a solution. – Little Bobby Tables Jan 17 '12 at 12:35
  • 3
    This doesn't work for me. The ends of the "X" don't quite coincide with the corners of the slide. – andreasdr Sep 07 '15 at 11:24
6

Here you have two options, second is what Jake suggested and first was taken from How to insert a background image in a beamer frame?

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{graphicx}

\begin{document}

{
\usebackgroundtemplate{%
\begin{tikzpicture}
\node[draw,very thick,minimum width=\paperwidth-\pgflinewidth,minimum height=\paperheight-\pgflinewidth] [anchor=north west] (mynode) {My node};
\draw (mynode.north west)--(mynode.south east);
\draw (mynode.south west)--(mynode.north east);
\end{tikzpicture}
}
\begin{frame}{Frame with background}
\begin{itemize}
\item 1
\item 2
\item 3
\end{itemize}
\end{frame}
}

\begin{frame}{Frame with overlay picture}
\begin{tikzpicture}[overlay, remember picture]
\node[draw,very thick,minimum width=\paperwidth-\pgflinewidth,minimum height=\paperheight-\pgflinewidth] at (current page.north west) [anchor=north west] (mynode) {My node};
\draw (mynode.north west)--(mynode.south east);
\draw (mynode.south west)--(mynode.north east);
\end{tikzpicture}
\begin{itemize}
\item 1
\item 2
\item 3
\end{itemize}
\end{frame}
\end{document}

enter image description here

EDIT

From beamer user guide 8.2 Frame and Margin Sizes

Aside from using these options, you should refrain from changing the “paper size.” However, you can change the size of the left and right margins, which default to 1cm. To change them, you should use the following command: \setbeamersize{⟨options⟩}

The following ⟨options⟩ can be given:

  • text margin left=⟨TEX dimension⟩ sets a new left margin. This excludes the left sidebar. Thus, it is the distance between the right edge of the left sidebar and the left edge of the text.

The problem is that this command is only valid in the preamble, so it changes all presentation margins. Here you have a new example:

\documentclass{beamer}
\usepackage{tikz}
\setbeamersize{text margin left=0pt}
\begin{document}
\begin{frame}
  \begin{tikzpicture}
    \node[minimum width=\paperwidth, minimum height=\paperheight, anchor=north west] (a) {};
    \draw [very thick] (a.north west) -- (a.south east);
    \draw [very thick] (a.north east) -- (a.south west);
  \end{tikzpicture}
\end{frame}
\end{document}

and its result

enter image description here

Ignasi
  • 136,588
2

Here's my preferred solution: one which uses a method for absolute positioning described here and here. It aligns the "X" perfectly.

\documentclass{beamer}
\usepackage{tikz}
\begin{document}
    \setbeamertemplate{navigation symbols}{} %remove navigation symbols
    \begin{frame}
        \begin{tikzpicture}[overlay, remember picture, shift={(current page.south west)}]
        \draw (0,0) -- (\paperwidth, \paperheight);
        \draw (0,\paperheight) -- (\paperwidth, 0);
        \end{tikzpicture}
    \end{frame}
\end{document}
andreasdr
  • 615
  • Or: \documentclass{beamer} \usepackage{tikz} \begin{document} \setbeamertemplate{navigation symbols}{} \begin{frame} \begin{tikzpicture}[overlay, remember picture] \draw (current page.north west) -- (current page.south east); \draw (current page.north east) -- (current page.south west); \end{tikzpicture} \end{frame} \end{document} – Gonzalo Medina Sep 10 '15 at 22:05
  • Yes, that is basically Ignasi's second solution. – andreasdr Sep 11 '15 at 19:42