Difference between revisions of "Generate Authorlist from Head Content"

From Wiki
Jump to navigation Jump to search
Line 1: Line 1:
With the new head syntax (MkIV) one can easy add information to chapters, sections, etc.
+
An example on how to generate a sorted list of all authors contributed to a conference proceeding.
  
Here is an example from Wolfgang Schuster ([http://archive.contextgarden.net/message/20100919.163604.e1f8cb40.en.html])
+
<texcode>
 +
\setuphead
 +
  [title]
 +
  [page=no,command=,]
  
<texcode>
+
\setuphead
\define[3]\ChapterList
+
  [chapter]
{\bTABLE[offset=0pt,strut=yes,frame=off,width=.5\textwidth]
+
  [command=\MyChapCMD]
    \bTR
 
      \bTD \structurelistuservariable{date} \eTD
 
      \bTD #2 \eTD
 
      \bTD (\structurelistuservariable{author}) \eTD
 
    \eTR
 
  \eTABLE}
 
  
 
\setuplist
 
\setuplist
 
   [chapter]
 
   [chapter]
   [alternative=command,
+
   [criterium=all,alternative=command,command=\MyChapListCMD]
   command=\ChapterList]
+
 
 +
\definesorting[author][authors]
 +
\setupsorting [author][criterium=all,expansion=yes]
 +
 
 +
\define[2]\MyChapCMD
 +
{#1\enspace #2
 +
   {\doifsomething
 +
      {\structureuservariable{author}}
 +
      {\author
 +
        [\structureuservariable{name}] % -> sorted by "name"-variable
 +
        {\bTABLE[width=broad]
 +
          \bTR
 +
            \bTD \structureuservariable{author} \eTD
 +
            \bTD \structureuservariable{city}  \eTD
 +
            \bTD \structureuservariable{date}  \eTD
 +
            \bTD \structureuservariable{email}  \eTD
 +
            \bTD \structureuservariable{note}  \eTD
 +
          \eTR
 +
        \eTABLE\nointerlineskip}%
 +
        \tfxx (\structureuservariable{author}, \structureuservariable{city})}}}
 +
 
 +
\define[3]\MyChapListCMD
 +
  {#1 #2 (\structurelistuservariable{author})\hfill  #3\blank}
 +
 
 +
 
 +
\starttext  \showframe[text]
  
\define[2]\ChapterHead
+
\starttitle[title=Contents]
   {\startframedtext[frame=off,width=broad,offset=0pt,align=middle]
+
   \placelist[chapter]
    \doifsomething
+
\stoptitle
      {\structureuservariable{date}}
 
      {\structureuservariable{date}\blank}
 
      #2
 
    \doifsomething
 
      {\structureuservariable{author}}
 
      {\blank\structureuservariable{author}}
 
  \stopframedtext}
 
  
\setuphead
+
\starttitle[title=List of Authors in Alphabetical Order]
   [chapter]
+
   \placelistofsorts[author][authors]
   [command=\ChapterHead]
+
\stoptitle
 +
 
 +
\startchapter
 +
   [title=Text by Ward]
 +
  [name=ward,
 +
  author=Peter D. Ward,
 +
  city=Washington,
 +
  email=ward@sample.com]
 +
 
 +
  \input ward
 +
\stopchapter
  
 +
\startchapter
 +
  [title=Text by Zapf]
 +
  [name=zapf,
 +
  author=Hermann Zapf,
 +
  city=Nürnberg,
 +
  date=8. November 1918,
 +
  email=zapf@sample.de]
  
\starttext
+
  \input zapf
 +
\stopchapter
  
\completecontent
+
\startchapter
 +
  [title=Text by Bryson]
 +
  [name=bryson,
 +
  author=Bill Bryson,
 +
  city=Norfolk,
 +
  date={December 8, 1951},
 +
  note=best-selling American author]
  
\startchapter[title=Rom][date=12.06.2010,author=Knuth]
+
   \input Bryson
   \input knuth
 
 
\stopchapter
 
\stopchapter
  
\startchapter[title=Pisa][date=14.06.2010,author=Tufte]
+
\startchapter
 +
  [title=Text by Tufte]
 +
  [name=tufte,
 +
  author=Edward R. Tufte,
 +
  city=Kansas City,
 +
  date=1942,
 +
  note=has criticized the way Microsoft PowerPoint is typically used]
 +
 
 
   \input tufte
 
   \input tufte
 
\stopchapter
 
\stopchapter
  
 
\stoptext
 
\stoptext
</texcode>
+
 
 +
</techcode>

Revision as of 15:16, 12 November 2010

An example on how to generate a sorted list of all authors contributed to a conference proceeding.

<texcode> \setuphead

 [title]
 [page=no,command=,]

\setuphead

 [chapter]
 [command=\MyChapCMD]

\setuplist

 [chapter]
 [criterium=all,alternative=command,command=\MyChapListCMD]

\definesorting[author][authors] \setupsorting [author][criterium=all,expansion=yes]

\define[2]\MyChapCMD

{#1\enspace #2
  {\doifsomething
     {\structureuservariable{author}}
     {\author
       [\structureuservariable{name}] % -> sorted by "name"-variable
       {\bTABLE[width=broad]
          \bTR
            \bTD \structureuservariable{author} \eTD
            \bTD \structureuservariable{city}   \eTD
            \bTD \structureuservariable{date}   \eTD
            \bTD \structureuservariable{email}  \eTD
            \bTD \structureuservariable{note}   \eTD
          \eTR
        \eTABLE\nointerlineskip}%
        \tfxx (\structureuservariable{author}, \structureuservariable{city})}}}

\define[3]\MyChapListCMD

 {#1 #2 (\structurelistuservariable{author})\hfill  #3\blank}


\starttext \showframe[text]

\starttitle[title=Contents]

 \placelist[chapter]

\stoptitle

\starttitle[title=List of Authors in Alphabetical Order]

 \placelistofsorts[author][authors]

\stoptitle

\startchapter

 [title=Text by Ward]
 [name=ward,
  author=Peter D. Ward,
  city=Washington,
  email=ward@sample.com]
 \input ward

\stopchapter

\startchapter

 [title=Text by Zapf]
 [name=zapf,
  author=Hermann Zapf,
  city=Nürnberg,
  date=8. November 1918,
  email=zapf@sample.de]
 \input zapf

\stopchapter

\startchapter

 [title=Text by Bryson]
 [name=bryson,
  author=Bill Bryson,
  city=Norfolk,
  date={December 8, 1951},
  note=best-selling American author]
 \input Bryson

\stopchapter

\startchapter

 [title=Text by Tufte]
 [name=tufte,
  author=Edward R. Tufte,
  city=Kansas City,
  date=1942,
  note=has criticized the way Microsoft PowerPoint is typically used]
 \input tufte

\stopchapter

\stoptext

</techcode>