2

Background

In ConTeXt, a multi-level index can be created using:

\index{level1+level2}text

If the value for level2 matches the previous index value of level2, then the text for level2 is not repeated.

Problem

I would like for the level2 to be repeated as per the expected outcome shown below:

Repeated Section Title

In the image, SECTION A is repeated (identified in red), but only because in the code snippet the middle "SECTION A" actually contains an extra space (i.e., "SECTION A ").

When the exact same section title is actually repeated (identified in orange), the section title is hidden.

Code

To illustrate the problem:

\define[1]\AnimalName{%
  \expanded{\index{#1+\namedstructurevariable{section}{title}}{#1}}%
}

\define[1]\AnimalQuant{#1}
\define[1]\AnimalGroup{#1}
\define[3]\Animal{
  \startitem
    \AnimalQuant{#1} \AnimalGroup{#2} \AnimalName{#3}
  \stopitem
}

\setupregister[index][
  textstyle=\em,
  style=\tfa\bold,
  balance=no,
  command=\Word,
]

\starttext
  \placeindex[compress=yes]
  \startchapter[title={Chapter 1}]
    \startsection[title={Section A}]
      \Animal{6}{rookery}{albatross}
      \Animal{12}{wisdom}{wombat}
      \Animal{10}{plague}{locusts}
      \Animal{11}{lounge}{lizard}
      \Animal{6}{pride}{lion}
      \startitem
        5 array \index{hedgehog+SECTION A}hedgehog
      \stopitem
      \startitem
        7 army \index{herring+SECTION A }herring
      \stopitem
      \startitem
        100 bloat \index{hippopotamuses+SECTION A}hippopotamuses
      \stopitem
    \stopsection
  \stopchapter
\stoptext

Change:

7 army \index{herring+SECTION A }herring

to (by removing the extra space after SECTION A ):

7 army \index{herring+SECTION A}herring

After making SECTION A exactly the same, the index is collapsed (hidden/removed):

Missing Level 2

Question

How do you prevent ConTeXt from collapsing duplicate level 2 index titles?

1 Answer 1

0

This was an issue with ConTeXt. To fix it:

  1. Edit context/tex/texmf-context/tex/context/base/strc-reg.lua/strc-reg.lua.
  2. Change from line 695:

        for i=1,4 do -- max 4
            if list[i] then
                e[i] = list[i][1]
            end
            if e[i] ~= done[i] then
                if e[i] and e[i] ~= "" then
                    done[i] = e[i]
                    for j=i+1,4 do done[j] = false end
    
                    if n == i then
                        context.stopregisterentries()
                        context.startregisterentries(n)
                    else
                        while n > i do
                            n = n - 1
                            context.stopregisterentries()
                        end
                        while n < i do
                            n = n + 1
                            context.startregisterentries(n)
                        end
                    end
                    local internal  = entry.references.internal or 0
                    local seeparent = entry.references.seeparent or ""
                    local processor = entry.processors and entry.processors[1] or ""
                    if metadata then
                        context.registerentry(processor,internal,seeparent,function() helpers.title(e[i],metadata) end)
                    else -- ?
                        context.registerentry(processor,internal,seeindex,e[i])
                    end
                else
                    done[i] = false
                    for j=i,4 do done[j] = false end
                end
            end
        end
    

Save the file then recompile using context --make.

1
  • 2
    Or just download the new beta (in a day or so).
    – Aditya
    Commented Sep 28, 2013 at 0:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .