I'm trying to create a new lecture environment starting from the base section. I'd like its title to be `Lecture <number>: <title>` if a title is provided, and `Lecture <number>` 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<number><title>`, and the one in the table of contents isn't affected at all. What am I doing wrong?
noib3 via ntg-context schrieb am 17.08.2021 um 16:43:
I'm trying to create a new lecture environment starting from the base section.
I'd like its title to be `Lecture <number>: <title>` if a title is provided, and `Lecture <number>` 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:
[...]
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<number><title>`, and the one in the table of contents isn't affected at all.
Why do you need Lua to format the list entries and section titles? \definehead [lecture] [section] \define[1]\LectureTextCommand {\doiftext{#1}{: #1}} \setuphead [lecture] [bodypartlabel=lecture, distance=0pt, textcommand=\LectureTextCommand, style=\bfc] \setuplabeltext [en] [lecture={Lecture }] \setupcombinedlist [content] [list={lecture}] \define[3]\LectureListCommand {\labeltext{lecture}#1\doiftext{#2}{: #2}\filler[dotfill]#3\par} \setuplist [lecture] [alternative=command, command=\LectureListCommand] \startsetups [footer:left] \labeltext{lecture} \getmarking[lecturenumber] \doiftext{\getmarking[lecture]}{: \getmarking[lecture]} \stopsetups \setupfootertexts [\directsetup{footer:left}] [] \starttext \completecontent \startlecture [title={Foo}] Foo bar baz \stoplecture \page \startlecture Foo bar baz \stoplecture \stoptext Wolfgang
participants (2)
-
noib3
-
Wolfgang Schuster