7

Background

Looking to put the page number flush to the bottom of the page using ConTeXt. The key lines in the Minimum Working Example (MWE) below are:

\setuplayout[
  topspace=\zeropoint,
  %bottomspace=\zeropoint,
]

I thought that by eliminating topspace and eliminating bottomspace the page's text height would automatically be calculated to fill the entire area.

Minimum Working Example

An example that shows what I'm trying to achieve:

\setuppapersize[letter][letter]
\setuplayout[
  topspace=\zeropoint,
  %bottomspace=\zeropoint,
]

\showframe

% Use roman numerals for the front matter
\definestructureconversionset[frontpart:pagenumber] [] [romannumerals]
\setuppagenumbering[location={footer,right},alternative=singlesided]

\starttext

\startfrontmatter
  \setuppagenumbering[conversion=romannumerals]
  \setcounter[userpage][1]

  % Table of Contents
  \completecontent
\stopfrontmatter

\startbodymatter
\setuppagenumbering[conversion=numbers]
\setcounter[userpage][2]

\startchapter[
  title={chapter},
  reference=sec:chapter,
]

\startsection[
  title={section},
  reference=sec:section,
]

\stopsection

\stopchapter

\stopbodymatter

\stoptext

Question

How would you move the page number to the very bottom of the page, as shown in the following image:

Page Number

Is this something that needs a dynamic layer?

Related

7

You can use height=fit (see Wiki - setuplayout), which stretches the text height to its maximum, pushing the footer including page number all the way down. Since you probably do not want the text height to be that large, you can increase the footerdistance. Example:

\setuplayout
  [topspace=\zeropoint,
    height=fit,
    footerdistance=2cm]

\setuppagenumbering
  [location={footer, right}]

\showframe
\starttext
  \null
\stoptext

screenshot

To shift the page number to the right, you can move it into the margin using

\setuppagenumbering
  [location={footer, right, margin}]
4

Marco has already given an answer to your question, but let me illustrate another way to visually achieve the same result.

Layers are a convenient way to place something at a particular location on a page. For example, to place the page number at the very bottom of the page, you can use

\setuppapersize[A6]

\definelayer
  [pagenumber]
  [
    width=\paperwidth,
    height=\paperheight,
    preset=rightbottom,
  ]

\setupbackgrounds[page][background=pagenumber, setups=setpagenumber]

\startsetups setpagenumber
  % Set the page number to be (2em, \lineheight) from the bottom right corner 
  % Note the `preset=rightbottom` above.
  %
  % The 2nd set of optional arguments are for the frame. For illustration I change
  % the color and font of the page number
  \setlayerframed
    [pagenumber]
    [
      x=2em,
      y=\lineheight,
    ]
    [
      frame=on,
      foregroundcolor=red,
      foregroundstyle=bold,
    ]
    {\pagenumber}
\stopsetups

% Disable default page numbering
\setuppagenumbering[location=]

\starttext
\input knuth
\input knuth
\input knuth
\stoptext

which gives

enter image description here

This approach is useful if you need to place the page number in a non-conventional place (as done in many of the ConTeXt manuals).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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