![tikz/pgf:路径的绝对定位](https://linux22.com/image/347643/tikz%2Fpgf%EF%BC%9A%E8%B7%AF%E5%BE%84%E7%9A%84%E7%BB%9D%E5%AF%B9%E5%AE%9A%E4%BD%8D.png)
我没有采取回答在框架上绝对定位路径beamer
。我实际的代码项目中的路径是在外部软件中生成的,非常复杂 - 我无法更改坐标。
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
% Taken from https://tex.stackexchange.com/questions/348392/
\begin{tikzpicture}[remember picture,overlay]
\useasboundingbox (current page.north west) rectangle (current page.south east);
% Position the center of the following drawing at (.5\paperwidth,.5\paperheight)
\path[
draw = blue,
line width = 2pt
] (0,0) -- (1,2) -- (2,2) -- cycle;
\end{tikzpicture}
% Indicate the actual center
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {Center};
\end{tikzpicture}
\end{frame}
\end{document}
答案1
可能不太正确,但如果您接受路径的中心是其边界框的中心,它似乎可以工作。
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {Center};
\node[anchor=center, draw] at (current page.center) {%
\begin{tikzpicture}[baseline=(current bounding box.center)]
\path[
draw = blue,
line width = 2pt
] (0,0) -- (1,2) -- (2,2) -- cycle;
\end{tikzpicture}%
};
\end{tikzpicture}
\end{frame}
\end{document}
如果你不想嵌套 tikzpictures,复杂的路径可以绘制为一个standalone
文档,可以插入到node
里面\includegraphics
:
%ComplexPath.tex
\documentclass[tikz, border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path[
draw = blue,
line width = 2pt
] (0,0) -- (1,2) -- (2,2) -- cycle;
\end{tikzpicture}
\end{document}
生成(具有透明背景):
可将其包含在主文档中:
%Main document
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {Center};
\node at (current page.center) {\includegraphics{ComplexPath}};
\end{tikzpicture}
\end{frame}
\end{document}