Difference between revisions of "Generate Authorlist from Head Content"

From Wiki
Jump to navigation Jump to search
m
 
(8 intermediate revisions by 3 users not shown)
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]\ChapterHead
+
\define[2]\MyChapCMD
  {\startframedtext[frame=off,width=broad,offset=0pt,align=middle]
+
{#1\enspace #2
    \doifsomething
+
  {\doifsomething
      {\structureuservariable{date}}
+
      {\structureuservariable{author}}
      {\structureuservariable{date}\blank}
+
      \expanded{\author
      #2
+
        [\structureuservariable{name}] % -> sorted by "name"-variable
    \doifsomething
+
        {\bTABLE[width=broad]
      {\structureuservariable{author}}
+
          \bTR
      {\blank\structureuservariable{author}}
+
            \bTD \structureuservariable{author} \eTD
  \stopframedtext}
+
            \bTD \structureuservariable{city}   \eTD
 +
            \bTD \structureuservariable{date}   \eTD
 +
            \bTD \structureuservariable{email} \eTD
 +
            \bTD \structureuservariable{note}   \eTD
 +
          \eTR
 +
        \eTABLE\nointerlineskip}%
 +
        \tfxx (\structureuservariable{author}, \structureuservariable{city})}}}
  
\setuphead
+
\define[3]\MyChapListCMD
   [chapter]
+
   {#1 #2 (\structurelistuservariable{author})\hfill  #3\blank}
  [command=\ChapterHead]
+
 
 +
 
 +
\starttext  \showframe[text]
 +
 
 +
\starttitle[title=Contents]
 +
  \placelist[chapter]
 +
\stoptitle
 +
 
 +
\starttitle[title=List of Authors in Alphabetical Order]
 +
  \placelistofauthors
 +
\stoptitle
  
 +
\startchapter
 +
  [title=Text by Ward]
 +
  [name=ward,
 +
  author=Peter D. Ward,
 +
  city=Washington,
 +
  email=ward@sample.com]
  
\starttext
+
  \input ward
 +
\stopchapter
  
\completecontent
+
\startchapter
 +
  [title=Text by Zapf]
 +
  [name=zapf,
 +
  author=Hermann Zapf,
 +
  city=Nürnberg,
 +
  date=8. November 1918,
 +
  email=zapf@sample.de]
  
\startchapter[title=Rom][date=12.06.2010,author=Knuth]
+
   \input zapf
   \input knuth
 
 
\stopchapter
 
\stopchapter
  
\startchapter[title=Pisa][date=14.06.2010,author=Tufte]
+
\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
 
   \input tufte
 
\stopchapter
 
\stopchapter
  
 
\stoptext
 
\stoptext
 +
 
</texcode>
 
</texcode>
 +
 +
[[Category:Sample documents]]

Latest revision as of 14:24, 8 June 2020

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

\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}}
      \expanded{\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]
  \placelistofauthors
\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