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? Many thanks for your help, Pablo -- http://www.ousia.tk
Am 20.02.2014 um 21:12 schrieb Pablo Rodriguez
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
On 02/20/2014 09:39 PM, Wolfgang Schuster wrote:
Am 20.02.2014 um 21:12 schrieb Pablo Rodriguez:
[...] 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.
Many thanks for your reply, Wolfgang. My question was about headers, but I didn’t mention it to make a shorter sample. The code now is the following: \setupheadertexts[\hfill\namedstructurevariable{chapter}{title}\hfill] [] [] [\hfill\doifsomethingelse{\namedstructurevariable{section}{title}} {\namedstructurevariable{section}{title}} {\namedstructurevariable{chapter}{title}}\hfill] Only a minor detail: is there a more proper way to center both headings? Many thanks for your help, Pablo -- http://www.ousia.tk
Am 20.02.2014 um 23:09 schrieb Pablo Rodriguez
On 02/20/2014 09:39 PM, Wolfgang Schuster wrote:
Am 20.02.2014 um 21:12 schrieb Pablo Rodriguez:
[...] 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.
Many thanks for your reply, Wolfgang.
My question was about headers, but I didn’t mention it to make a shorter sample.
In this case this was a important part for the solution because it makes a difference when you use \getmarking in \setupheadertexts or in the text.
The code now is the following:
\setupheadertexts[\hfill\namedstructurevariable{chapter}{title}\hfill] [] [] [\hfill\doifsomethingelse{\namedstructurevariable{section}{title}} {\namedstructurevariable{section}{title}} {\namedstructurevariable{chapter}{title}}\hfill]
Only a minor detail: is there a more proper way to center both headings?
You can use the simple version of \setupheadertexts and use \doifoddpageelse to check whether you’re on a left or right page. When you make a test for content of a \getmarking command you have to use \doiftext because the \doifempty etc. checks don’t work in this case. \startsetups[header] \doifoddpageelse { \getmarking[chapter] } { \doiftextelse { \getmarking[section] } { \getmarking[section] } { \getmarking[chapter] } } \stopsetups \setupheadertexts[\directsetup{header}] \setupfootertexts[pagenumber] \starttext \chapter{Chapter A} \page \chapter{Chapter B} \page \dorecurse{5} {\chapter{Chapter #1} \dorecurse{10} {\section{Section #1.##1} \dorecurse{3}{\input knuth\par}}} \stoptext Wolfgang
On 02/20/2014 11:23 PM, Wolfgang Schuster wrote:
Am 20.02.2014 um 23:09 schrieb Pablo Rodriguez
: [...] Only a minor detail: is there a more proper way to center both headings?
You can use the simple version of \setupheadertexts and use \doifoddpageelse to check whether you’re on a left or right page. When you make a test for content of a \getmarking command you have to use \doiftext because the \doifempty etc. checks don’t work in this case.
Many thanks for your reply, Wolfgang. This was exactly what I needed. I must admit that I didn’t understood what the simple version of \setupheadertexts was about. And \doiftext (as well as \doifsomething) were totally unknown to me. Many thanks again for your help, Pablo -- http://www.ousia.tk
Have you looked at: http://wiki.contextgarden.net/Headers_and_Footers#Marginal_headings_and_cent... ?
On 02/20/2014 11:32 PM, Thangalin wrote:
Have you looked at:
http://wiki.contextgarden.net/Headers_and_Footers#Marginal_headings_and_cent...
?
Many thanks for your reply, Thagalin. I even compiled the sample code, but I hadn’t understood how the \setupheadertexts worked with a single argument and changing headers for double-sided pages. Pablo -- http://www.ousia.tk
participants (3)
-
Pablo Rodriguez
-
Thangalin
-
Wolfgang Schuster