I'm trying to create a new lecture environment starting from the base
section.
I'd like its title to be `Lecture : ` if a title is
provided, and `Lecture ` if it isn't. This title should also be
reported in the left footer and in the table of contents.
This is the code I have so far:
```
\definehead
[lecture]
[section]
\setuphead
[lecture]
[
command=\Lecture,
style=\bfc,
]
\setuplabeltext
[lecture={Lecture}]
\define[2]\Lecture{\ctxlua{
userdata.format_lecture_title({
label = context.labeltext('lecture'),
number = [==[#1]==],
title = [==[#2]==],
})
}}
\setupfootertexts
[\ctxlua{
userdata.format_lecture_title({
label = context.labeltext('lecture'),
number = context.getmarking({'lecturenumber'}),
title = context.getmarking({'lecture'}),
})
}]
[pagenumber]
\startluacode
userdata = userdata or {}
function userdata.format_lecture_title(args)
if args.title and args.title ~= '' then
context('%s %s: %s', args.label, args.number, args.title)
else
context('%s %s', args.label, args.number)
end
end
\stopluacode
\setupcombinedlist
[content]
[list={lecture}]
\setuplist
[lecture]
[
alternative=c,
command=\Lecture, % this seems to have no effect?
]
\starttext
\completecontent
% Both title and left footer should be 'Lecture 1: Foo'
\startlecture [title={Foo}]
Foo bar baz
\stoplecture
\page
% Both title and left footer should be 'Lecture 2'
\startlecture []
Foo bar baz
\stoplecture
\stoptext
```
Unfortunately none of them are reported correctly. The title in the body is
formatted simply as `Lecture`, the one in the left footer is formatted as
`Lecture`, and the one in the table of contents isn't
affected at all.
What am I doing wrong?
___
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___