交替注释这两行,一行有效,另一行无效:
\documentclass{beamer}
\begin{document}
\pgfkeys{/Baq/.cd ,
nb/.default = 10,
nb/.store in = \nb,
nb,
contraintes/.default = 5,
contraintes/.store in = \contraintes,
% Comment alternativelly
contraintes/.code={\directlua{contraintes = \contraintes }} ,
contraintes
}
\newcommand{\Contraintes}[1][contraintes = 6]{%
\pgfkeys{/Baq/.cd , #1 }
\directlua{
% Comment alternativelly
% contraintes = \contraintes
nb = \nb
tex. print ( "Coucou :" , \nb , \contraintes )
}
}
\begin{frame}
\Contraintes
\end{frame}
\end{document}
可以使\directlua
命令部分工作,但是无法改变值:
\documentclass{beamer}
\begin{document}
\pgfkeys{/Baq/.cd ,
contraintes/.store in = \contraintes,
contraintes = 5,
contraintes/.code={\directlua{contraintes = \contraintes }} ,
}
\newcommand{\Contraintes}[1][contraintes = 6]{%
\pgfkeys{/Baq/.cd , #1 }
\directlua{
tex. print ( "Coucou :" , \contraintes )
}
}
\begin{frame}
\Contraintes
\end{frame}
\end{document}
答案1
看起来问题是.store in
和.code
不能同时使用。(因为store in
也是code
,所以我认为第二个会覆盖第一个?)pgfkeys 中的 .store 和 .code 之间的根本区别是什么)
无论哪种方式,您都可以在“代码”中手动执行“存储”:
\documentclass{beamer}
\begin{document}
\pgfkeys{/Baq/.cd ,
nb/.default = 10,
nb/.store in = \nb,
nb,
contraintes/.default = 5,
contraintes/.code={\def\contraintes{#1}\directlua{contraintes = \contraintes}} ,
contraintes
}
\newcommand{\Contraintes}[1][contraintes = 6]{%
\pgfkeys{/Baq/.cd , #1 }
\directlua{
nb = \nb
tex. print ( "Coucou :" , \nb , \contraintes )
}
}
\begin{frame}
\Contraintes
\end{frame}
\end{document}