如何限制幻灯片 2 上节点大小的变化?我相信这是由于下标引起的,但不知道如何解决。
\documentclass{beamer}
\usepackage{tikz}
\usepackage{calc}
\usepackage{fixltx2e}
\usetikzlibrary{positioning,calc}
\begin{document}
\newlength{\zerooffset}
\begin{frame}
\begin{tikzpicture}[overlay,remember picture]
\node[draw,minimum size=1.2cm,rectangle] at (current page.center) (s1) {p};
\onslide<1>{
\setlength{\zerooffset}{\widthof{Z\textsubscript{0}}}
\node[draw,below=1.6cm of s1,anchor=south west,text height=1cm,align=left,text width=1cm,
xshift={\dimexpr-0.5\zerooffset-\pgfkeysvalueof{/pgf/inner xsep}}] (s3) {Z\textsubscript{0}};
\draw[->,thick] let \p1=(s1.south),\p2=(s3.north) in (\x1,\y1)--(\x1,\y2);
}
\onslide<2>{
\setlength{\zerooffset}{\widthof{X}}
\node[draw,below=1.6cm of s1,anchor=south west,text height=1cm,text width=1cm,
xshift={\dimexpr-0.5\zerooffset-\pgfkeysvalueof{/pgf/inner xsep}}] (s3) {X};
\draw[->,thick] let \p1=(s1.south),\p2=(s3.north) in (\x1,\y1)--(\x1,\y2);
}
\end{tikzpicture}
\end{frame}
\end{document}
答案1
在第二个节点(节点“p”下方)的定义中,text depth=0.25cm
在其节点内容中添加或\vphantom{Z\textsubscript{0}}
。
由于您的代码对我来说不清楚,我只能建议一些小小的改进:
\documentclass{beamer}
\usepackage{tikz}
\usepackage{calc}
\usepackage{fixltx2e}
\usetikzlibrary{positioning,calc}
\begin{document}
\newlength{\zerooffset}
\begin{frame}
\begin{tikzpicture}[overlay,remember picture,
second node/.style = {%
draw,
text height=1cm, text depth=0.25mm, text width=1cm,
align=left, anchor=south west}
]
\node[draw,minimum size=1.2cm] at (current page.center) (s1) {p};
\onslide<1>{
\setlength{\zerooffset}{\widthof{Z\textsubscript{0}}}
\node[second node,below=1.6cm of s1,
xshift={\dimexpr-0.5\zerooffset-\pgfkeysvalueof{/pgf/inner xsep}}] (s3) {Z\textsubscript{0}};
\draw[->,thick] let \p1=(s1.south),\p2=(s3.north) in (\x1,\y1)--(\x1,\y2);
}
\onslide<2>{
\setlength{\zerooffset}{\widthof{X}}
\node[second node,below=1.6cm of s1,
xshift={\dimexpr-0.5\zerooffset-\pgfkeysvalueof{/pgf/inner xsep}}] (s3) {X};
\draw[->,thick] let \p1=(s1.south),\p2=(s3.north) in (\x1,\y1)--(\x1,\y2);
}
\end{tikzpicture}
\end{frame}
\end{document}