On Friday, February 7, 2014, at 18:12 Wolfgang Schuster wrote:



Am 07.02.2014 um 15:45 schrieb Andreas Schneider <aksdb@gmx.de>:

Dynamic headings & query heading information
2) another macro should build an index at the end of the document. I use Lua to keep a list of all database tables referenced within the document (together with some metadata) and save it in the jobpasses struct. Now I also want to track the chapters, sections, etc where these references are, to be able to see, where a database table is used.

To solve these two problems, I'm looking for information about the current heading. The level and the associated reference name.
If I have the level, I can keep my own list of necessary heading types (subject, subsubject, ...) and just get the one at level+1 to write the heading using lua (tex.sprint(....)).
With the reference name I can obviously solve 2), since I then can simply keep a list for each db table in the jobpasses structure.
You can try the \currentstrcuture… commands but I don’t know if the are meant as user level commands.

\starttext

\chapter{Chapter}

\starttabulate
\NC Name  \EQ \currentstructurename  \NC\NR
\NC Level \EQ \currentstructurelevel \NC\NR
\stoptabulate

\section{Section}

\starttabulate
\NC Name  \EQ \currentstructurename  \NC\NR
\NC Level \EQ \currentstructurelevel \NC\NR
\stoptabulate

\stoptext

Wolfgang



In case I haven't told you before: you are awesome!

This is exactly what I was looking for. Due to this I also found \currentstructurereference and a bunch of other commands :)
Once you know that "structure" is the keyword, "strc-sec.*" is just around the corner.

Regarding your earlier mail (\definesectionlevels ...):
Wow, there is really a lot of "hidden" functionality in ConTeXt. If you lay out the document with these commands from the beginning, that really eases restructuring tasks. However the readability (of the source code) slightly falls off. I will evaluate this further. Thanks for this too :-)

--
Best Regards,
Andreas