0

Comment the 2 lines alternativelly, one works the other doesn't :

\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}

It is possible to make the \directlua command part to work, but hen one can't change the value :

\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
  • /.initial and /.code (or one of its relatives) can be used to bind to a key both a value and some code, respectively. See the doc for /.initial. Jul 8, 2022 at 5:23

1 Answer 1

2

Looks like the issue is that .store in and .code cannot be used at the same time. (because store in is also a code, so the second one overrides the first one, I think? What is the fundamental difference between .store in and .code in pgfkeys)

Either way, you can do the "store in" manually inside the "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}
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .