1\version "2.21.2"
2
3\header {
4  texidoc = "Page labels may be placed inside music or at top-level,
5and referred to in markups.  Labels created with @code{\\tocItem}
6(and thus bearing an internally-generated unique identifying symbol)
7remain referrable by their user-specified name."
8}
9
10#(set-default-paper-size "a6")
11
12#(define-markup-command (toc-line layout props label text) (symbol? markup?)
13  (interpret-markup layout props
14   (markup #:fill-line (text #:page-ref label "8" "?"))))
15
16\book {
17  \markup \huge \fill-line { \null "Title Page" \null }
18
19  \pageBreak
20
21  \label #'toc
22  \markup \column {
23    \large \fill-line { \null "Table of contents" \null }
24    \toc-line #'toc "Table of contents"
25    \toc-line #'firstScore "First Score"
26    \toc-line #'markA "Mark A"
27    \toc-line #'markB "Mark B"
28    \toc-line #'markC "Mark C"
29    \toc-line #'unknown "Unknown label"
30  }
31
32  \pageBreak
33
34  \label #'firstScore
35  \score {
36    { c'2 c'
37      \mark \markup {
38        A (page \concat { \page-ref #'markA "0" "?" ) }
39      } \label #'markA
40      c' c'
41      \pageBreak
42      \mark "B" \label #'markB
43      d' d'
44      \tocItem parent "This shouldn’t be printed"
45      d' d'
46      \once \override Score.RehearsalMark.break-visibility =
47        #begin-of-line-invisible
48      \mark "C" \label #'markC
49      \tocItem parent.markC "This shouldn’t be printed"
50    }
51    \header { piece = "First score" }
52  }
53}
54