2

Background

Looking to customize the table of contents.

Problem

In the example, the following problems exist:

  • The last entry in the table of contents is not hyperlinked.
  • All hyperlinks are off by one.

Note that the chapters and sections are separate pages in the document.

In the following image a red box surrounds the entry that cannot be clicked:

Missing Link

Minimum Working Example

Here is the code to reproduce the problem:

\setupinteraction[state=start,]
\setuphead[chapter,section][page=yes,continue=no,]

\define[3]\SectionTOC{#3 #2}

% Using alternative causes the cross-reference to be off.
\setuplist[section][
  alternative=interactive,
  command=\SectionTOC,
]

\starttext
  \placecontent

  \startchapter[title=Chapter]
    \dorecurse{4}{
      \startsection[title=Section]
        Level \recurselevel.
      \stopsection
    }
  \stopchapter
\stoptext

Question

How do you use an interactive alternative to generate correct hyperlinks for a customized table of contents?

0

From the mailing list, a \noindent is required to eliminate the half-line shift:

% The table of contents links get shifted up. This code adds a
% \noindent so that the TOC links do not get shifted.
\unprotect
\startsetups[\??listrenderings:interactive]
  \edef\p_command{\listalternativeparameter\c!command}%
  \ifx\p_command\empty
    [\currentlist: \currentlistentrynumber\space -- \currentlistentrytitle\space -- \currentlistentrypagenumber]%
  \else
    \listparameter\c!before
    \noindent\hbox \strc_lists_get_reference_attribute\v!all \strc_lists_get_destination_attribute {
      \p_command\currentlistentrynumber\currentlistentrytitle\currentlistentrypagenumber
    }
    \listparameter\c!after
  \fi
\stopsetups
\protect

Next, add an \endgraf to the lists:

\setuplist[chapter][
  before={\endgraf\blank[big]},
  after={\blank[medium]},
]

\setuplist[section,sectionpicture][
  before=\endgraf,
]

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.