4

As mentioned in two different questions on this plattform (here and here) I'm currently working on a book project. With some help I was able to solve those problems, so the current project will probably be finished in LaTeX.

However, it recently dawned on me that LateX might not be the best solution for projects like this. So, I have been think of making the switch to ConTeXt for the next project and I would now like to try rebuilding a LaTeX layout in ConTeXt. So far, that works pretty well, but I'm having one problem that I can't seem to find a solution for.

Here's a very simple MWE for a layout that I have been working on:

\starttext

\enableregime[utf-8]
\mainlanguage[de]
\language[de]

\setuppapersize[A4][A4]
\setuplayout[alternative = doublesided,
  backspace=11.67mm, width=131.25mm,
  topspace=21.21mm, height=254.57mm,
  headerdistance=13pt, header=13pt,
  footerdistance=13pt, footer=13pt,
  rightmargindistance=13pt, rightmargin=39.5mm
]
\setuppagenumbering[alternative=doublesided]
\setupbackgrounds[header][text][frame=off, bottomframe=on]

\setupbodyfontenvironment[default][em=italic]   % make italic default instead of slanted
\usetypescript[modern][ec]
\setupbodyfont[modern, 9pt]
\setupwhitespace[line]
\setupinterlinespace[line=13pt]
\setuplayout[grid = yes]

\startbodymatter

\chapter{Chapter}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

\inothermargin{Lorem ipsum dolor sit amet.}Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

\stopbodymatter

\stoptext

This is how it looks like:

A simple ConTeXt layout with margin notes. But how to widen the header?

So, I'm using the outer margin of each page (about a quarter of the text area) to include margin notes. That works pretty well and - coming from LaTeX - I have to say it was surprisingly easy to set this up. However, I would now like to widen the header and the footer to extend over the whole text area, i.e. the line in the header should be wide enough to cover the margin notes, the page number should be centered relative to the whole text area (instead of relative to the main text block) and so on. And so far I have been unable to find a way to achieve that.

I'm assuming I'm using the wrong setup to achieve this by setting the \rightmargin in \setuplayout? But how else can this be done? Any help would be much appreciated.

(By the way: Does ConTeXt also have a command like \blindtext like LaTeX?)

5
  • 1
    You should leave the configuration outside \starttext.
    – Manuel
    Oct 11, 2016 at 21:40
  • 1
    Instead of \blindtext, in ConTeXt it is common to just input one of the sample text files: knuth, ward, tufte, zapf. So just use \input knuth or \dorecurse{5}{\input knuth \endgraf} if you want longer text. There is also a port of lipsum package.
    – Aditya
    Oct 11, 2016 at 22:08
  • 1
    BTW, in MKIV, you don't need \enableregime[utf-8]. Everything is utf8 by default.
    – Aditya
    Oct 11, 2016 at 22:09
  • Thanks, @Manuel. I was adding the \starttext command as an afterthought (it was a "project" before) and didn't check the position carefully enough.
    – Marcus C.
    Oct 12, 2016 at 17:35
  • Thank you, @Aditya, that's good to know. As to everything being utf8... hmm, you are probably right. But I remember my German Umlauts not being rendered correctly before, so I thought that utf8 was necessary. Maybe I had something wrong.
    – Marcus C.
    Oct 12, 2016 at 17:37

1 Answer 1

5

There is no default mechanism for page headers that does what you want. However, it is relatively simple to do so manually. In the solution below, I set the "inner" page header to be a box with width equal to textwidth + outermargindistance + outermarginwidth and center the pagenumber in that box.

I also removed all the parts of your setup that were not relevant to the example. Also not the use of visual module to create random boxes (instead of text).

\usemodule[visual]

\setuppapersize[A4][A4]
\setuplayout
[
  backspace=11.67mm,        width=131.25mm,
  topspace=21.21mm,         height=254.57mm,
  headerdistance=13pt,      header=13pt,
  footerdistance=13pt,      footer=13pt,
  rightmargindistance=13pt, rightmargin=39.5mm,
]
\setuppagenumbering[alternative=doublesided, location=]
\definemeasure[fullwidth][\dimexpr\textwidth+\outermarginwidth+\outermargindistance\relax]

\startsetups header
  \framed[frame=off, bottomframe=on, width=\measure{fullwidth}, align=middle]
    {\pagenumber}
\stopsetups

\setupheadertexts[\setups{header}][][][\setups{header}]

\starttext

\chapter{\fakewords{2}{3}}

\fakewords{50}{60}

\inoutermargin{\fakewords{10}{20}} \fakewords{50}{60}
\page

\fakewords{50}{60}

\inoutermargin{\fakewords{10}{20}} \fakewords{50}{60}

\stoptext

which gives

enter image description here

BTW, the following answer on margin notes in ConTeXt may be useful.

2
  • Thanks, great, that's exactly what I was looking for. I have to say that I'm a bit surprised that ConTeXt doesn't offer a more direct mechanism for such a layout. But this is relatively easy to set up and looks like a robust solution. One more question: Can this procedure (a box in the page header) also be used to create a colored bar instead of a header? Say, along the top edge of the page?
    – Marcus C.
    Oct 12, 2016 at 18:59
  • 1
    I'd use layers or page backgrounds to have a colored bar on the top.
    – Aditya
    Oct 12, 2016 at 20:01

You must log in to answer this question.

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