Changes

Jump to navigation Jump to search
New page: This is an example which displays horizontal aligned table of contents from luigi: <texcode> \startluacode document.yue = document.yue or {} document.yue.chapter = document.yue.ch...
This is an example which displays horizontal aligned table of contents from luigi:

<texcode>
\startluacode
document.yue = document.yue or {}
document.yue.chapter = document.yue.chapter or {}
document.yue.section = document.yue.section or {}
document.yue.chcount = 0
document.yue.seccount = 0
\stopluacode


\def\ListSectionCommand#1#2#3{#1 #2 #3}

\setupcolors[state=start]
\def\ListChapterCommand#1#2#3%
{\startluacode
document.yue.chcount = document.yue.chcount +1
document.yue.chapter[document.yue.chcount] = "{\\red\\switchtobodyfont[55pt]\\os #1} {\\blue\\switchtobodyfont[34pt] #2}"
\stopluacode%
}


\def\PlaceContent%
{\startluacode
tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end
format = string.format
local tab
tab = ""
if document.yue.chcount > 0
then
for i=1,document.yue.chcount do
tab = tab.."\|p"
end
tab = tab.."\|"
tprint("\\starttabulate["..tab.."]")
for i=1,document.yue.chcount do
tprint("\\NC
"..document.yue.chapter[i].."\\vskip8pt"..format("\\placelist[section][criterium=chapter,number=\%i,before=,after=\\vskip2pt]",i))
end
tprint("\\NC\\NR")
tprint("\\stoptabulate")
end
\stopluacode
}

\setuplist[section][alternative=none,command=\ListSectionCommand]
\setuplist[chapter][alternative=none,command=\ListChapterCommand]

\setuppapersize [A4,landscape][A4,landscape]
\starttext
\setupbackgrounds[page][backgound=color,backgroundcolor=darkyellow]
%% Do nothing except store chapters

\framed[height=6cm,frame=off,align=middle,top=\vss,bottom=]{\switchtobodyfont[ss, 55pt] \darkgreen Table of Contents}
{ \magenta
\switchtobodyfont[ss,21pt]
\placelist[chapter]%
\PlaceContent
}

\chapter{first} \section{AA}\dorecurse{10}{\input tufte} \section{BB} \dorecurse{10}{\input knuth}
\chapter{second} \section{CC} \dorecurse{10}{\input zapf}\section{DD} \dorecurse{10}{\input bryson}
\chapter{third} \section{EE} \dorecurse{10}{\input ward}
\stoptext
</texcode>

--[[User:58.35.85.255|58.35.85.255]] 06:37, 2 September 2008 (CEST)yue wang
Anonymous user

Navigation menu