Как определить элементы, появляющиеся в списке, который появляется в другом месте документа в ConTeXt?

Как определить элементы, появляющиеся в списке, который появляется в другом месте документа в ConTeXt?

У меня есть документ, который будет отображать резюме в начале каждой главы. В резюме будут перечислены важные моменты, которые будут появляться позже в отрывках.

Например:

This chapter will talk about:
\printtopics

Section 1
Building a bridge is very easy. First start with some stones. Then,
\definetopic{How to build a temporary bridge from stones.}
find a narrow area in a river. Throw the stones into the river
until the river has completely stopped.
...

Это даст:

This chapter will talk about:
1. How to build a temporary bridge from stones.
2. How to hunt for rabbits.
3. How to find firewood.

Section 1
Building a bridge is very easy. First start with some stones. Then,
find a narrow area in a river. Throw the stones into the river
until the river has completely stopped.
...

Использование \definetopic{How to build a temporary bridge from stones.}означает, что эти слова добавляются в список и появляются в резюме в начале главы.

Как определить элементы, которые необходимо добавить в список, отображаемый в начале главы, но при этом определить их в тексте документа в ConTeXt?

решение1

Для этой цели можно определить локальный список глав.

\definelist
  [topics]
  [criterium=chapter,
   headnumber=always,
   pagenumber=no]

\definecounter
  [topic]
  [way=bychapter]

\define[1]\definetopic{%
  \incrementcounter[topic]%
  \writetolist[topics]{\rawcountervalue[topic]}{#1}}

\starttext

\startchapter[title=Foo]
  This chapter will talk about:
  \placelist[topics]

  \startsection[title=Bar]
    \definetopic{How to build a temporary bridge from stones.}%
    \input knuth
    \definetopic{How to hunt for rabbits.}%
    \input knuth
    \definetopic{How to find firewood.}%
    \input knuth
  \stopsection
\stopchapter

\startchapter[title=Foo]
  This chapter will talk about:
  \placelist[topics]

  \startsection[title=Bar]
    \definetopic{How to hunt for rabbits.}%
    \input knuth
  \stopsection
\stopchapter

\stoptext

введите описание изображения здесь

Связанный контент