Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am working with a multi-volume document within a single PDF and with no reset page or section numbers.

As ConTeXt does not seem to have any \volume title, as it has for \part and \chapter, I just put in new title pages whenever needed. The document structure looks like this, with \titlepage being a custom macro which places the title information and displays the volume number:

\titlepage
\startbodymatter
    \part{Alligators}
        \chapter{Freshwater}
            \section{Diet}
            \section{Habitat}
    \part{Fish}
\stopbodymatter
\titlepage
\startbodymatter
    \part{Birds}
    \part{Snakes}
\stopbodymatter
\titlepage
\startbodymatter
    \part{Frogs}
\stopbodymatter

I found that if I place the table of contents in the first volume, it is too long. I need to place one table of contents within each volume, which only shows entries, such as \part, \chapter, \section, etc., for that volume and no other.

How can I place a table of contents within my \titlepage macro, such that ConText creates one table of contents appearing after each title, and each table of contents only shows the content appearing after that title page, but not after the following title page? E.g., the table of contents for the first volume appearing above would look like this:

Contents
1 Alligators
    1 Freshwater
        1 Diet
        2 Habitat
 2 Fish

Entries for "volume" do not need to appear inside these lists.

share|improve this question

2 Answers 2

up vote 4 down vote accepted
+250

You want the toplevel structure to be named volume and separate TOCs for each of these. The tricky part is that every structure has a list associated with it and you can’t just clear that along the way, leaving only the local items to be typeset. So the obvious solution is: don’t use the same structures all the time. Different structure, different list.

The code below demonstrates a \titlepage macro that dynamically creates new structures (headings, lists) each time it is called. Everything happens in the background, so you can just continue using your structure macros. With one exception: I took the liberty of titlecasing the labels (e.g. \part -> \Part) to avoid confusion.

Demo output on A6 paper.

%% 1. Define headings matching your structuring preferences. To get a
%%    “volume” structure at level 1, just map it to part =) These will
%%    form the base of the dynamically generated structures later.
%%    NB: To achieve a consistent overall layout you will want to
%%    \setuphead and \setuplist these blueprints here, not their
%%    copies.
\definehead [base_volume]  [part]                                    % level 1
\definehead [base_part]    [chapter]    [sectionsegments=chapter]    % level 2
\definehead [base_chapter] [section]    [sectionsegments=section]    % level 3
\definehead [base_section] [subsection] [sectionsegments=subsection] % level 4

\definelist [base_volume]  [part]
\definelist [base_part]    [chapter]    [style={\word\sc}]
\definelist [base_chapter] [section]    [style=bold]
\definelist [base_section] [subsection] [style=italic]

%% 2. Some settings to fake the  titlepage.
\definemakeup [titlepage]
\defineframed [volumetitledisplay] [
  align=middle,
  frame=off,
  width=\hsize,
]

\unprotect

%% 3. Initialize a counter. It will be used to create macros and lists
%%    for each volume.
\newcount \nvolumes \nvolumes0

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                            main macro
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\titlepage{%
  %% 4. Increment the volume counter.
  \advance\nvolumes\plusone

  %% 5. Define some internal shortcuts involving the current counter.
  \setevalue {currentvolume}{volume_\the\nvolumes}
  \setevalue   {currentpart}{part_\the\nvolumes}
  \setevalue{currentchapter}{chapter_\the\nvolumes}
  \setevalue{currentsection}{section_\the\nvolumes}
  \setevalue   {currentlist}{list_\the\nvolumes}

  %% 6. Create the structures local to this volume. They inherit the
  %%    setups from their parents as defined above.
  \definehead [\currentvolume]  [base_volume]
  \definehead [\currentpart]    [base_part]
  \definehead [\currentchapter] [base_chapter]
  \definehead [\currentsection] [base_section]

  \definelist [\currentvolume]  [base_volume]
  \definelist [\currentpart]    [base_part]
  \definelist [\currentchapter] [base_chapter]
  \definelist [\currentsection] [base_section]

  %% 7. The TOC is a combined list. It needs to be recombined for each
  %%    volume, referencing the appropriate structure lists.
  \definecombinedlist [\currentlist] [%\currentvolume,%
                                      \currentpart,%
                                      \currentchapter,%
                                      \currentsection,]
  \setupcombinedlist [\currentlist] [ criterium=text, ]

  %% 8. The user macros. They are uppercased to distinguish them from
  %%    the builtin ones with the same name. Nothing special, really:
  %%    they just map to the most recently generated structures.
  \setevalue {Volume}{\csname\currentvolume\endcsname}
  \setevalue   {Part}{\csname\currentpart\endcsname}
  \setevalue{Chapter}{\csname\currentchapter\endcsname}
  \setevalue{Section}{\csname\currentsection\endcsname}

  %% 9. Some title page stuff that is actually visible. If the volumes
  %%    should carry a title, just make \titlepage monadic and pass the
  %%    argument to \Volume{}. In order to make the title appear, don’t
  %%    forget \setuphead[base_volume][placehead=yes]!
  \page[right]
  \Volume{\the\nvolumes} %% <= here
  \starttitlepagemakeup
    \vfill
    \volumetitledisplay{%
      {\sc Volume} \the\nvolumes
    }
    \vfill
  \stoptitlepagemakeup

  %% 10. Typeset the table of contents.
  \title{Contents}%
  \csname place\currentlist\endcsname
}

\protect

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                               usage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\starttext

\titlepage
\startbodymatter
    \Part{Alligators}
        \Chapter{Freshwater}
            \Section{Diet}
            \Section{Habitat}
    \Part{Fish}
\stopbodymatter
\titlepage
\startbodymatter
    \Part{Birds}
    \Part{Snakes}
\stopbodymatter
\titlepage
\startbodymatter
    \Part{Frogs}
\stopbodymatter

\stoptext
share|improve this answer

You can divide the text and put the volumes in individual files. That way you have smaller files and the table of content automatically shows only the current volume.

To adjust for the page number offset you can use

\setcounter[userpage][42]

and to adjust the part numbering

\setstructurenumber{1}{12}

The first argument is the structure level, one means part, two means chapter, etc. The second argument is the increment. It depends on the number of parts in the preceeding volume.

share|improve this answer
    
Is there any way which does not involve placing the text into different files? This manner will interfere too much with existing scripts which need all of the material in one file and which will not work if each volume is compiled separately. –  Village Sep 23 '12 at 10:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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