Difference between revisions of "Headers and Footers"

From Wiki
Jump to navigation Jump to search
Line 1: Line 1:
Headers with centered content
+
'''Headers with centered content'''
  
 
ConTeXt offers the possibility to have mirrored headers (for odd and even pages); content can be in two parts, at the inner and outer margin of each page. But how do you get a header that will have one part of its content centered and one part in the outer margin? (This is a common setup for books: chapter title centered, page number in outer margin.) Hans posted this solution to the list:
 
ConTeXt offers the possibility to have mirrored headers (for odd and even pages); content can be in two parts, at the inner and outer margin of each page. But how do you get a header that will have one part of its content centered and one part in the outer margin? (This is a common setup for books: chapter title centered, page number in outer margin.) Hans posted this solution to the list:
Line 28: Line 28:
  
 
The use of the TeX primitive rlap and llap allows centering of content.
 
The use of the TeX primitive rlap and llap allows centering of content.
 +
 +
 +
 +
'''Using capitals'''
 +
 +
In the previous example, the chapter title and the section title were fetched with the macro <cmd>getmarking</cmd> which wraps around <cmd>fetchmark</cmd>.
 +
However, in case you need a raw version of the mark, say for instance to put it uppercase, you may use this setup instead:
 +
 +
<texcode>
 +
 +
\startsetups[text a]
 +
  \rlap{\pagenumber}
 +
  \hfill
 +
  \expanded{\uppercase{\fetchmark[chapter][first}}
 +
  \hfill
 +
  \llap{whatever}
 +
\stopsetups
 +
 +
\startsetups[text b]
 +
  \rlap{whatever}
 +
  \hfill
 +
  \expanded{\uppercase{\fetchmark[section][first}}
 +
  \hfill
 +
  \llap{\pagenumber}
 +
\stopsetups
 +
 +
</texcode>
 +
 +
 +
You can replace <cmd>uppercase</cmd> by <cmd>WORD</cmd> and so on.

Revision as of 22:54, 17 August 2005

Headers with centered content

ConTeXt offers the possibility to have mirrored headers (for odd and even pages); content can be in two parts, at the inner and outer margin of each page. But how do you get a header that will have one part of its content centered and one part in the outer margin? (This is a common setup for books: chapter title centered, page number in outer margin.) Hans posted this solution to the list:

\setuppagenumbering[alternative=doublesided]

\setupheadertexts[]
\setupheadertexts[\setups{text a}][][][\setups{text b}]

\startsetups[text a]
  \rlap{\pagenumber}
  \hfill
  \getmarking[chapter]
  \hfill
  \llap{whatever}
\stopsetups

\startsetups[text b]
  \rlap{whatever}
  \hfill
  \getmarking[section]
  \hfill
  \llap{\pagenumber}
\stopsetups

The use of the TeX primitive rlap and llap allows centering of content.


Using capitals

In the previous example, the chapter title and the section title were fetched with the macro \getmarking which wraps around \fetchmark. However, in case you need a raw version of the mark, say for instance to put it uppercase, you may use this setup instead:


\startsetups[text a]
  \rlap{\pagenumber}
  \hfill
  \expanded{\uppercase{\fetchmark[chapter][first}}
  \hfill
  \llap{whatever}
\stopsetups

\startsetups[text b]
  \rlap{whatever}
  \hfill
  \expanded{\uppercase{\fetchmark[section][first}}
  \hfill
  \llap{\pagenumber}
\stopsetups


You can replace \uppercase by \WORD and so on.