Hi Brent, you could simply delay the execution of your code until the point where you need it like this:
bpI = #(define-scheme-function (parser location) () #{ \bookpart { \tocItem "toc1" "a" { c' } } #}) bpII = #(define-scheme-function (parser location) () #{ \bookpart { \tocItem "toc2" "b" { d' } } #}) \markuplist \table-of-contents $(bpII) $(bpI) (Sorry for the mess, I'm writing from my phone.) Cheers, Valentin 24.09.2022 13:36:04 Brent Annable <brentanna...@gmail.com>: > Hi all, > > I'm creating a book of music using a master file where I call on \bookpart > variables from lots of different files, which are included in the master file > using the \include function. I have a list of included files in a separate > file, and the master just includes that one file. > > I want to create a table of contents at the beginning of the book, so I need > to add a \tocItem to each score. The only place I have found where that works > is inside the \bookpart variable in each individual file, before the score. > So in my master file, each score entry looks like this: > > \bookpart { \myBookPart } > > And the variables in the individual files look like this: > > myBookPart = \bookpart { \tocItem \markup "Name of song" > {c1 c1 c1 c1} > } > > I'm currently putting all the separate scores into the master file, and I > plan to shuffle them around later to get the ordering right. > > I've noticed that when the table of contents is generated, the items are > always listed *in the order in which the files are \included*, not the order > in which the scores actually appear in the book. So even though the page > numbers are correct, the TOC lists the songs in the order in which I include > the files in the \include file. When I start shifting things around later in > the master, I really don't want to have to re-order the \include list as > well, that will be double the work. > > I've attached some files that replicate my problem. One thing I noticed that > the master wouldn't compile at all when the version number was set to 2.22.1, > it only worked when I set it to 2.19.65, the version number in all the files > I'm using. Does that mean I'm using incorrect syntax for the TOC? > > Otherwise, is there anywhere else I can put the \tocItem command so that the > items are automatically re-ordered when I switch them around in the master > file? > > Sorry for the voluminous email and thanks for any help, > > Brent. > >