8

Background

Looking to include the section within an index.

Problem

In LaTeX the nameref package allows coding a contextual macro called \currentname. This allows users to refer to the current section (or chapter, or part) without needing to type it in explicitly.

Ultimately, I'd like to include the current name in the index. For example:

\starttext

\placeindex
\page [yes]

\startchapter[title={Title1},]
\index{item+\currentchaptername}
\input knuth
\stopchapter

\startchapter[title={Title2},]
\index{item+\currentchaptername}
\input knuth
\stopchapter

\stoptext

Being able to reference the chapter title indirectly has other uses than the one given above.

Question

What is the equivalent to \currentname in ConTeXt?

Ideas

I have tried: \the\chapter, \show\thechapter, \thechapter, \currentchaptername, etc. I have also looked at \nameref{marker}, but that, even if it worked, seems like an obtuse solution.

Related

Some related information:

2 Answers 2

9

The following variables give information about the current section (from strc-sec.mkiv):

   \xdef\currentstructurename           {\structureparameter\c!name}%
   \xdef\currentstructurecoupling       {\structureparameter\c!coupling}%
   \xdef\currentstructureownnumber      {\structureparameter\c!ownnumber}% optional own number
   \xdef\currentstructurelevel          {\structureparameter\c!level}%
   \edef\currentstructureexpansion      {\structureparameter\c!expansion}%
   \xdef\currentstructurexmlsetup       {\structureparameter\c!xmlsetup}%
   \xdef\currentstructurecatcodes       {\structureparameter\s!catcodes}%
   \xdef\currentstructurelabel          {\structureparameter\c!label}%
   \xdef\currentstructurereference      {\structureparameter\c!reference}%
   \xdef\currentstructurereferenceprefix{\structureparameter\c!referenceprefix}%
   \xdef\currentstructurebackreference  {\structureparameter\c!backreference}%
   \xdef\currentstructureshownumber     {\structureparameter\c!number}%
   \xdef\currentstructuresaveinlist     {\structureparameter\c!saveinlist}%
   \xdef\currentstructureincrementnumber{\structureparameter\c!incrementnumber}%

   \xdef\currentstructuretitle   {\structureparameter\c!title}%
   \xdef\currentstructurebookmark{\structureparameter\c!bookmark}%
   \xdef\currentstructuremarking {\structureparameter\c!marking}%
   \xdef\currentstructurelist    {\structureparameter\c!list}%

In addition, the following have more complicated definitions.

\currentstructurenumber
\currentstructurelistnumber
\currentsectioncountervalue
\previoussectioncountervalue

Other useful commands are

\structurenumber
\structuretitle
\structurevariable{#1}
\structureuservariable{#1}

and

\namedstructurevariable{#1}{#2}
\namedstructureuservariable{#1}{#2}

Where #1 is the structured item to inspect and #2 is its attribute. For example:

\namedstructurevariable{subsection}{title}
5

Alternatively to Aditya's answer, what might be handy is getmarking e.g. \getmarking[title][current]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .