How can I add a TOC entry from inside a markup (or from a markup function)? 

I tried 
#(define-markup-command (piece-title layout props title) (markup?)
  (add-toc-item! 'tocItemMarkup title)
  (interpret-markup layout props (markup #:bold title))
)
but that does not add anything to the TOC :-(((

Nicolas' workaround is to call collect-music-for-book: 

#(define-public (add-toc-item parser markup-symbol text)
  (collect-music-for-book parser
   (add-toc-item! markup-symbol text)))

but for this approach I need the parser, which I do not have available in the 
markup command..
The reason I want this is that I automatically want all score titles to appear 
in the TOC, without having to duplicate the titles and manually insert loads 
of tocItem calls. 




Similarly, how can I add a reference to a position inside a markup? I tried
    \markup { Some interesting point \label #'refA. }
    \pageBreak
    \markup { As mentioned on page \page-ref #'refA "0" "?", there is 
      something interesting. }
but this only give a syntax error (syntax error, unexpected MUSIC_FUNCTION).

Of course, this example is stripped down and thus trivial and should better be 
written with \label outside the markup, but I have a preface with ~6 pages 
consisting of one \markuplines (the long biography of the composer and 
description of the work) and want to reference one thing mentioned in there 
later on in the score.


So, how can I add a TOC entry and a label from inside a markup function (both 
are really just the same problem)? A sample lilypond file is attached.

Thanks,
Reinhold
-- 
------------------------------------------------------------------
Reinhold Kainhofer, Vienna University of Technology, Austria
email: [EMAIL PROTECTED], http://reinhold.kainhofer.com/
 * Financial and Actuarial Mathematics, TU Wien, http://www.fam.tuwien.ac.at/
 * K Desktop Environment, http://www.kde.org, KOrganizer maintainer
 * Chorvereinigung "Jung-Wien", http://www.jung-wien.at/
\version "2.11.46"

\header { title = "Test title " }

%%% Nicolas' solution needs the parser:
% #(define-public (add-toc-item parser markup-symbol text)
%   (collect-music-for-book parser
%    (add-toc-item! markup-symbol text)))
%%% How do I get the parser from inside a markup command?

#(define-markup-command (piece-title layout props title) (markup?)
  (add-toc-item! 'tocItemMarkup title)
  (interpret-markup layout props (markup #:bold title))
)


\paper {
  % Doesn't work...
  scoreTitleMarkup = \markup \piece-title \fromproperty #'header:piece
}


\markuplines \table-of-contents
\pageBreak
    
% Doesn't work...
\markup\piece-title "Something"
% Works:
#(add-toc-item! 'tocItemMarkup "Irgendwas")
  
\score { \relative c'' {c4 d c d}
  \header { piece = "Nr. 1 - Text" }
}

\score { \relative c'' {c4 d c d}
  \header { piece = "Nr. 2 - Was anderes" }
}


%%%%%%%%%
% Problem with adding a label inside a markup:
\markup { Some interesting point \label #'refA. }
\pageBreak
\markup { As mentioned on page \page-ref #'refB "0" "?", there is something interesting. }

Attachment: toc.pdf
Description: Adobe PDF document

_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to