lilypond-user
[Top][All Lists]
Advanced

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

Re: Make TOC entries available to LaTeX


From: Thomas Morley
Subject: Re: Make TOC entries available to LaTeX
Date: Thu, 26 Apr 2018 22:57:48 +0200

2018-04-26 8:48 GMT+02:00 Urs Liska <address@hidden>:
> Hi Harm,
>
> thanks for looking into this.
>
>
> Am 25.04.2018 um 23:13 schrieb Thomas Morley:
>>
>> 2018-04-25 16:00 GMT+02:00 Urs Liska <address@hidden>:
>> ...
>>>
>>> 2)
>>> Assuming the TOC items are created using \tocItem then it should be
>>> guaranteed that there is the same label present as key in both
>>> label-table
>>> and one of the (toc-items) sublists. So (IISC) several further checks
>>> could
>>> be removed additionally (or am I missing something?):
>>>
>>>               (let* ((label (car toc-item))
>>>                      (text  (caddr toc-item))
>>>                      (page (assoc-ref label-table label)))
>>>
>>> should be sufficient? Therefore the whole function could be written as
>>
>> Being always paranoid, I would do some thorough testings.
>
>
> OK, I've found the case where my assumption would break. A rare (and
> pointless) case but an existing one:
>
> %%%
> #(define (oly:create-toc-file layout pages)
>    (format #t "label-page-table:\n~a\n" (ly:output-def-lookup layout
> 'label-page-table))
>    (format #t "toc-items:\n~a\n" (toc-items)))
>
> \paper {
>   #(define (page-post-process layout pages) (oly:create-toc-file layout
> pages))
> }
>
>
> \tocItem \markup "A TOC entry"
> {
>   c'
> }
>
> \tocItem \markup "Another TOC entry"
> %%%
>
>
> The \tocItem without anything following it will create an entry in the
> toc-items list but no label. So this second simplification won't work
> reliably.

I think I've seen usecases for this. So better be prepared to deal with it.

>
>> ...
>>
>>> 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?
>>
>> page-post-process has the layout-variable.
>> (ly:output-def-lookup layout 'first-page-number) should do the trick.
>
>
> Thanks, this works.
> What do you think: this example code is much easier to understand than the
> one currently in the manual. Should I propose an update?


Would be very nice.
You noticed my other mail about relying on "ancester-layout"?
Should be implemented as well.

Though, I don't have the knowledge to judge the Tex-coding.

Cheers,
  Harm



reply via email to

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