From: Oliver von Criegern <oliver.v.criegern@badw-muenchen.de>
To: ntg-context@ntg.nl
Subject: Cross-reference expansion with ConTeXt and processing with LuaTeX
Date: Wed, 4 Sep 2019 19:37:51 +0200 [thread overview]
Message-ID: <744a214b-2694-1c99-ff73-b1a5f2d0ac29@badw-muenchen.de> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1537 bytes --]
Dear list members,
I want to process cross-references in ConTeXt/LuaTeX, that is, to do
some calculations in Lua with the page and line numbers returned by the
\at and \inlinerange commands.
But this does not work, as these commands are obviously not being
expanded before they are passed to Lua.
Here is a minimal example:
|\setupreferencing[state=start]||\definenumber[test]\setnumber[test][5]\startluacodefunction
TestVar(var)print('VARIABLE: ')print(var)tex.print(var)end
\stopluacode\def\TestLua#1{\ctxlua{TestVar([==[#1]==])}}% Cf.
https://www.contextgarden.net/Programming_in_LuaTeX\startbuffer[testtext]\dorecurse{100}{Words,
words, words. }\stopbuffer\starttext\startlinenumberingCounter:
\TestLua{\rawcountervalue[test]}\par% The counter is expanded before
being passed to Lua.Lineref: \TestLua{\inlinerange[1]}\par% The line
reference is not expanded before being passed to
Lua.\getbuffer[testtext]\someline[1]LABEL 1 \stoplinenumbering\stoptext|||
\TestLua just passes the argument to the Lua command TestVar, which
prints it to stdout and returns it to TeX. The pdf result looks good at
first glance, showing the correct values as expected, but in stdout we read:
|VARIABLE: 5 VARIABLE: \inlinerange[1] |||
The line reference obviously has not been expanded before but only after
having been passed to the Lua command. Accordingly, when trying to
perform mathematical calculations on it in Lua, there will be an error.
So how can I pass the value of my reference to Lua?
Best regards,
Oliver
||
[-- Attachment #1.2: Type: text/html, Size: 5089 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next reply other threads:[~2019-09-04 17:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-04 17:37 Oliver von Criegern [this message]
2019-09-05 12:41 ` Hans Hagen
2019-09-06 14:26 ` Oliver von Criegern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=744a214b-2694-1c99-ff73-b1a5f2d0ac29@badw-muenchen.de \
--to=oliver.v.criegern@badw-muenchen.de \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).