[NTG-context] Newbie questions

Mojca Miklavec mojca.miklavec.lists at gmail.com
Sun Jun 25 17:33:05 CEST 2006


On 6/24/06, Thomas Moore wrote:
> 1.  I have successfully set up a doublesided layout that has a text
> column and an outer margin for margin notes and some small figures. I
> would like to set up a header that has the chapter number and name
> (e.g.  "3. Third Chapter Name") on the inner edge of the text column,
> and the page number aligned with the *outer* edge of the margin and a
> 1-pt rule below the entire header (from below the chapter number to
> below the page number). How would one do this elegantly (or even
> inelegantly)?

First forget about the wrong pagenumber positioning. Here's the most
elegant solution for drawing the line:

\setuppagenumbering
	[alternative=doublesided,
	 location=]

\setupheadertexts
	[pagenumber]
	[chapter]
	[chapter]
	[pagenumber]

\setuplayout
	[header=15pt,
	 headerdistance=20pt]

\setupbackgrounds
	[header]
	[text]
	[bottomframe=on,
	 rulethickness=1pt]

\starttext
\chapter{first}
\dorecurse{50}{\input tufte }
\chapter{second}
\dorecurse{20}{\input tufte }
\stoptext

But I don't know if there's a simple extention to it to draw the
missing line inbetween.


Here's another solution, which is the wrong way of doing things (it's
way too slow and meant for more complex things than a simple rule, but
could be optimezed if "useMPgraphic" was replaced with "reusable" or
"unique"). Also try \showlayout and see meta-pag.tex in the ConTeXt
source.

\startuseMPgraphic{PageFrame}
  StartPage ;
  y1=y2=PaperHeight-TopSpace-HeaderHeight;

  if OnRightPage :
    x2 = BackSpace+TextWidth = x1 + LeftMarginDistance +
LeftMarginWidth + TextWidth;
  else:
    x2 = BackSpace = x1 - (RightMarginDistance + RightMarginWidth + TextWidth);
  fi;
    draw z1--z2 withpen pencircle scaled 1pt;
  StopPage;
\stopuseMPgraphic

\defineoverlay
	[PageFrame][\useMPgraphic{PageFrame}]

\setupbackgrounds
	[page]
	[background=PageFrame]


The trird solutions is probably the way to go, but it influences only
a single page and \getmarking[chapter] has no influence. I guess that
a minor modification is needed to handle both left & right page
properly and to put that layer over all pages, not only on the  first
one:

\definelayer
	[page]
	[width=\paperwidth,
	 height=\paperheight]
\setupbackgrounds
	[page]
	[background=page]
\setlayerframed
	[page]
	[voffset=\topspace,
	 hoffset=\the\dimexpr\backspace-\leftmarginwidth-\leftmargindistance\relax,
	 preset=lefttop]
	[width=\the\dimexpr\textwidth+\leftmarginwidth+\leftmargindistance\relax,
	 rulethickness=1pt,
	 frame=off,
	 bottomframe=on]
	{\pagenumber\hfill\getmarking[chapter][first]}

Hoping that someone can fix at least one of the solutions above to
work as intended,
    Mojca


More information about the ntg-context mailing list