In LaTeX I often use pythontex
in a way that there is a block \begin{pycode}[sessionname]
... \end{pycode}
where I make some calculations. Then in the following text I refer to variables defined there for example via \py[sessionname]{Variable}
.
Now I can make a yas-snippet that expands for example py
to \py[]{}
. But then I have to manually insert the session name.
So how can I make a snipped which looks backwards and automatically inserts the session name of the previous pycode
environment while expanding py
?
If there is another snipped package which can do this, I am interested in it too.