1

I would like page number appear in both the Table of Contents, and page footers, just like in old Manuals from Digital Equipment Corporation. That is Chapter#--Page#, where pages restart at 1 with each chapter. This is the best I have:

\setuppagenumbering[alternative=doublesided,location=]
\starttext

% with \headnumber[chapter], page number in TOC appears as "-1".
% with \determineheadnumber[chapter]\currentheadnumber, page numbers in
%   TOC appear as "0-1"
\define[1]\addchapterprefix{\headnumber[chapter]--#1}
\defineconversion[addchapterprefix][\addchapterprefix]
\definestructureconversionset[frontpart:pagenumber][][romannumerals]
\definestructureconversionset[bodypart:pagenumber][][addchapterprefix]
\setuppagenumber[way=bychapter,numberconversionset=pagenumber]

\setuplist[chapter][alternative=f,style=\ssb]
\setuplist[section][alternative=c,pageconversionset=pagenumber]
\setupfootertexts%
    [{{\bf\userpagenumber}~~\getmarking[chapter][first]}]%
    []%
    []%
    [{\getmarking[chapter][first]~~{\bf\userpagenumber}}]

\setuphead[chapter][page=right]
\setuphead[section][number=no,style=\ssb]

% with \startsectionblockenvironment[frontpart] ConTeXt fails to produce
%   any output, or error message.
\startfrontmatter
\startchapter[list=Table of Contents]
\setupinterlinespace[small]
\placecontent[criterium=all]
\startsection[title=Preface]
\dorecurse{10}{The quick brown fox jumps over the lazy dog.\par}
\stopsection
\stopchapter
\stopfrontmatter

\startbodymatter
\setcounter[userpage][1]

\startchapter[title=This is my chapter title]
\dorecurse{10}{The quick brown fox jumps over the lazy dog.\par}
\startsection[title=This is my section title]
\dorecurse{10}{The quick brown fox jumps over the lazy dog.\par}
\stopsection
\stopchapter

\startchapter[title=This is another chapter title]
\dorecurse{10}{The quick brown fox jumps over the lazy dog.\par}
\startsection[title=This is another section title]
\dorecurse{10}{The quick brown fox jumps over the lazy dog.\par}
\stopsection
\stopchapter

\stopbodymatter
\stoptext

I've used \startfrontmatter over \startsectionblockenvironment[frontpart] because ConTeXt cycles once with the latter, and produces no output or error message. The calling of the page conversion seems to work with \startfrontmatter, only I can't find any place that the chapter number is defined at the time of producing the table of contents.

Using ConTeXt version 2019.03.21 21:39, LuaTeX version 1.10.0 (Tex Live 2019) on macOS 10.14.6.

1

You mix up the following two commands:

  • \startsectionblock[⟨NAME〉] ... \stopsectionblock and
  • \startsectionblockenvironment[⟨NAME〉] ... \stopsectionblockenvironment.

The sectionblock environment is the same as the bodypart environment but you pass the name of the sectionblock as argument of the start-command. The sectionblockenvironment environment is used to set options which are used at the begin of a certain sectionblock and you put it in the preamble of your document.

To get the chapter value in front of the page number you have to enable the prefix for the userpagenumber (the \setuppagenumber command is a synonym for \setupuserpagenumber).

\setupuserpagenumber
  [way=bychapter,
   prefix=yes,
   prefixset=chapter,
   prefixsegments=chapter]

\setuppagenumbering
  [alternative=doublesided,
   location=none]

\setupfootertexts
  [{\prefixedpagenumber\hspace[medium]\getmarking[chapter][first]}]
  []
  []
  [{\getmarking[chapter][first]\hspace[medium]\prefixedpagenumber}]

\setuplist
  [chapter]
  [alternative=f]

\setuplist
  [section]
  [alternative=c,
   pageprefix=yes,
   pageprefixsegments=chapter]

\defineconversionset [frontpart:pagenumber] [] [i]
\defineconversionset  [bodypart:pagenumber] [] [n]

\setuphead
  [section]
  [number=no]

\starttext

\startfrontmatter

\completecontent

\stopfrontmatter

\startbodymatter

\dorecurse{2}
  {\chapter{Chapter \convertnumber{word}{#1}}
   \dorecurse{4}
     {\section{Section ##1}
      \dorecurse{3}{\samplefile{weisman}}}}

\stopbodymatter

\stoptext
| improve this answer | |
0

Answering my own question (although, I'm not entirely sure why this works). It relies upon \setupuserpagenumber[ prefixsegments=chapter ] which is missing from most documentation:

\setuppagenumbering[alternative=doublesided,location=]
\starttext

\definestructureprefixset[pageprefix][chapter][] % ch--pg in \userpage footers
\setuplist[chapter][alternative=f,style=\ssb]
\setuplist[section][alternative=c,pageconversionset=pagenumber]
\setupfootertexts%
    [{{\bf\userpagenumber}~~\getmarking[chapter][first]}]%
    []%
    []%
    [{\getmarking[chapter][first]~~{\bf\userpagenumber}}]

\setuphead[chapter][page=right]
\setuphead[section][number=no,style=\ssb]

\startfrontmatter
\setupuserpagenumber[numberconversion=romannumerals]

\startchapter[list=Table of Contents]
\setupinterlinespace[small]
\placecontent[criterium=all]
\startsection[title=Preface]
\dorecurse{10}{The quick brown fox jumps over the lazy dog.\par}
\stopsection
\stopchapter
\stopfrontmatter

\startbodymatter
\setupuserpagenumber[way=bychapter,prefix=yes,
            prefixsegments=chapter, % ch--pg in ToC
            prefixset=pageprefix,   % ch--pg in \userpage footers
            numberconversion=numbers]
\setcounter[userpage][1]

\startchapter[title=This is my chapter title]
\dorecurse{10}{The quick brown fox jumps over the lazy dog.\par}
\startsection[title=This is my section title]
\dorecurse{10}{The quick brown fox jumps over the lazy dog.\par}
\stopsection
\stopchapter

\startchapter[title=This is another chapter title]
\dorecurse{20}{The quick brown fox jumps over the lazy dog.\par}
\startsection[title=This is another section title]
\dorecurse{20}{The quick brown fox jumps over the lazy dog.\par}
\stopsection
\stopchapter

\stopbodymatter
\stoptext
| improve this answer | |

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.