On 04/15/2012 07:44 AM, Aaron W. Hsu wrote:
Hey All:
I am very new to ConTeXt, but I am trying to use it to achieve a format similar to what you can get from WEB systems. Right now I am working on the definitions of chunks and their cross references. I have three main macros:
\defchunk Definining a new chunk \chunk Referencing a chunk by name \stopchunk Ending a chunk definition
Here is an example:
\defchunk{This is a name} Some text /BTEX\chunk{Other stuff}/ETEX goes here. And here. \stopchunk
\defchunk{Other stuff} Something else \stopchunk
\defchunk{This is a name} Some other stuff. \stopchunk
Now, at the end, let's say that each of these appears in sections 1, 2, and 3, respectively. The output I am looking for, in Unicode, might look like this:
⟨This is a name 1⟩≡ Some text ⟨Other stuff 2⟩ goes here. And here. ── See also section 3.
⟨Other stuff 2⟩≡ Something else ── This code is used in section 1.
⟨This is a name 1⟩≡ Some other stuff. ──
So here, there are really three things that I want to achieve. I need to be able to get a list of all of the sections wherein a given chunk is referenced using \chunk, a list of all the sections where a section of the same name is defined, and finally, be able to tell in which section the first occurrence of a chunk is defined.
How can I accomplish this?
Have you had a look at the reference manual? Chapter 13 on descriptions will show you how to define something like \definedescription[chunk][location=serried,titlestyle=\bf] which you then should be able to use as \chunk[name1]{This is a name} For referencing (chapter 12), use \in for pointing to the relevant section, \at[name1] for a page number. \definedescription[chunk] \starttext \input tufte \section[s1]{One section} \chunk[c1]{A chunk} \input ward \par \input tufte \startchunk[c2]{A long chunk} \input ward \input tufte \stopchunk In section \in[s1] on page \at[c1], we defined the first chunk. \stoptext You can style this with \setupdesription[chunk][...=...] or directly in the definition. Enjoy =) Severin