答案1
您可以使用与https://topanswers.xyz/tex?q=1989定义与框架重合的坐标系:
\documentclass{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]
% showing a couple of example coordinates
\node[anchor=south west] at (0,0) {(0,0)};
\node[anchor=south east] at (1,0) {(1,0)};
\node[anchor=north west] at (0,1) {(0,1)};
\node[anchor=north east] at (1,1) {(1,1)};
\node at (0.7,0.3) {test};
\end{tikzpicture}
\end{frame}
\end{document}
答案2
您可以使用tikzpagenodes
来安装一个坐标系统,其中(0,0)
和(1,1)
分别是框架文本区域的左下角和右上角。可以\put
为此定义一个命令,但我看不出该语法比 更简单(x,y) node {<text>}
,尤其是因为后者更灵活,因为它允许您轻松添加 pgf 键。
\documentclass{beamer}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\tikzset{frameoverlay/.style={overlay,remember picture,shift={(current page text area.south west)},
x={($(current page text area.south east)-(current page text area.south west)$)},
y={($(current page text area.north west)-(current page text area.south west)$)},nodes={anchor=south west}}}
\begin{document}
\begin{frame}[t]
\frametitle{TikZ pagenodes}
\begin{tikzpicture}[frameoverlay]
\path
(0.5,0.5) node{Hello}
(0.7,0.7) node{World}
(0.2,0.1) node{Something}
(0.6,0.3) node{New};
\end{tikzpicture}
\end{frame}
\end{document}