>> https://lilypond.org/doc/v2.23/Documentation/usage/sharing-the-table-of-contents.html > > Here is an enhanced replacement.
Here is an even more enhanced replacement that allows formatting commands in the TOC entries, for example ``` 2, section, 1, {\emph{B}}, toc97 ``` Werner ====================================================================== \usepackage{catchfile} \usepackage{etoolbox} \usepackage{pdfpages} \usepackage{xifthen} % Include a LilyPond score with an optional table of contents. % This macro is a wrapper for the `\includepdf` command from the % 'pdfpages' LaTeX package. % % Syntax: % % \includescore{scorefile} % \include[tocfile]{scorefile} % % `scorefile` is the name of a PDF file. `tocfile` is the name % of a file containing entries for the master file's table of % contents; see option 'addtotoc' in the 'pdfpages' % documentation for the exact syntax. \newcommand{\includescore}[2][]{% \ifthenelse{\isempty{#1}} {\includepdf[pages=-]{#2}} {\CatchFileDef{\IStoclines}{#1}{}% \begingroup\edef\x{\endgroup \noexpand\includepdf[pages=-, addtotoc={\expandonce\IStoclines}] {#2}}% \x }% }