# How to define a section title for volumes in ConTeXt?

I have a lengthy document, which must be divided into separate volumes. So that it can be compiled in one pass, the source file is organized like this:

\starttext
\startfrontmatter
\stopfrontmatter
\startbodymatter
% this contains the text for volume 1
\stopbodymatter

\startfrontmatter
\stopfrontmatter
\startbodymatter
% this contains the text for volume 2
\stopbodymatter

\startfrontmatter
\stopfrontmatter
\startbodymatter
% this contains the text for volume 3
\stopbodymatter
\stoptext


ConTeXt already has definitions for parts, chapters, and sections, but I could not find any details about volumes. I have found this documentation about adding new section titles, but I do not know if this is proper usage.

First, unlike other section titles, I need the volume title to appear on the title page of each volume, but not in the body matter, e.g.:

 __________________
|                  |
|THIS IS THE TITLE |
|                  |
|    by Author     |
|                  |
|                  |
|                  |
|     Volume I     |
|__________________|


Table of Contents
Volume I
Part 1 - Animals   3
Part 2 - Plants   6
Volume II
Part 3 - Rocks   9


The documentation on creating custom section titles does not seem to cover these points. Volumes seem so different from the other sections that I am not sure if it is correct to use \setuphead to define them. What is the best way to go about adding volumes to the document?

-

Part is the top-level sectioning command in ConTeXt, and to me it looks like that is near-impossible to change, so if you wanted a \volume sectioning command, you would have to redefine all of the structure using \definehead. Not really hard, but it is quite involved.

But commands like \startfrontmatter and \startbodymatter are not meant to be repeated (various things are reset like e.g, part numbers) and it looks like you do not really want your parts and page numbers reset at the start of a new volume anyway.

My advice is therefore to create the special pages for Volumes using a dedicated macro and write your main toc either by hand or by defining a new, global combined list. That would look something like this:

\definelist[volume]
\definecombinedlist
[allcontent]
[volume,part]
[criterium=all,level=section]

\def\Volume#1%
{\page[right]
\writetolist[volume]{}{Volume #1}%
% build up the title page here
}

\starttext
\startfrontmatter
\placecombinedlist[allcontent]
\stopfrontmatter

\startbodymatter
\Volume{I}
\part{Animals}
\chapter{One}
\chapter{Two}
\part{Plants}

\Volume{II}
\part{Rocks}
\stopbodymatter

\stoptext

-