[luatex] Accessing pgf nodes from inside Lua(La)Tex

Keith J. Schultz schultzk at gmx.net
Tue Jun 19 12:49:37 CEST 2012

HI Paul,

You have helped understand a few things and not in the documentation.

Actually, I do not want to use TeX macros.
I am looking for a way to access the structures of the nodes defined
through pgf. 

I was hoping to find a way to access them from lua.

so instead of:  

in lua something like:
	local Y = getx(get_anchor(<pgfNodeName>, "south")

What you have shown me I might be able to go into the sources of pgf and
find a way to extract the data I want. But, I do not have the time to go that route.


Am 19.06.2012 um 08:45 schrieb Paul Isambert:

> "Keith J. Schultz" <schultzk at uni-trier.de> a écrit:
>> Hi All,
>> I am writing a package with pgf/TikZ from making Nassi-Schneider diagramms.
>> I have the code working under XeLaTeX and wanted to refracture it to LuaTeX.
>> I have to admit that I am not very TeXian. 
>> My question is if I have the name of a pgf node how do I get at its coordinates from
>> within LuaTeX.
>> Or, is there a way to call pgf from directly inside LuaTeX.
>> What I am looking for is to have a LuaTeX call to get the coordinates.
>> The following code that I have is: 
>> 	\pgfextracty{\YCoordinate}{\pgfpointanchor{\LastNode}{south}}
>> 	where \LastNode is the Name of the pgf node and \YCoordinate is a dimension.
>> So my do I access pgf structures from in LuaTeX?
>> Any help or pointers would be appreciated.
> I don't think PGF has any Lua interface, but I might be wrong here.
>> It would help me, also, if someone could tell me how to access something I have defined
>> with \edef in LuaTeX
>> eg. 
>> in the TeX file 
>> \edef{\aValue}{tttt}
>> in a loaded .lua file
>> function get_my_value(NameValue)
>> 	local a = <some in Lua to access the edef>(NameValue)
>> 	return a
>> end
> You can't do that, really. You may devise a complex system of
> \directlua/tex.print calls, but I have some doubts it'll work.
> Instead, you can use token lists:
>    \edef\aValue{tttt}
>    \mytok\expandafter{\aValue}
> and in Lua:
>    function get_my_value (name)
>      local a = tex.toks.mytok
>      return a
>    end
> Otherwise, if you really need a TeX macro (not a token list), you can
> try:
>    \directlua{ mymacros = {} }
>    \def\gobble#1{}
>    \def\Def#1#2{%
>      \edef#1{#2}%
>      \directlua{%
>        mymacros["\expandafter\gobble\string#1"] =
>          "\luaescapestring{#2}" }%
>      }
> then
>    \Def\aValue{tttt}
> defines \aValue as before and makes its replacement text available in
> Lua as "mymacros.aValue". Admittedly suboptimal...
> Best,
> Paul

More information about the luatex mailing list