我有以下投影仪框架,它有两个矩阵,一个有 4 列,另一个有 3 列。第一个按预期逐列显示,但第二个不是。具体来说,对于第二个,我有类似visible on=<\the\pgfmatrixcurrentcolumn+4->
和向下路径的东西node[visible on=<\col+4->]
,但这些似乎不起作用。我如何确保第二个矩阵在第一个矩阵之后也逐列显示?
\documentclass[xcolor=table,10pt,aspectratio=169]{beamer}
\usetheme{metropolis}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usepackage{tikzpeople}
\usepackage[beamer,customcolors]{hf-tikz}
\usetikzlibrary{
arrows,
automata,
backgrounds,
calc,
chains,
decorations,
decorations.text,
decorations.pathreplacing,
decorations.pathmorphing,
external,
matrix,
overlay-beamer-styles,
patterns,
positioning,
ext.node-families,
shapes,
tikzmark,shadows.blur,fit
}
\DeclareMathOperator{\Enc} {Enc} % instead of \mathsf{Enc}
\DeclareMathOperator{\PKey} {PKey}
\DeclareMathOperator{\Sim} {Sim}
\DeclareMathOperator{\Prover}{Prover}
\begin{document}
\begin{frame}{Intuition}
\begin{center}
\scriptsize
\only<1-4>{
\begin{tikzpicture}
\matrix (m) [
nodes={draw=\bcol, fill=\fcol, rounded corners,
node family/width=samewidth,
visible on=<\the\pgfmatrixcurrentcolumn-4>},
matrix of math nodes,
ampersand replacement = \&,
row sep=.1cm,
column sep=.2cm] {
\begin{alignedat}{3} c_0 & \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
c_1 & \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_0) \\
\pi_{t^*} & \gets \Prover(t^*, x, w) \end{alignedat}
\&
\begin{alignedat}{3} c_0 & \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
c_1 & \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_0) \\
\pi_{t^*} & \gets \textcolor{blue}{\Sim(t^*, x)} \end{alignedat}
\&
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, \textcolor{blue}{m_1}) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\&
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_1) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\\
\& \& \&
\mathsf{sk}_{f, t} = iO(\text{PKey}[\textcolor{blue}{\mathsf{sk}_1^{\mathsf{PKE}}}, t])
\\
};
\path[nodes={align=center, above}]
foreach \Text[count=\col from 2] in {
SSS-NIZK\\$\approx_c$, IND-CPA-PKE\\$\approx_c$, iO\\$\approx_c$} {
(m-1-\pgfinteval{\col-1}.north east)
-- node[visible on=<\col->] {\Text} (m-1-\col.north west)
};
\end{tikzpicture}
}
\only<5-7>{
\begin{tikzpicture}
\matrix (m) [
nodes={draw=\bcol, fill=\fcol, rounded corners,
node family/width=samewidth,
visible on=<\the\pgfmatrixcurrentcolumn+4->},
matrix of math nodes,
ampersand replacement = \&,
row sep=.1cm,
column sep=.2cm] {
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_1) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\&
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_1) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\&
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, \textcolor{blue}{m_1}) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_1) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\\
\mathsf{sk}_{f, t} = iO(\text{PKey}[\mathsf{sk}_1^{\mathsf{PKE}}, t])
\&
\mathsf{sk}_{f, t} = iO(\text{PKey}[\mathsf{sk}_1^{\mathsf{PKE}}, t])
\&
\mathsf{sk}_{f, t} = iO(\text{PKey}[\mathsf{sk}_1^{\mathsf{PKE}}, t])
\\
\Delta_{t \to t'} = piO(\text{PUpdate}[\mathsf{sk}_0^{\mathsf{PKE}}, t, t'])
\&
\Delta_{t \to t'} = piO(\text{PUpdate}[\textcolor{blue}{\mathsf{sk}_1^{\mathsf{PKE}}}, t, t'])
\&
\Delta_{t \to t'} = piO(\text{PUpdate}[\mathsf{sk}_0^{\mathsf{PKE}}, t, t'])
\\
};
\path[nodes={align=center, above}]
foreach \Text[count=\col from 2] in {
piO\\$\approx_c$, IND-CPA-PKE\\$\approx_c$} {
(m-1-\pgfinteval{\col-1}.north east)
-- node[visible on=<\col+4->] {\Text} (m-1-\col.north west)
};
\end{tikzpicture}
}
\end{center}
\end{frame}
\end{document}
答案1
您需要使此加法的结果可用,beamer
以便它直接拥有一个整数。
我们可以随意\pgfmathparse{int(\pgfmatrixcurrentcolumn+4)}
使用,\pgfmathresult
但那没有必要。
对于整数运算,可以使用
纯 eTeX
\numexpr
visible on=<\the\numexpr\pgfmatrixcurrentcolumn+4\relax->
最新的 LaTeX
\inteval
visible on=<\inteval{\pgfmatrixcurrentcolumn+4}->
PGF 自己的间隔(未记录)
visible on=<\pgfinteval{\pgfmatrixcurrentcolumn+4}->
当然,我会建议一种额外的风格,以便于指定:
\tikzset{
column visible from/.style={
visible on=<\pgfinteval{\pgfmatrixcurrentcolumn+#1}->},
column visible from/.default=0
}
这允许您在第二张图片中指定column visible from = 4
(5、6、…)。如果没有值,0
则将使用该值并体验第一张图片的行为。
对于节点之间的节点,我没有一个很好的解决方案,这里我使用
visible on=<\pgfinteval{\col+4}->
再次。
代码
\documentclass[xcolor=table,10pt,aspectratio=169]{beamer}
\usetheme{metropolis}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{tikz}
\usepackage[beamer,customcolors]{hf-tikz}
\usetikzlibrary{
matrix,
overlay-beamer-styles,
ext.node-families,
shapes,
}
\DeclareMathOperator{\Enc} {Enc} % instead of \mathsf{Enc}
\DeclareMathOperator{\PKey} {PKey}
\DeclareMathOperator{\Sim} {Sim}
\DeclareMathOperator{\Prover}{Prover}
\tikzset{
column visible from/.style={
visible on=<\pgfinteval{\pgfmatrixcurrentcolumn+#1}->},
column visible from/.default=0
}
\begin{document}
\begin{frame}{Intuition}
\begin{center}
\scriptsize
\only<1-4>{
\begin{tikzpicture}
\matrix (m) [
nodes={draw=\bcol, fill=\fcol, rounded corners,
node family/width=samewidth,
column visible from},
matrix of math nodes,
ampersand replacement = \&,
row sep=.1cm,
column sep=.2cm] {
\begin{alignedat}{3} c_0 & \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
c_1 & \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_0) \\
\pi_{t^*} & \gets \Prover(t^*, x, w) \end{alignedat}
\&
\begin{alignedat}{3} c_0 & \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
c_1 & \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_0) \\
\pi_{t^*} & \gets \textcolor{blue}{\Sim(t^*, x)} \end{alignedat}
\&
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, \textcolor{blue}{m_1}) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\&
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_1) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\\
\& \& \&
\mathsf{sk}_{f, t} = iO(\text{PKey}[\textcolor{blue}{\mathsf{sk}_1^{\mathsf{PKE}}}, t])
\\
};
\path[nodes={align=center, above}]
foreach \Text[count=\col from 2] in {
SSS-NIZK\\$\approx_c$, IND-CPA-PKE\\$\approx_c$, iO\\$\approx_c$} {
(m-1-\pgfinteval{\col-1}.north east)
-- node[visible on=<\col->] {\Text} (m-1-\col.north west)
};
\end{tikzpicture}
}
\only<5-7>{
\begin{tikzpicture}
\matrix (m) [
nodes={draw=\bcol, fill=\fcol, rounded corners,
node family/width=samewidth,
column visible from=4},
matrix of math nodes,
ampersand replacement = \&,
row sep=.1cm,
column sep=.2cm] {
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_1) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\&
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, m_0) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_1) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\&
\begin{alignedat}{3} & c_0 && \gets \Enc(\PKey_0^{\mathsf{PKE}}, \textcolor{blue}{m_1}) \\
& c_1 && \gets \Enc(\PKey_1^{\mathsf{PKE}}, m_1) \\
& \pi_{t^*} && \gets \Sim(t^*, x) \end{alignedat}
\\
\mathsf{sk}_{f, t} = iO(\text{PKey}[\mathsf{sk}_1^{\mathsf{PKE}}, t])
\&
\mathsf{sk}_{f, t} = iO(\text{PKey}[\mathsf{sk}_1^{\mathsf{PKE}}, t])
\&
\mathsf{sk}_{f, t} = iO(\text{PKey}[\mathsf{sk}_1^{\mathsf{PKE}}, t])
\\
\Delta_{t \to t'} = piO(\text{PUpdate}[\mathsf{sk}_0^{\mathsf{PKE}}, t, t'])
\&
\Delta_{t \to t'} = piO(\text{PUpdate}[\textcolor{blue}{\mathsf{sk}_1^{\mathsf{PKE}}}, t, t'])
\&
\Delta_{t \to t'} = piO(\text{PUpdate}[\mathsf{sk}_0^{\mathsf{PKE}}, t, t'])
\\
};
\path[nodes={align=center, above}]
foreach \Text[count=\col from 2] in {
piO\\$\approx_c$, IND-CPA-PKE\\$\approx_c$} {
(m-1-\pgfinteval{\col-1}.north east)
-- node[visible on=<\pgfinteval{\col+4}->] {\Text} (m-1-\col.north west)
};
\end{tikzpicture}
}
\end{center}
\end{frame}
\end{document}