ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to get \structurenumber and \structuretitle by Lua?
@ 2012-04-17 15:13 Procházka Lukáš Ing. - Pontex s. r. o.
  2012-04-17 17:20 ` Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-04-17 15:13 UTC (permalink / raw)
  To: ConTeXt

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

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to get \structurenumber and \structuretitle by Lua?
  2012-04-17 15:13 How to get \structurenumber and \structuretitle by Lua? Procházka Lukáš Ing. - Pontex s. r. o.
@ 2012-04-17 17:20 ` Hans Hagen
  2012-04-18  8:03   ` Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2012-04-17 17:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
-----------------------------------------------------------------
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to get \structurenumber and \structuretitle by Lua?
  2012-04-17 17:20 ` Hans Hagen
@ 2012-04-18  8:03   ` Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 0 replies; 3+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-04-18  8:03 UTC (permalink / raw)
  To: ConTeXt; +Cc: pragma@wxs.nl (Hans Hagen)

[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]

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 <pragma@wxs.nl> wrote:

> 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

[-- Attachment #2: t-CurSec2.log --]
[-- Type: application/octet-stream, Size: 13967 bytes --]

(C:/Lukas/Jobs/D5-035.Zat/A-PruvZpr/Test/t-CurSec2.mkiv

ConTeXt  ver: 2012.04.07 14:42 MKIV  fmt: 2012.4.9  int: english/english

system          > cont-new.mkiv loaded
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-new.mkiv
system          > beware: some patches loaded from cont-new.mkiv
)
system          > t-CurSec2.top loaded

system          > options > start used options

used options    > % runtime options files (command line driven)
used options    > \unprotect
used options    > % feedback and basic job control
used options    > \nonstopmode
used options    > % handy for special styles
used options    > \startluacode
used options    > document = document or { }
used options    > document.arguments={
used options    >  ["FILE"]="t-CurSec2.mkiv",
used options    >  ["halt-on-error"]=true,
used options    >  ["mode"]="t-CurSec2",
used options    >  ["nonstopmode"]=true,
used options    > }
used options    > document.files={
used options    >  "C:/Lukas/Jobs/D5-035.Zat/A-PruvZpr/Test/t-CurSec2.mkiv",
used options    > }
used options    > \stopluacode
used options    > % process info
used options    > \setupsystem[inputfile=C:/Lukas/Jobs/D5-035.Zat/A-PruvZpr/Test/t-CurSec2.mkiv]
used options    > \setupsystem[\c!n=1,\c!m=1]
used options    > % modes
used options    > \enablemode[t-CurSec2]
used options    > % options (not that important)
used options    > \startsetups *runtime:options
used options    > \stopsetups
used options    > % styles and modules
used options    > \startsetups *runtime:modules
used options    > \stopsetups
used options    > % done
used options    > \protect \endinput

system          > options > stop used options

(t-CurSec2.top
)
fonts           > latin modern fonts are not preloaded
languages       > language en is active
{c:/ConTeXt/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map}
fonts           > preloading latin modern fonts (second stage)
fonts           > typescripts > unknown: library 'loc'
{c:/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-math.map}{c:/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-rm.map}
fonts           > virtual math > unable to resolve name mapsfromchar
fonts           > fallback modern rm 12pt is loaded
structure       > sectioning > section @ level 3 : 0.0.1 -> A
structure       > sectioning > subsection @ level 4 : 0.0.1.1 -> Aa
structure       > sectioning > subsubsection @ level 5 : 0.0.1.1.1 -> Aaa
! 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.

system          > tex > error on line 10 in file C:/Lukas/Jobs/D5-035.Zat/A-PruvZpr/Test/t-CurSec2.mkiv: LuaTeX error  ...

 1     %\directlua{require "LPr-U"}
 2     
 3     \starttext
 4       \section{A}
 5         \subsection{Aa}
 6           \subsubsection{Aaa}
 7     
 8             \startluacode
 9                 print("@@@", structures.sections.getnumber(2))
10 >>          \stopluacode
11     \stoptext
12     

<inserted text> ...ections.getnumber(2))\r        }
                                                  
\luat_start_lua_code_indeed ...ua \zerocount {#1}}
                                                  
l.10         \stopluacode
                         
The lua interpreter ran into a problem, so the
remainder of this lua chunk will be ignored.

backend         > xmp > using file 'c:/ConTeXt/tex/texmf-context/tex/context/base/lpdf-pdx.xml'
pages           > flushing realpage 1, userpage 1
 )<c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman10-regular.otf><c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman12-regular.otf>

system          > files > start used files

used files      >    1: filename=C:/Lukas/Jobs/D5-035.Zat/A-PruvZpr/Test/t-CurSec2.mkiv | foundname=C:/Lukas/Jobs/D5-035.Zat/A-PruvZpr/Test/t-CurSec2.mkiv | usedmethod=direct
used files      >    2: filename=cont-new.mkiv | filetype=tex | foundname=c:/ConTeXt/tex/texmf-context/tex/context/base/cont-new.mkiv | usedmethod=otherwise
used files      >    3: filename=t-CurSec2.top | foundname=t-CurSec2.top | usedmethod=direct
used files      >    4: filename=lang-us.lua | filetype=lua | foundname=c:/ConTeXt/tex/texmf-context/tex/context/patterns/lang-us.lua | usedmethod=otherwise
used files      >    5: filename=mkiv-base.map | filetype=map | format=map | foundname=c:/ConTeXt/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map | usedmethod=otherwise
used files      >    6: filename=lm.lfg | filetype=tex | foundname=c:/ConTeXt/tex/texmf-context/tex/context/fonts/lm.lfg | usedmethod=otherwise
used files      >    7: filename=lm-math.lfg | filetype=tex | foundname=c:/ConTeXt/tex/texmf-context/tex/context/fonts/lm-math.lfg | usedmethod=otherwise
used files      >    8: filename=lm-math.map | filetype=map | format=map | foundname=c:/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-math.map | usedmethod=otherwise
used files      >    9: filename=lm-rm.map | filetype=map | format=map | foundname=c:/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-rm.map | usedmethod=otherwise
used files      >   10: filename=lmroman12-regular | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman12-regular.otf | usedmethod=otherwise
used files      >   11: filename=lmroman7-regular.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman7-regular.otf | usedmethod=otherwise
used files      >   12: filename=rm-lmr7.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/rm-lmr7.tfm | usedmethod=otherwise
used files      >   13: filename=lmmi7.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/lmmi7.tfm | usedmethod=otherwise
used files      >   14: filename=lmsy7.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/lmsy7.tfm | usedmethod=otherwise
used files      >   15: filename=lmex10.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/lmex10.tfm | usedmethod=otherwise
used files      >   16: filename=msam7.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/amsfonts/symbols/msam7.tfm | usedmethod=otherwise
used files      >   17: filename=msbm7.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/amsfonts/symbols/msbm7.tfm | usedmethod=otherwise
used files      >   18: filename=stmary10.afm | filetype=afm | format=afm | foundname=c:/ConTeXt/tex/texmf/fonts/afm/public/stmaryrd/stmary10.afm | usedmethod=otherwise
used files      >   19: filename=stmary10.pfb | filetype=pfb | format=pfb | foundname=c:/ConTeXt/tex/texmf/fonts/type1/public/stmaryrd/stmary10.pfb | usedmethod=otherwise
used files      >   20: filename=lmroman7-bold.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman7-bold.otf | usedmethod=otherwise
used files      >   21: filename=lmmib7.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/lmmib7.tfm | usedmethod=otherwise
used files      >   22: filename=lmsans8-regular.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmsans8-regular.otf | usedmethod=otherwise
used files      >   23: filename=lmmono8-regular.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmmono8-regular.otf | usedmethod=otherwise
used files      >   24: filename=eufm7.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/amsfonts/euler/eufm7.tfm | usedmethod=otherwise
used files      >   25: filename=eufb7.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/amsfonts/euler/eufb7.tfm | usedmethod=otherwise
used files      >   26: filename=lmroman9-regular.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman9-regular.otf | usedmethod=otherwise
used files      >   27: filename=rm-lmr9.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/rm-lmr9.tfm | usedmethod=otherwise
used files      >   28: filename=lmmi9.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/lmmi9.tfm | usedmethod=otherwise
used files      >   29: filename=lmsy9.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/lmsy9.tfm | usedmethod=otherwise
used files      >   30: filename=msam10.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/amsfonts/symbols/msam10.tfm | usedmethod=otherwise
used files      >   31: filename=msbm10.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/amsfonts/symbols/msbm10.tfm | usedmethod=otherwise
used files      >   32: filename=lmroman9-bold.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman9-bold.otf | usedmethod=otherwise
used files      >   33: filename=lmmib10.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/lmmib10.tfm | usedmethod=otherwise
used files      >   34: filename=lmsans9-regular.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmsans9-regular.otf | usedmethod=otherwise
used files      >   35: filename=lmmono9-regular.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmmono9-regular.otf | usedmethod=otherwise
used files      >   36: filename=eufm10.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/amsfonts/euler/eufm10.tfm | usedmethod=otherwise
used files      >   37: filename=eufb10.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/amsfonts/euler/eufb10.tfm | usedmethod=otherwise
used files      >   38: filename=lmroman12-regular.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman12-regular.otf | usedmethod=otherwise
used files      >   39: filename=rm-lmr12.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/rm-lmr12.tfm | usedmethod=otherwise
used files      >   40: filename=lmmi12.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/lmmi12.tfm | usedmethod=otherwise
used files      >   41: filename=lmsy10.tfm | filetype=tfm | format=tfm | foundname=c:/ConTeXt/tex/texmf/fonts/tfm/public/lm/lmsy10.tfm | usedmethod=otherwise
used files      >   42: filename=lmroman12-bold.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman12-bold.otf | usedmethod=otherwise
used files      >   43: filename=lmsans12-regular.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmsans12-regular.otf | usedmethod=otherwise
used files      >   44: filename=lmmono12-regular.otf | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmmono12-regular.otf | usedmethod=otherwise
used files      >   45: filename=lmroman10-regular | filetype=otf | format=otf | foundname=c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman10-regular.otf | usedmethod=otherwise
used files      >   46: filename=lpdf-pdx.xml | filetype=tex | foundname=c:/ConTeXt/tex/texmf-context/tex/context/base/lpdf-pdx.xml | usedmethod=otherwise

system          > files > stop used files


system          > structure > start used structure

used structure  > text: t-CurSec2

system          > structure > stop used structure


mkiv lua stats  > used config file          - selfautoparent:texmf/web2c/texmfcnf.lua
mkiv lua stats  > used cache path           - c:/ConTeXt/tex/texmf-cache/luatex-cache/context/2448223e6631addb83df348d74153606
mkiv lua stats  > resource resolver         - loadtime 0.063 seconds, 2 scans with scantime 0.031 seconds, 0 shared scans, 46 found files, scanned paths: C:/Lukas/ConTeXt/Fonts c:/windows/fonts
mkiv lua stats  > stored bytecode data      - 302 modules, 65 tables, 367 chunks
mkiv lua stats  > cleaned up reserved nodes - 39 nodes, 9 lists of 436
mkiv lua stats  > node memory usage         - 2 glue, 2 penalty, 12 attribute, 28 glue_spec, 3 attribute_list
mkiv lua stats  > node list callback tasks  - 6 unique task lists, 5 instances (re)created, 175 calls
mkiv lua stats  > used backend              - pdf (backend for directly generating pdf output)
mkiv lua stats  > loaded patterns           - en::2
mkiv lua stats  > jobdata time              - 0.000 seconds saving, 0.000 seconds loading
mkiv lua stats  > callbacks                 - 314 direct, 570 indirect, 884 total
mkiv lua stats  > lxml preparation time     - 0.000 seconds, 0 nodes, 11 lpath calls, 0 cached calls
mkiv lua stats  > result saved in file      - t-CurSec2.pdf
mkiv lua stats  > loaded fonts              - 34 files: stmary10.afm lmmono12-regular.otf lmmono8-regular.otf lmmono9-regular.otf lmroman10-regular.otf lmroman12-bold.otf lmroman12-regular.otf lmroman7-bold.otf lmroman7-regular.otf lmroman9-bold.otf lmroman9-regular.otf lmsans12-regular.otf lmsans8-regular.otf lmsans9-regular.otf eufb10.tfm eufb7.tfm eufm10.tfm eufm7.tfm msam10.tfm msam7.tfm msbm10.tfm msbm7.tfm lmex10.tfm lmmi12.tfm lmmi7.tfm lmmi9.tfm lmmib10.tfm lmmib7.tfm lmsy10.tfm lmsy7.tfm lmsy9.tfm rm-lmr12.tfm rm-lmr7.tfm rm-lmr9.tfm
mkiv lua stats  > fonts load time           - 0.500 seconds 
mkiv lua stats  > luatex banner             - this is luatex, version beta-0.70.1-2012032923 (tex live 2012)
mkiv lua stats  > control sequences         - 33337 of 65536 + 100000
mkiv lua stats  > current memory usage      - 35 MB (ctx: 36 MB)
mkiv lua stats  > runtime                   - 1.297 seconds, 1 processed pages, 1 shipped pages, 0.771 pages/second


[-- Attachment #3: t-CurSec2.mkiv --]
[-- Type: application/octet-stream, Size: 225 bytes --]

%\directlua{require "LPr-U"}

\starttext
  \section{A}
    \subsection{Aa}
      \subsubsection{Aaa}

        \startluacode
            print("@@@", structures.sections.getnumber(2))
        \stopluacode
\stoptext

[-- Attachment #4: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-18  8:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-17 15:13 How to get \structurenumber and \structuretitle by Lua? Procházka Lukáš Ing. - Pontex s. r. o.
2012-04-17 17:20 ` Hans Hagen
2012-04-18  8:03   ` Procházka Lukáš Ing. - Pontex s. r. o.

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).