lilypond-user
[Top][All Lists]
Advanced

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

Re: Footnotes documentation


From: David Kastrup
Subject: Re: Footnotes documentation
Date: Sun, 11 Dec 2011 08:06:50 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

"address@hidden" <address@hidden> writes:

> Le Dec 10, 2011 à 9:18 PM, David Kastrup a écrit :
>
>>> 
>> 
>> Why don't we have \footnote \default for autonumbering (just like with
>> \mark),
>
> We could...I don't understand how \default works, so I'm not sure how
> to make it work here, but a tutorial would get me on my way!

Have you read "Scheme function usage" in EG?

Anyway, let's take a look at two contenders:

autoFootnoteGrob =
#(define-music-function (parser location grob-name offset footnote)
   (symbol? number-pair? markup?)
   (_i "Footnote @var{grob-name} with the text in @var{footnote}
allowing for the footnote to be automatically numbered such that
the number appears at @var{offset}.  Note that, for this to take effect,
auto-numbering must be turned on in the paper block.  Otherwise, no
number will appear.  Use like @code{\\once})")
   (make-music 'FootnoteEvent
               'automatically-numbered #t
               'symbol grob-name
               'X-offset (car offset)
               'Y-offset (cdr offset)
               'text (make-null-markup)
               'footnote-text footnote))


footnote =
#(define-music-function (parser location offset text footnote)
   (number-pair? markup? markup?)
   (_i "Attach @var{text} at @var{offset} with @var{text} referring
to @var{footnote} (use like @code{\\tweak})")
   (make-music 'FootnoteEvent
               'automatically-numbered #f
               'X-offset (car offset)
               'Y-offset (cdr offset)
               'text text
               'footnote-text footnote))

There is an optional argument before number-pair giving the symbol, and
an optional markup text before the footnote.  So we do

footnote =
#(define-music-function (parser location grob-name offset text footnote)
   ((symbol? '()) number-pair? (markup?) markup?)
   (_i "Attach @var{text} at @var{offset} with @var{text} referring
to @var{footnote} (use like @code{\\tweak})")
   (make-music 'FootnoteEvent
               'automatically-numbered (not text)
               'symbol grob-name
               'X-offset (car offset)
               'Y-offset (cdr offset)
               'text (or text (make-null-markup))
               'footnote-text footnote))

And there you are.  If you write a symbol before your offset, that is
used as the grob-name.  If you write \default as the text, then the
footnote is automatically numbered (there is no other way than writing
\default to skip an optional argument before another argument of
identical type, or you could also just leave out the optional argument
like you do with the grob name).

The difference between grob-name and text here is that the first gets
specified with a default value of '() in case the argument is not given
(because that is just what LilyPond uses for unset arguments) while text
just takes the default default of #f since that is easiest to check for
and we need it in two places.  Can't be confused with an explicit
argument of #f since that would not make it through argument type
checking.

So there: your personal tutorial, and you get 1 function and interface
instead of 4.  I have no idea why that was hard to do from the existing
documentation, so it is your task to change the existing documentation
in a way that would have made it possible for you to do this.

Deal?

-- 
David Kastrup



reply via email to

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