[NTG-context] \doifemptyelse

Wolfgang Schuster schuster.wolfgang at gmail.com
Thu Feb 20 21:39:07 CET 2014


Am 20.02.2014 um 21:12 schrieb Pablo Rodriguez <oinos at gmx.es>:

> Dear list,
> 
> I have the following sample:
> 
> \starttext
> 
> \chapter{Chapter}
> 
> .\doifemptyelse{\getmarking[section][current]}
>    {\getmarking[chapter][current]}
>    {\getmarking[section][current]}.
> 
> \section{Section}
> 
> .\doifemptyelse{\getmarking[section][current]}
>    {\getmarking[chapter][current]}
>    {\getmarking[section][current]}.
> 
> \stoptext
> 
> I must be missing something extremely basic, because I think that the
> first condiitonal occurs when \getmarking[section][current] is empty
> (dots have nothing in between).
> 
> How can I make the first conditional work?

You can’t, markings are only reliable when you use them in the header of footer of the page.

To access the values of a heading you can use the \structurevariable and \namedstructurevariable commands.

\starttext

\chapter{Chapter}

A: \doifsomethingelse{\namedstructurevariable{section}{title}}
  {\namedstructurevariable{section}{title}}
  {\namedstructurevariable{chapter}{title}}

B: \structurevariable{title}

\section{Section}

A: \doifsomethingelse{\structurevariable{section}{title}}
  {\namedstructurevariable{section}{title}}
  {\namedstructurevariable{chapter}{title}}

B: \structurevariable{title}

\subsection{Subsection}

A: \doifsomethingelse{\structurevariable{section}{title}}
  {\namedstructurevariable{section}{title}}
  {\namedstructurevariable{chapter}{title}}

B: \structurevariable{title}

\stoptext

Wolfgang


More information about the ntg-context mailing list