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

ここに画像の説明を入力してください

関連情報