3)
I think the inclusion in the TeX TOC can (now?) be done in a
simpler way
using the catchfile package:
\documentclass{article}
\usepackage{pdfpages,catchfile}
\newcommand\includelilypond[1]{%
\begingroup
\CatchFileDef\currentlilypondtoc{#1.toc}{}
\edef\x{\noexpand\includepdf[pages=-,addtotoc={\currentlilypondtoc}]{#1.pdf}}
\expandafter\endgroup\x
}
\begin{document}
\tableofcontents
\includelilypond{test}
\end{document}
(Answer from
https://tex.stackexchange.com/questions/428239/merge-in-manual-toc-entries-in-a-lualatex-document)
There's only one issue: The TOC will create wrong entries when
LilyPond's
first page number is not 1. So there should actually be an offset
in place.
How can I read the value of the first-page-number variable to set
up this
offset?