5

I'm getting stumped about how to generate the ToC for this book. I'm about to give up and just do it by hand. The author wants to include a lot of structural information that isn't present in the actual text, and none of the numbers "roll over" as they're want to do in ConTeXt.

This is the desired effect:

  Narrator 1...

    FIRST PART: PART SUBTITLE

1). First Poem // First Poem (Spanish title) . . . . . . . . . . . . . . . . .    1
    Author of Poem (b. XXXX d. XXYY)

2). Second Poem // Poema Secunda . . . . . . . . . . . . . . . . . . . . . . .    3
    Author of Poem

  Narrator 2...

3). Third Poem // Third Poem . . . . . . . . . . . . . . . . . . . . . . . . .    5
    Author

    SECOND PART: Part 2

4). Fourth Poem // Fourth Poem . . . . . . . . . . . . . . . . . . . . . . . .    7
    Author

  Narrator 3...

The problems I have essentially boil down to these:

  1. There is this weird "narrator" concept that doesn't seem to contain or be contained by the part/poem structure. A new part doesn't imply a new "narrator" and a new "narrator" doesn't imply a new part.

  2. I need to aggrandize each title with the title in translation and the author, and I want to typeset them nicely.

  3. I need poems to continue counting up across parts.

I see basically three approaches:

  1. Make each poem a chapter and customize the appearance with \setuphead[chapter][....]. Then use \writebetweenlist[chapter] to add the Narrator and author information.

  2. Make a new list with \definelist[poem] and \definecombinedlist[content][part,poem]; continue using \writebetweenlist[poem] to insert the author and Narrator. This feels like the most conceptually valid option, but I think I'll still need a lot of customization.

  3. Forget all about ConTeXt and switch to plain TeX, use eplain's writetocentry system. Make it look right and forget maintainability.

  • I am not on a computer with ConTeXt installed, so these are hints rather than the complete answer. First, the easy parts. To add author and translation information, you can just use \startpoem[title={....}][spanishtitle={...}, author={...}] and define a custom list rendering for poems to display the author. To ensure that poems are numbered across parts use \setuphead[poem][way=bytext]. That just leaves you with how to add the narrator; for that the easiest option is to use \writebetweenlist – Aditya May 27 '15 at 14:39
  • @Aditya This is very helpful, but I need a few more hints. Am I using \definehead to create \startpoem? Do I use \definelistalternative to change the rendering? How do I get at spanishtitle and author from within it? – Daniel Lyons May 27 '15 at 15:05
  • A couple years ago (on a project I had to take a hiatus from) I attempted to do something similar, except I actually used the glossaries package. It allowed for page numbers, numerous levels of details (not all of which were included in the text), and if memory serves item groupings (i.e. something akin to your narrator criterion). If summarized with a custom style, continuous numbering might also be possible although not entirely guaranteed to reflect an ordered by use gls entries in your document unless governed by explicit sort criterion (manually), so possibly not relevant. – EngBIRD May 31 '15 at 3:11
  • @EngBIRD I'm not using LaTeX. – Daniel Lyons May 31 '15 at 19:19
4
+50

Let's start with the easy part first: How to handle title translation and author. The ConTeXt way is to specify them as part of \starthead, e.g.,

\startpoem
    [title={First Poem}]
    [
      translation={Primier Poema},
      author={Daniel Lyons},
    ]

...

\stoppoem

For this, we specify:

\definehead
  [poem]
  [section]
  [alternative=poemtitle]


\defineheadalternative
  [poemtitle]
  [alternative=horizontal,
   renderingsetup=poemtitle]

\startsetups poemtitle
    \vbox {
    \headnumbercontent. \headtextcontent
    \doifsomething{\structureuservariable{translation}}
      {\space//\space
       \structureuservariable{translation}}
    \doifsomething{\structureuservariable{author}}
        {\blank \structureuservariable{author}}}
\stopsetups

Next, you want the poem number not to be reset with a new part. Note that we mapped a poem to section (rather than a chapter). To control when section counters are reset, we need to use \definestructureresetset. It is explained in this message on the mailing list. For your purpose, you need.

\setuphead
  [part][placehead=yes]

\definestructureresetset[default][0,0,0,1][1]  
% The order of these numbers is: part-chapter-section-subsection
% 0 means do not reset the subsequent section number
% 1 means reset.
%
% So, 0,0,0,1 means that do not reset section (which is what we will map poems
% to) at chapter or part.

How to access title translation and author in lists. This information is available in lists using \setupstructurelistvariable. So, you can define:

\define[1]\PoemListTitle
    {#1%
  {\doifsomething{\structurelistuservariable{translation}}
      {\space//\space
        \structurelistuservariable{translation}}%
    \doifsomething{\structurelistuservariable{author}}
        {\crlf \structurelistuservariable{author}}}

All that is left is the narrator, which can be added using \writebetweenlist.

A working example with all the information so far is below. I merged the renderings of the head and list, to remove redundant information.

\setuphead
  [part][placehead=yes]

\definestructureresetset[default][0,0,0,1][1]  
% The order of these numbers is: part-chapter-section-subsection
% 0 means do not reset the subsequent section number
% 1 means reset.
%
% So, 0,0,0,1 means that do not reset section (which is what we will map poems
% to) at chapter or part.

\definehead
  [poem]
  [section]
  [alternative=poemtitle]

\defineheadalternative
  [poemtitle]
  [alternative=horizontal,
   renderingsetup=poemtitle]

\define[1]\PoemExtras
  % #1: \structureuservariable for heads
  %   : \structurelistuservariable for lists
  {\doifsomething{#1{translation}}
      {\space//\space
        #1{translation}}%
    \doifsomething{#1{author}}
        {\crlf #1{author}}}

\startsetups poemtitle
    \vbox {
        \headnumbercontent. \headtextcontent
        \PoemExtras\structureuservariable
    }
\stopsetups

\setuplist
    [poem]
    [textcommand=\PoemListTitle]

\define[1]\PoemListTitle
    {#1\PoemExtras\structurelistuservariable}


\starttext

\placelist[part,poem][alternative=c]

\startpart[title={First Part: Part Subtitle}]

  \startpoem
      [title={First Poem}]
      [
        translation={Primier Poema},
        author={Daniel Lyons},
      ]


    \input ward

  \stoppoem

  \startpoem
      [title={Second Poem}]
      [
        translation={Poema Secunda},
        author={Author of Poem},
      ]


    \input ward

  \stoppoem

\stoppart

\startpart
    [title={Second Part: Part 2}]


  \startpoem
      [title={Third Poem}]
      [
        translation={Poema Tercer},
        author={Author of Poem},
      ]


    \input ward

  \stoppoem

\stoppart

\stoptext

which gives

enter image description here

  • Ah, sorry for the noise – Ben Voigt Jun 1 '15 at 23:14
  • There is a lot of wizardry in here, and I really appreciate your taking the time to share it with me! :) – Daniel Lyons Jun 2 '15 at 14:41

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.