lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use LaTeX code from manual to include LilyPond-generated TOC?


From: Werner LEMBERG
Subject: Re: How to use LaTeX code from manual to include LilyPond-generated TOC?
Date: Sat, 12 Mar 2022 06:45:19 +0000 (UTC)

>> 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
    }%
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]