3

I want to place a tikz node at both 75% height and width of a page roughly like this: Image with node at (0.75, 0.75)

I got the correct x position with the following code, but I am struggling to get the y position right.

\documentclass[aspectratio=169]{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{frame}
\begin{tikzpicture}[remember picture,overlay]
    \node[draw]  (1) at ($(current page.south west)!.75!(current page.south east)$) {asdf};
\end{tikzpicture}
\end{frame}

\end{document}

What are my options to chain calculations? Ideally would be a way to generate the coordinates by using the x coordinate from the calculation above and using the y coordinate from a calculation that uses current page.north and current page.south.

0

3 Answers 3

3

You could use the trick from https://topanswers.xyz/tex?q=1989 and use coordinates relative to the page:

\documentclass[aspectratio=169]{beamer}

\usepackage{tikz}

% trick taken from https://topanswers.xyz/tex?q=1989
\tikzset{
    use page relative coordinates/.style={
        shift={(current page.south west)},
        x={(current page.south east)},
        y={(current page.north west)}
    },
}

\begin{document}
    
\begin{frame}
  \begin{tikzpicture}[remember picture, overlay,use page relative coordinates]

    \node[draw] at (0.75,0.25) {Quack};

  \end{tikzpicture}
\end{frame} 
    
\end{document}

enter image description here

6

If you want the intersection between two ortogonal lines you can use the -| or |- operator:

\documentclass[aspectratio=169]{beamer}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
    
\begin{frame}
  \begin{tikzpicture}[remember picture, overlay]
% only to show the lines  
\draw[red] ($(current page.north west)!.75!(current page.south west)$) --++ (\paperwidth,0cm);
\draw[red] ($(current page.south west)!.75!(current page.south east)$) --++ (0,\paperheight);

    \node[draw] at 
     ({$(current page.north west)!.75!(current page.south west)$} %xline
      -|
      {$(current page.south west)!.75!(current page.south east)$}) %yline 
      {Quack};

  \end{tikzpicture}
\end{frame} 
    
\end{document}

enter image description here

1

You can also use xshift, yshift to set the absolute position (after setting the anchor of the node)

\documentclass{beamer}
\usepackage{tikz}


\begin{document}
\begin{tikzpicture}[overlay, remember picture]
  \node[xshift=0\paperwidth, yshift=0\paperheight]
    at (current page.south east){\fbox{foo 1}};
  \node[xshift=-.25\paperwidth, yshift=.25\paperheight]
    at (current page.south east){\fbox{foo 2}};
  \node[xshift=-.5\paperwidth, yshift=.5\paperheight]
    at (current page.south east){\fbox{foo 3}};
  \node[xshift=-.75\paperwidth, yshift=.75\paperheight]
    at (current page.south east){\fbox{foo 4}};
  \node[xshift=-1\paperwidth, yshift=1\paperheight]
    at (current page.south east){\fbox{foo 5}};
\end{tikzpicture}
\end{document}

Then you'll get:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .