Difference between revisions of "Generate Authorlist from Head Content"

From Wiki
Jump to navigation Jump to search
Line 1: Line 1:
== Environment for a German diploma thesis ==
+
==User Content in Heads and  Table of Contents==
  
This layout do not match the guidelines from the university.
+
With the new head syntax (MkIV) one can easy add information to chapters, sections, etc.
 +
 
 +
Here is an example from Wolfgang Schuster ([http://archive.contextgarden.net/message/20100919.163604.e1f8cb40.en.html])
  
 
<texcode>
 
<texcode>
 +
\define[3]\ChapterList
 +
{\bTABLE[offset=0pt,strut=yes,frame=off,width=.5\textwidth]
 +
    \bTR
 +
      \bTD \structurelistuservariable{date} \eTD
 +
      \bTD #2 \eTD
 +
      \bTD (\structurelistuservariable{author}) \eTD
 +
    \eTR
 +
  \eTABLE}
  
\startenvironment env-diplom
+
\setuplist
 
+
   [chapter]
 
+
   [alternative=command,
%%%% Language-settings: hyphenation, etc.
+
   command=\ChapterList]
 
 
 
 
\setuplanguage
 
  [de]
 
  [rightquotation=«,leftquotation=», % use guillemets
 
  rightquote=‹,leftquote=›,
 
  lefthyphenmin=2,  % default: (left|right)hyphenmin=3 (-> lang-ger.tex)
 
  righthyphenmin=2] % z.B. Glau-be
 
   
 
\hyphenation{Ta-d-schi-ki-s-tan}
 
\hyphenation{Kir-gi-si-s-tan}
 
 
 
\mainlanguage[de]
 
 
 
\setupquotation[method=font] % otherwise no expansion, protruding
 
 
 
\definesymbol[1][•] % otherwise lmr is used
 
 
 
\setbreakpoints[compound] % hyphenate compound words
 
 
 
 
 
%% Colors
 
 
 
\definecolor[headcolor]  [s=.1]
 
\definecolor[subheadcolor][s=.3]
 
\definecolor[refcolor]    [r=.5]
 
 
 
 
 
 
 
%%%% Draft-mode (debugging, etc.)
 
 
 
 
 
\startmode[draft] % -> \enablemode[draft]
 
  \synctex=1
 
  % \hbadness=10000 % don't complain underfull hboxes
 
  % \version[temporary] % final|concept|temporary -> Error
 
  \overfullrule=6pt
 
 
 
  \definepalet[layout][grid=blue:4,page=green]
 
 
 
  % \showframe[text] % []
 
  \showgrid
 
 
 
  % \setuppapersize[A4][A4,oversized]
 
 
 
  %% Show 8mm BCOR (Binderand)
 
 
 
  \definelayer
 
    [page]
 
    [width=\paperwidth,
 
    height=\paperheight]
 
 
 
  \setupbackgrounds [leftpage]  [background=page]
 
  \setupbackgrounds [rightpage] [background=page]
 
 
 
  \startsetups binderand:links
 
    \setlayerframed
 
      [page]
 
      [preset=middleright]
 
      [frame=off,
 
      background=color,
 
      backgroundcolor=lightgray,
 
      width=8mm,
 
      height=\paperheight]{}
 
  \stopsetups
 
 
 
  \startsetups binderand:rechts
 
    \setlayerframed
 
      [page]
 
      [preset=middleleft]
 
      [frame=off,
 
      background=color,
 
      backgroundcolor=lightgray,
 
      width=8mm,
 
      height=\paperheight]{}
 
  \stopsetups
 
   
 
  \setupbackgrounds [leftpage]  [setups=binderand:links]
 
  \setupbackgrounds [rightpage] [setups=binderand:rechts]
 
\stopmode
 
 
 
 
 
%% Interaction (references etc.)
 
 
 
\setupinteraction
 
  [state=start,
 
  color=refcolor,
 
  contrastcolor=green,
 
  style=normal, % otherwise bold
 
  title={Gesellschaftsbilder und Selbstverständnis russlanddeutscher
 
    Aussiedler in der Sowjetunion und in Deutschland},
 
  subject={Diplomarbeit in Erziehungswissenschaft, Sozialpädagogik,
 
    Sozialarbeit}, % -> not recognized, why?
 
  keywords={Diplomarbeit in Erziehungswissenschaft, Sozialpädagogik,
 
    Sozialarbeit}, % -> not recognized, why?
 
  author=Katharina Harder] % \getvariable{Diplom}{author}
 
    
 
% \setupinteractionscreen[option=doublesided] % viewer dependent
 
 
 
\placebookmarks[chapter,appchapter,section,appsection,subsection]
 
 
 
 
 
 
 
%%%% Layout
 
 
 
 
 
% | Bund-/Innensteg | Außensteg  | Kopfsteg  | Fußsteg      |
 
% | (backspace)    | (cutspace) | (topspace) | (bottomspace) |
 
% |-----------------+------------+------------+---------------|
 
% | 12.5mm + 8mm    | 22.5mm    | 19.5mm    | 32.5mm        |
 
% | 10mm  + 8mm    | 20mm      | 15mm      | 25mm          |
 
 
 
\setuplayout % default-layout
 
  [width=middle,
 
  height=fit,
 
  topspace=12mm,        % Kopfsteg: 15mm
 
  header=10mm,          % + 10mm Kopf
 
  footer=\headerheight, % Fuß: 10mm + 15mm Fußsteg
 
  backspace=18mm,      % 12.5mm Innensteg + 8mm Binderand
 
  cutspace=20mm,        % Außensteg: 22.5mm
 
  margin=10mm,
 
  margindistance=10pt,
 
  location=doublesided, % if oversized
 
  % lines=59, % 60
 
  grid=tolerant]  
 
 
 
 
 
%% Front part layout: inherit all settings besides back- and cutspace
 
 
 
\definelayout [frontpart] [backspace=30.5mm,cutspace=32.5mm]
 
\definelayout [default]   [] % default-layout
 
 
 
 
 
\setupalign[stretch,hz,hanging,verytolerant]
 
 
 
\setupindenting[small,next,yes]
 
 
 
\setupcolumns[distance=1.2em]
 
 
 
%% alternative with columnsets (-> manual balancing)
 
\definecolumnset[two][distance=1em,balancing=yes]
 
% \setupcolumnsetlines[two][page][column][line]
 
 
 
 
 
%% Page numbering
 
 
 
\setuppagenumbering[location=,alternative=doublesided]
 
 
 
\setupuserpagenumber[numberconversionset=pagenumber]
 
 
 
 
 
%% empty page on last chapter pages
 
 
 
\setupsectionblock [frontpart] [page=mychapterpagebreak]
 
\setupsectionblock [appendix]  [page=mychapterpagebreak]
 
\setupsectionblock [bodypart]  [page=mychapterpagebreak]
 
 
 
 
 
%% different layouts for different parts
 
 
 
\startsectionblockenvironment[frontpart] % -> frontmatter
 
  \setuplayout[grid=no]
 
  \setuplayout[frontpart]
 
  \setupuserpagenumber[numberconversion=romannumerals,start=3]
 
  \setupheadertexts[][\setups{rechte:Seite}][\setups{linke:Seite:Anfang}][]
 
\stopsectionblockenvironment
 
 
 
\startsectionblockenvironment[bodypart] % -> bodymatter
 
  \setuplayout[grid=tolerant]
 
  \setuplayout[default]
 
  \setuppagenumber[number=1]
 
  \setupheadertexts[][\setups{rechte:Seite}][\setups{linke:Seite:Hauptteil}][]
 
  \def\Kapitel{Kapitel}
 
\stopsectionblockenvironment
 
 
 
\startsectionblockenvironment[appendix] % -> appendices
 
  \setupheadertexts[][\setups{rechte:Seite}][\setups{linke:Seite:Hauptteil}][]
 
  \def\Kapitel{Anhang}
 
\stopsectionblockenvironment
 
 
 
 
 
%% manualy adjust the inter-word spacing to achieve better (page) breaks
 
%% (perhaps there are better methods!?)
 
 
 
\definetolerancemethod % default space: 2.5pt
 
  [horizontal] [myspace] % .3em ~ 3pt
 
  {\spaceskip.3em plus.2em minus.15em\relax}
 
 
 
\definestartstop
 
  [SloppyPar] % \setuptolerance[myspace,stretch]
 
  [before=\start\doifmode{draft}{\red}, % -> adjust with \looseless±1
 
  after=\stop]
 
 
 
 
 
 
 
%%%% Fonts
 
 
 
 
 
\doiffontpresentelse{LinLibertineO}{\enablemode[Libertine]}{\enablemode[Termes]}
 
 
 
\startmode[Libertine]  % Linux Libertine (Serif) and Linux Biolinum (Sans)
 
  \usetypescriptfile[type-linlibertine]
 
 
 
  \usetypescript[libertine]
 
  \setupbodyfont[libertine,10pt]
 
 
 
  \setupinterlinespace[height=.8,depth=.2,line=2.8ex,stretch=0]
 
\stopmode
 
 
 
\startmode[Termes]  % TeX Gyre Termes (Serif) and TeX Gyre Heros (Sans)
 
  \usetypescript[termes,heros]
 
  \setupbodyfont[termes,10pt]
 
\stopmode
 
 
 
 
 
%% Fonts for heads etc.
 
 
 
\definefont[TitlFont][Serif sa d] % \tfd
 
\definefont[SubjFont][Serif sa b] % \tfb
 
\definefont[NameFont][Serif sa a] % \tfa
 
\definefont[CovrFont][Serif sa a] % \tfa
 
 
 
\definefont[ChapFont][SansBold sa c]    % \ssbfc
 
\definefont[SecFont] [SansBold sa a]    % \ssbfa
 
\definefont[SectFont][SansBold]        % \ssbf
 
\definefont[SubsFont][SansBold]        % \ssbf
 
\definefont[SsubFont][SansBold]        % \ssbf
 
\definefont[ChapNumF][SerifItalic sa a] % \it
 
 
 
 
 
 
 
%%%% Headers
 
 
 
 
 
\def\Seitennummer{\setff{sc}\strut\userpagenumber}
 
 
 
\definetext[ChapterFoot][footer][\Seitennummer]
 
 
 
 
 
\setupframed
 
  [width=broad,
 
  depth=1pt, % -> boffset don't work, why?
 
  frame=off,
 
  bottomframe=on,
 
  framecolor=headcolor,
 
  offset=overlay]
 
 
 
\startsetups linke:Seite:Anfang % -> left page frontmatter-sectionblock
 
  \framed[align=right]{\Seitennummer \hskip3em {\itx \getmarking[chapter]}}
 
\stopsetups
 
 
 
\startsetups linke:Seite:Hauptteil % -> left page bodymatter-sectionblock
 
  \framed[align=right]{\Seitennummer \hskip3em {\itx
 
      {\setff{csc}\WORD{\Kapitel}\space\getmarking[chapternumber]}
 
      \emspace\getmarking[chapter]}}
 
\stopsetups
 
 
 
\startsetups rechte:Seite % -> right page in all sectionblocks
 
  \framed[align=left]{{\itx \getmarking[section]} \hskip3em \Seitennummer}
 
\stopsetups
 
 
 
 
 
 
 
%%%% Heads
 
 
 
 
 
\newsignal\SectionSignal % adds a very small space (use it as a tag)
 
 
 
\def\TestSpace% to reduce the vertical space between two consecutive heads
 
  {\relax\ifdim\lastskip=\SectionSignal \blank[nowhite]
 
  \else \blank \fi}
 
 
 
 
 
%% own head placement
 
 
 
\setupframed
 
  [depth=\zeropoint,
 
  bottomframe=off,
 
  top=\vfill,
 
   bottom=\vfill\vfill]
 
 
 
\def\MyChapCmd#1#2%
 
  {\framed[align=middle,height=6\lineheight]
 
  {{\ChapNumF\Kapitel\,~#1}\blank #2}}
 
 
 
\def\MySubsubsubsecCmd#1#2%
 
  {\framed[align=right]{#1#2}}
 
 
 
  
%% new heads in appendix
+
\define[2]\ChapterHead
 +
  {\startframedtext[frame=off,width=broad,offset=0pt,align=middle]
 +
    \doifsomething
 +
      {\structureuservariable{date}}
 +
      {\structureuservariable{date}\blank}
 +
      #2
 +
    \doifsomething
 +
      {\structureuservariable{author}}
 +
      {\blank\structureuservariable{author}}
 +
  \stopframedtext}
  
\definehead [appchapter] [chapter]
+
\setuphead
\definehead [appsection] [section]
 
 
 
\definepagebreak % empty pages without header and footer
 
  [mychapterpagebreak]
 
  [yes,header,footer,right]
 
 
 
 
 
\setupheads[align=right] % align={right,nothyphenated}
 
 
 
\setuphead % Level 1
 
 
   [chapter]
 
   [chapter]
  [header=empty,
+
   [command=\ChapterHead]
  footer=ChapterFoot,
 
  page=mychapterpagebreak,
 
  grid=high,
 
  textstyle=\ChapFont,
 
  numberstyle=\ChapNumF,
 
  command=\MyChapCmd,
 
  color=headcolor]
 
 
 
\setuphead % Level 1
 
  [title]
 
  [header=empty,
 
  alternative=middle,
 
  before={\blank[force]},
 
  after={\blank[2*big]},
 
  color=headcolor,
 
  textstyle=\ChapFont,
 
  command=\normalplacehead]
 
 
 
\setuphead % Level 2
 
  [section,appsection]
 
  [grid=high,
 
  alternative=normal,
 
  after=\vskip\SectionSignal,
 
  style=\SecFont, % \setupinterlinespace[2.6ex] -> disturbs the grid
 
  color=headcolor]
 
 
 
\setuphead % Level 3
 
  [subsection,subsubject]
 
  [before=\TestSpace,
 
  style=\SectFont,
 
  color=headcolor]
 
 
 
\setuphead % Level 4
 
  [subsubsection,subsubsubject]
 
  [before=\blank,
 
  after=\vskip\SectionSignal,
 
  style=\SubsFont,
 
  color=headcolor]
 
 
 
\setuphead % Level 5
 
  [subsubsubsection,subsubsubsubject]
 
  [grid=high,
 
  % alternative=MySecPlacement,
 
  command=\MySubsubsubsecCmd,
 
  before=\TestSpace,
 
  after=\vskip\SectionSignal,
 
  color=subheadcolor,
 
  number=no]
 
 
 
 
 
 
 
%%%% Table of contents
 
 
 
 
 
\setupheadtext[de][content=Inhaltsverzeichnis] % default: Inhalt
 
 
 
\definecombinedlist
 
  [content]
 
  [chapter,section,subsection,subsubsection,subsubsubsection]
 
  [criterium=all,
 
  numberstyle=,
 
  pagestyle=]
 
 
 
\setupcombinedlist
 
  [content]
 
  [numberstyle=\setff{tnum}] 
 
 
\definecombinedlist
 
  [appendix-content]
 
  [appchapter,appsection]
 
  [level=appsection,criterium=all]
 
 
 
 
 
\setuplist
 
  [chapter,appchapter]
 
  [style=\bf,
 
  before={\blank[2*big]},
 
  after=\blank,
 
  pagenumber=yes,
 
  headnumber=no]
 
 
 
\setuplist
 
  [section,appsection]
 
  [alternative=c]
 
 
 
\setuplist
 
  [subsection,subsubsection]
 
  [before={\blank[medium]},
 
  after={\blank[small]},
 
  width=3em,
 
  alternative=c]
 
 
 
\setuplist
 
  [subsubsubsection]
 
  [alternative=d,
 
  align={right,hz},
 
  margin=3em,
 
  style=\it,
 
  pagestopper={~\subheadcolor\char"25A0}]
 
 
 
 
 
 
 
%%%% Citatations and footnotes
 
 
 
 
 
\def\ellipsis{[…] } % otherwise [] is seen as option (-> blockquote)
 
 
 
% to avoid doubled reference-labels inside blockquote-environments
 
% with \getMyCite, redefine them (-> page-lin.mkiv)
 
\def\mystartlinereference#1{\mksomelinereference{#1}{lra:b:#1}{\mkshowstartlinereference{#1}}\ignorespaces}
 
\def\mystoplinereference #1{\removeunwantedspaces\mksomelinereference{#1}{lra:e:#1}{\mkshowstoplinereference{#1}}}
 
 
 
\startsetups blockquote:setup
 
  \setupindenting[no]%
 
  \let\mkstartlinereference\mystartlinereference
 
  \let\mkstoplinereference\mystoplinereference 
 
\stopsetups
 
 
 
\setupdelimitedtext
 
  [blockquote]
 
  [before=\setups{blockquote:setup},
 
  leftmargin=1em,
 
  rightmargin=0em, 
 
  spaceafter=,]
 
 
 
\setupnote
 
  [footnote]
 
   [command=,  % -> numbercommand
 
  textstyle=, % -> textcommand
 
  location=lastcolumn,
 
  align={hz,hanging,stretch},
 
  margindistance=0.125em,
 
  numbercommand=\setff{sups}, % use superscript-figures
 
  textcommand=\setff{sups}]
 
 
 
 
 
 
 
%%%% Miscellaneous
 
 
 
 
 
%% smaller thinspace (-> \,)
 
\def\thinspace{\kern.5\interwordspace} % \let\,\thinspace
 
 
 
\def\Paraphe{} % initials
 
\def\Antwort{{\bf \Paraphe:}\ \ }
 
\def\Frage{{\bf I:}\ \ }
 
 
 
 
 
%% Quote from appendix
 
 
 
\setuplinenumbering
 
  [color=subheadcolor,
 
  step=5,
 
  style={\setff{lf}\tfxx}] % use lining figures
 
 
 
\definestartstop
 
  [Linenumbering] % no indenting in line-numbered text
 
  [before={\startlinenumbering\setupindenting[no]},
 
  after=\stoplinenumbering]
 
 
 
 
 
\def\startMyCite[#1]% with help form Wolfgang Schuster
 
  {\def\stopMyCite
 
    {\startline[#1]\getbuffer[#1]\stopline[#1]\savebuffer[#1]}%
 
    \dostartbuffer[#1][startMyCite][stopMyCite]}
 
 
 
\def\getMyCite[#1]{%\doifmode{draft}{\inothermargin{{\darkred Zitat\blank #1}}}
 
  \ReadFile{\jobname-#1.tmp} (\at{S.\!}[lr:b:#1], \inline{Z.\!}[#1])}
 
 
 
 
 
  
%%%% Bibliography (not used)
 
  
 +
\starttext
  
\stopenvironment
+
\completecontent
  
%%% Local Variables:
+
\startchapter[title=Rom][date=12.06.2010,author=Knuth]
%%% mode: context
+
  \input knuth
%%% TeX-master: t
+
\stopchapter
%%% End:
 
  
 +
\startchapter[title=Pisa][date=14.06.2010,author=Tufte]
 +
  \input tufte
 +
\stopchapter
  
 +
\stoptext
 
</texcode>
 
</texcode>

Revision as of 23:19, 29 September 2010

User Content in Heads and Table of Contents

With the new head syntax (MkIV) one can easy add information to chapters, sections, etc.

Here is an example from Wolfgang Schuster ([1])

\define[3]\ChapterList
 {\bTABLE[offset=0pt,strut=yes,frame=off,width=.5\textwidth]
    \bTR
      \bTD \structurelistuservariable{date} \eTD
      \bTD #2 \eTD
      \bTD (\structurelistuservariable{author}) \eTD
    \eTR
  \eTABLE}

\setuplist
  [chapter]
  [alternative=command,
   command=\ChapterList]

\define[2]\ChapterHead
  {\startframedtext[frame=off,width=broad,offset=0pt,align=middle]
     \doifsomething
       {\structureuservariable{date}}
       {\structureuservariable{date}\blank}
       #2
     \doifsomething
       {\structureuservariable{author}}
       {\blank\structureuservariable{author}}
   \stopframedtext}

\setuphead
  [chapter]
  [command=\ChapterHead]


\starttext

\completecontent

\startchapter[title=Rom][date=12.06.2010,author=Knuth]
  \input knuth
\stopchapter

\startchapter[title=Pisa][date=14.06.2010,author=Tufte]
  \input tufte
\stopchapter

\stoptext