Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following code in my ConTeXt environment:

\startsetups[sectioninfo]
\ss
  \rlap{\userpagenumber}
  \hfill
  § \getmarking[sectionnumber][current]
  \emspace
  \bf \getmarking[section][current]
  \hfill
  \llap{}
\stopsetups

\setupheadertexts[\setups{chapterinfo}][]
                 []                    [\setups{sectioninfo}]

My intention here is pretty simple; I want the page number on the left and the section name in the middle. However, if there's no section defined in this chapter yet, it will show the name of the last section defined in the previous chapter, or the one before that, and so forth, which is undesirable. It's also undesirable in the front matter, where no sections have yet been defined, to see the § in the header.

So I'm asking three questions:

  1. How does one conditionally display one thing or another, in particular if one thing is blank or empty in some sense? I think I mean this in a TeX sense primarily, but if there's a ConTeXt-specific way of doing this, that's fine too.
  2. How does one determine if \getmarking[section][current] is giving me something from the previous chapter, or is there a different parameter to \getmarking that can be passed to get the most recent section in this chapter only?

Any resources you can point me towards would be greatly appreciated! Thanks!

share|improve this question
add comment

1 Answer

I've discovered some answers.

To the first question, there is a command \doiftextelse. I've replaced my definition of sectioninfo using it to solve the first part:

\startsetups[sectioninfo]
\ss
  \rlap{\userpagenumber}
  \hfill
  \doiftextelse{\getmarking[section][current]}
    {§ \getmarking[sectionnumber][current]
       \emspace
       \bf \getmarking[section][current]}
    {}
  \hfill
  \llap{}
\stopsetups

So, in short, \doiftextelse{condition}{true-case}{false-case}. Wolfgang Schuster helpfully supplied this answer on the NTG-ConTeXt mailing list. However, I still don't know where commands like this are defined and where to learn how to write them. This is information I would love to have.

As to the second problem, I don't know what I'm doing wrong in my document, but I can't create a short example of it, so it must be something glitchy in my environment. In the meantime, I've come up with a kludge that seems to solve the problem, which is:

\setuphead[chapter][after={\marking[section]{}}]

This is just a cheap way of resetting the section marking on each chapter definition. It cures my symptom, but I'm still not sure what's causing the disease.

share|improve this answer
    
The only reliable way to understand low level commands like \doiftextelse is to read the source documentation. Luigi Scarsgo maintains the typeset version of the source, but that is slightly old. You can also generate the documentation on your own using ` mtxrun --script modules --process kpse:supp-box.mkiv` which will generate supp-box-mkiv.pdf which includes, among other things, a terse documentation of doiftextelse. –  Aditya Feb 16 '11 at 22:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.