0

The following question is related to this one.


I'd like to be able to position a TikZ node in an arbitrary position inside the "main area" of a beamer slide, i.e. inside the white rectangle in the example below.

\documentclass{beamer}
\usetheme{Warsaw}
\begin{document}
\section{A section}
\begin{frame}{Title}
\end{frame}
\end{document}

An empty beamer slide under the Warsaw theme

In order to do so, I need to have access to one of several collections of information:

  1. The heights of the various articles that go in the top and bottom of the slide:

    • the section banner
    • the title banner
    • the navigation ruler
    • the banner along to bottom edge of the slide
  2. The distances of the four corners of the main area from the edge of the page closest to them, respectively.

  3. The distance of one of the four corners of the main area from the edge of the page closest to it, together with the height of the main area.

  4. An object similar to TikZ's current page that represents the main area, so it would be possible to write something like \draw[fill=red] (main area.north west) circle (1pt); to get a filled red circle at the top left corner of the main area.

In either case, I'd also like to know the height of the shade under the title banner.

Note that the height of the various articles mentioned in the first point above is dynamic, and each of them can be hidden separately from the others.

  1. How can I gain access to a sufficient amount of information that would enable me to position a TikZ picture at an arbitrary position in a slide's main area?
  2. Is there a general answer to the previous question irrespective of theme? This would be preferrable over an answer that relies on the Warsaw theme.
Evan Aad
  • 11,066
  • 4
    https://www.ctan.org/pkg/tikzpagenodes – samcarter_is_at_topanswers.xyz Dec 13 '22 at 10:41
  • @samcarter_is_at_topanswers.xyz Thanks. This is a good starting point, but it's only a partial answer, since the navigation toolbar and title banner are part of the current page text area object defined by the tikzpagenodes package your comment referred to. Additionally, the tikzpagenodes package doesn't help with figuring out the height of the shade under the title banner. – Evan Aad Dec 13 '22 at 10:53
  • 1
    The big problem is that \beamer@frametitlebox is not created until after the text area, and is empty by shipout. You would have to modify beamer to store the sizes in global variables as they are generated. See https://tex.stackexchange.com/questions/397523/tikz-based-beamer-frame – John Kormylo Dec 14 '22 at 05:02
  • @JohnKormylo Thanks. The post you linked to is helpful, and also the post that prompted it. – Evan Aad Dec 14 '22 at 05:41
  • I suspect that the header and footer are added by the beamer style file, and do not use \headheight or \footskip. (OTOH, the navigation bar is given a height of 1.875ex and a depth of 0.75ex, mostly empty space.) – John Kormylo Dec 15 '22 at 15:23
  • I meant "theme" not "style". – John Kormylo Dec 17 '22 at 03:44

1 Answers1

2

The height of the text area is unknown, or at least is not equal to \textheight. The text area either overlaps the bottom of the slide, or it doesn't. there is no way to know a priori. I don't think beamer even calculates the available space. It just applies \vfill above and below and hopes.

Using \tikzmark you can locate of the NW and SE corners, or even compute offsets relative to (current page) anchors.

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}
\begin{document}
\section{A section}
\begin{frame}{Title}
\rule{\textwidth}{16\baselineskip}
\end{frame}

\begin{frame}{Title} \parbox[c][16\baselineskip][s]{\textwidth}{% \tikzmark{topleft}\par \vfill \hfill\tikzmark{bottomright}}% \tikz[remember picture, overlay]{\fill[black] (pic cs:topleft) rectangle (pic cs:bottomright);} \end{frame} \end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thanks for the answer. I don't understand what your code is meant to show. – Evan Aad Dec 13 '22 at 17:39
  • 1
    This is as big a box as will fit before overlaping the bottom of the slide. It may change if you change the title etc. – John Kormylo Dec 13 '22 at 21:24
  • Where is the bottom of this box? Does it end along the top of the navigation bar? Or does the navigation bar overlap part of the black box? – Evan Aad Dec 13 '22 at 21:42
  • It does appear to be overlapping a little, assuming the icons are centered. OTOH, the icons are visible and functional. – John Kormylo Dec 13 '22 at 21:47
  • Why did you use the number 16? Where did this magical number come from? Did you simply experiment with values until you arrived at this number? And why did you multiply it my \baselineskip? What's special about \baselineskip? Could you have used any other dimensional value? – Evan Aad Dec 13 '22 at 21:48
  • 1
    Yes, 15 was too small and 17 was too big. I used \baselineskip (\ht\strutbox+\dp\strutbox) because a 1 pt increment would have taken forever. – John Kormylo Dec 13 '22 at 21:51
  • So you attempted to find the height of the white region by manual trial and error, and judging by your eyesight? – Evan Aad Dec 13 '22 at 21:55
  • 1
    I don't believe the information can be obtained any other way. See https://tex.stackexchange.com/questions/397523/tikz-based-beamer-frame – John Kormylo Dec 13 '22 at 21:59
  • And moreover you acknowledge that, with all your efforts, (a) the height you obtained is not quite right ("it does appear to be overlapping a little"), and (b) it isn't definitive ("It may change if you change the title etc.") So basically your real answer is: "I I don't believe the information can be obtained", and the rest of your answer, including the code, is a side note showing how the height can be approximately estimated for one specific slide with specific content and under a specific theme, and this with a lot of effort that can't be automated. – Evan Aad Dec 13 '22 at 22:09
  • That sums it up. If you look at the linked solution, it required replacing the title with with your own version in order to measure the height. A similar approach would be required for the navigation bar and anything else not modeled. This is because \beamer@frametextheight is not computed until after the text area is created. – John Kormylo Dec 14 '22 at 04:39
  • You wrote: "there is no way to know a priori". Is there a way to know aposteriori, but programmatically, not through trial and error? Two mechanisms I've learned about in the intervening days since you posted this answer are: (1) expl3's hook mechanism, and in particular shipout/foreground; see here, (2) beamer's templates and \addtobeamertemplate{...}{}{} command; see here. Do you think they can help? – Evan Aad Dec 18 '22 at 14:11
  • Every theme does things differently (which is probably why beamer extends the text area all the way to the bottom of the slide). – John Kormylo Dec 18 '22 at 17:10
  • I've become convinced that there is no way to programatically query the position and dimensions of the text area and of a slide's various other layout components: the header, footer, title, title's shade, and navigation bar. Therefore, manual experimentation+eyesight judgment, as demonstrated in your answer, is a viable way to find out this information. Another possibility, I guess, is to dive into the source code. In either case, it's messy. – Evan Aad Dec 25 '22 at 06:40