How to get \structurenumber and \structuretitle by Lua?
Hello, values of number and title of the current (sub...)section can be received by \structurenumber and \structuretitle commands. Is there a way how to get these values by Lua? Suppose: ---- \starttext \section{Sec 1} % Now "\structurenumber" yields "1" and "\structuretitle" gives "Sec 1" % How to get "1" and "Sec 1" from Lua? \startluacode print(0, context["structuretitle"]) print(1, context["structuretitle"]()) print(2, context.getvalue("structuretitle")) print(3, context.constants("structuretitle")) print(4, context.variables("structuretitle")) \stopluacode \stoptext ---- My attempts don't give any useful value (or some of them are even erroneous). I have no idea how to get the texts "1" and "Sec 1". Any hints would be appreciated... Best regards, Lukas -- Ing. Lukáš Procházka [mailto:LPr@pontex.cz] Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038
On 17-4-2012 17:13, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
Hello,
values of number and title of the current (sub...)section can be received by \structurenumber and \structuretitle commands.
Is there a way how to get these values by Lua?
structures.sections.getnumber(2) gives the number at level 2 ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hello Hans,
thanks for the idea.
Unfortunately, I'm getting error:
----
\starttext
\section{A}
\subsection{Aa}
\subsubsection{Aaa}
\startluacode
print("@@@", structures.sections.getnumber(2))
\stopluacode
\stoptext
----
"
! LuaTeX error ...TeXt/tex/texmf-context/tex/context/base/strc-doc.lua:762: attempt to index field 'references' (a nil value)
stack traceback:
...TeXt/tex/texmf-context/tex/context/base/strc-doc.lua:762: in function 'findnumber'
...TeXt/tex/texmf-context/tex/context/base/strc-doc.lua:863: in function 'getnumber'
<main ctx instance>:2: in main chunk.
"
How would I get the text? With "structures.sections.gettitle(2)"?
Best regards,
Lukas
On Tue, 17 Apr 2012 19:20:42 +0200, Hans Hagen
structures.sections.getnumber(2)
gives the number at level 2
-- Ing. Lukáš Procházka [mailto:LPr@pontex.cz] Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038
participants (2)
-
Hans Hagen
-
Procházka Lukáš Ing. - Pontex s. r. o.