![无法将 tikz 正确定位在 beamer 背景上](https://linux22.com/image/457266/%E6%97%A0%E6%B3%95%E5%B0%86%20tikz%20%E6%AD%A3%E7%A1%AE%E5%AE%9A%E4%BD%8D%E5%9C%A8%20beamer%20%E8%83%8C%E6%99%AF%E4%B8%8A.png)
我正在尝试beamer
使用该pgfornaments
包制作自定义背景。尽管指定了坐标,但我似乎无法定位图像。
这是我的 MWE:
\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[sfdefault]{atkinson}
\usepackage{microtype}
\usepackage{textpos}
\usepackage{tikz}
\usepackage{pgfornament}
\beamertemplatenavigationsymbolsempty
\title{The Patience Test Study}
\author[TeX User]{TeX User}
\institute{University of Kyoto}
%%%Background
\setbeamertemplate{background}{%
\begin{tikzpicture}[remember picture, absolute]
\foreach \i in {4,5,6,...,10}
\node[] at (\i,0) {\pgfornament[width=1cm]{70}};
%
\foreach \i in {4,5,6,...,10}
\node[] at (\i,9) {\pgfornament[width=1cm]{70}};
\end{tikzpicture}
}%
%%%Titlepage
\makeatletter
\setbeamertemplate{title page}{
\centering
\vfill
\usebeamerfont{title}\inserttitle\par%
\ifx\insertsubtitle\@empty%
\else%
\vskip0.1em%
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
\fi%
\vskip-0.4em\par
\begin{tikzpicture}
\pgfornament[width=1cm]{75};
\end{tikzpicture}
\vskip0.5em\par
\usebeamerfont{author}\small\insertauthor\par
\vskip1.2em%
\usebeamerfont{institute}\insertinstitute\par
\vskip0.1em%
{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
\vskip0.1em%
{\scriptsize{\usebeamerfont{date}\insertdate}}
\vfill
}
\makeatother
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Introduction}
\framesubtitle{Basic research question}
\end{frame}
\end{document}
以下是标题页的相应输出:
在此示例中,尽管在 tikz 节点中声明了绝对坐标,但我无法将装饰物集中起来。我该如何使用此beamer
模板上的绝对位置来定位元素。
答案1
我喜欢用这个小技巧https://topanswers.xyz/tex?q=1989相对于页面定位 tikzpicture。这会将图片的原点放置在页面的南下角,您可以通过将节点从 -x 放置到 x 来对称排列节点。
\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[sfdefault]{atkinson}
\usepackage{microtype}
\usepackage{textpos}
\usepackage{tikz}
\usepackage{pgfornament}
\beamertemplatenavigationsymbolsempty
\title{The Patience Test Study}
\author[TeX User]{TeX User}
\institute{University of Kyoto}
% trick taken from https://topanswers.xyz/tex?q=1989
\tikzset{
position in page centre/.style={
shift={(current page.south)}
},
}
%%%Background
\setbeamertemplate{background}{%
\begin{tikzpicture}[remember picture,overlay,position in page centre]
\foreach \i in {-4,...,4}
\node[] at (\i,0.5) {\pgfornament[width=1cm]{70}};
%
\foreach \i in {-4,...,4}
\node[] at (\i,9) {\pgfornament[width=1cm]{70}};
\end{tikzpicture}
}%
%%%Titlepage
\makeatletter
\setbeamertemplate{title page}{
\centering
\vfill
\usebeamerfont{title}\inserttitle\par%
\ifx\insertsubtitle\@empty%
\else%
\vskip0.1em%
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
\fi%
\vskip-0.4em\par
\begin{tikzpicture}
\pgfornament[width=1cm]{75};
\end{tikzpicture}
\vskip0.5em\par
\usebeamerfont{author}\small\insertauthor\par
\vskip1.2em%
\usebeamerfont{institute}\insertinstitute\par
\vskip0.1em%
{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
\vskip0.1em%
{\scriptsize{\usebeamerfont{date}\insertdate}}
\vfill
}
\makeatother
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Introduction}
\framesubtitle{Basic research question}
\end{frame}
\end{document}