put footnote in a variable

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

put footnote in a variable

Gianmaria Lari
I have the following code:

\version "2.19.81"
\fixed c' {
  \time 3/4 
  c c c

  \once \override Score.FootnoteItem.annotation-line = ##f 
  \footnote \markup\huge { * } #'(0 . 5) \markup {\lower #0.8 { \super { * } }
     "The second time play the measure as " \raise #0.5
    \score {
      \new Staff \with {
        \remove "Time_signature_engraver"
        fontSize = #-3
        \override StaffSymbol.staff-space = #(magstep -3)
        \override StaffSymbol.thickness = #(magstep -3)
        firstClef = ##f
      }
      \fixed c' {f2 e4}
      \layout { indent = 0\cm ragged-last = ##t}
    }
  } 
  
  e2 f4
  
  c c c
}

Is there any way to put all the code related to the footnote in a variable? For example if possible I would like to write something like this:

\version "2.19.81"
\fixed c' {
  \time 3/4 
  c c c

  \myfootnote e2 f4
  
  c c c
}

and of course 

myfootnote =   {
\once \override Score.FootnoteItem.annotation-line = ##f 
  \footnote \markup\huge { * } #'(0 . 5) \markup {\lower #0.8 { \super { * } }
     "The second time play the measure as " \raise #0.5
    \score {
      \new Staff \with {
        \remove "Time_signature_engraver"
        fontSize = #-3
        \override StaffSymbol.staff-space = #(magstep -3)
        \override StaffSymbol.thickness = #(magstep -3)
        firstClef = ##f
      }
      \fixed c' {f2 e4}
      \layout { indent = 0\cm ragged-last = ##t}
    }
  } 
}

Thank you, g.

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: put footnote in a variable

Aaron Hill
On 2018-11-01 1:04 am, Gianmaria Lari wrote:

> I have the following code:
>
> \version "2.19.81"
> \fixed c' {
>   \time 3/4
>   c c c
>
>   \once \override Score.FootnoteItem.annotation-line = ##f
>   \footnote \markup\huge { * } #'(0 . 5) \markup {\lower #0.8 { \super
> { *
> } }
>      "The second time play the measure as " \raise #0.5
>     \score {
>       \new Staff \with {
>         \remove "Time_signature_engraver"
>         fontSize = #-3
>         \override StaffSymbol.staff-space = #(magstep -3)
>         \override StaffSymbol.thickness = #(magstep -3)
>         firstClef = ##f
>       }
>       \fixed c' {f2 e4}
>       \layout { indent = 0\cm ragged-last = ##t}
>     }
>   }
>
>   e2 f4
>
>   c c c
> }
>
> Is there any way to put all the code related to the footnote in a
> variable?
> For example if possible I would like to write something like this:
>
> \version "2.19.81"
> \fixed c' {
>   \time 3/4
>   c c c
>
>   \myfootnote e2 f4
>
>   c c c
> }
>
> and of course
>
> myfootnote =   {
> \once \override Score.FootnoteItem.annotation-line = ##f
>   \footnote \markup\huge { * } #'(0 . 5) \markup {\lower #0.8 { \super
> { *
> } }
>      "The second time play the measure as " \raise #0.5
>     \score {
>       \new Staff \with {
>         \remove "Time_signature_engraver"
>         fontSize = #-3
>         \override StaffSymbol.staff-space = #(magstep -3)
>         \override StaffSymbol.thickness = #(magstep -3)
>         firstClef = ##f
>       }
>       \fixed c' {f2 e4}
>       \layout { indent = 0\cm ragged-last = ##t}
>     }
>   }
> }

Does this work for you?

%%%%
\version "2.19.81"

myfootnote = #(define-music-function (m) (ly:music?) #{
   \once \override Score.FootnoteItem.annotation-line = ##f
   \footnote \markup \huge { * } #'(0 . 5)
   \markup { \lower #0.8 { \super { * } }
     "The second time play the measure as " \raise #0.5
     \score {
       \new Staff \with {
         \remove "Time_signature_engraver"
         fontSize = #-3
         \override StaffSymbol.staff-space = #(magstep -3)
         \override StaffSymbol.thickness = #(magstep -3)
         firstClef = ##f
       }
       \fixed c' {f2 e4}
       \layout { indent = 0\cm ragged-last = ##t}
     }
   } $m
#} )

\fixed c' {
   \time 3/4
   c c c
   \myfootnote e2 f4
   c c c
}
%%%%

-- Aaron Hill

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: put footnote in a variable

Gianmaria Lari


On Thu, 1 Nov 2018 at 09:33, Aaron Hill <[hidden email]> wrote:
On 2018-11-01 1:04 am, Gianmaria Lari wrote:
> I have the following code:
>
> \version "2.19.81"
> \fixed c' {
>   \time 3/4
>   c c c
>
>   \once \override Score.FootnoteItem.annotation-line = ##f
>   \footnote \markup\huge { * } #'(0 . 5) \markup {\lower #0.8 { \super
> { *
> } }
>      "The second time play the measure as " \raise #0.5
>     \score {
>       \new Staff \with {
>         \remove "Time_signature_engraver"
>         fontSize = #-3
>         \override StaffSymbol.staff-space = #(magstep -3)
>         \override StaffSymbol.thickness = #(magstep -3)
>         firstClef = ##f
>       }
>       \fixed c' {f2 e4}
>       \layout { indent = 0\cm ragged-last = ##t}
>     }
>   }
>
>   e2 f4
>
>   c c c
> }
>
> Is there any way to put all the code related to the footnote in a
> variable?
> For example if possible I would like to write something like this:
>
> \version "2.19.81"
> \fixed c' {
>   \time 3/4
>   c c c
>
>   \myfootnote e2 f4
>
>   c c c
> }
>
> and of course
>
> myfootnote =   {
> \once \override Score.FootnoteItem.annotation-line = ##f
>   \footnote \markup\huge { * } #'(0 . 5) \markup {\lower #0.8 { \super
> { *
> } }
>      "The second time play the measure as " \raise #0.5
>     \score {
>       \new Staff \with {
>         \remove "Time_signature_engraver"
>         fontSize = #-3
>         \override StaffSymbol.staff-space = #(magstep -3)
>         \override StaffSymbol.thickness = #(magstep -3)
>         firstClef = ##f
>       }
>       \fixed c' {f2 e4}
>       \layout { indent = 0\cm ragged-last = ##t}
>     }
>   }
> }

Does this work for you?

%%%%
\version "2.19.81"

myfootnote = #(define-music-function (m) (ly:music?) #{
   \once \override Score.FootnoteItem.annotation-line = ##f
   \footnote \markup \huge { * } #'(0 . 5)
   \markup { \lower #0.8 { \super { * } }
     "The second time play the measure as " \raise #0.5
     \score {
       \new Staff \with {
         \remove "Time_signature_engraver"
         fontSize = #-3
         \override StaffSymbol.staff-space = #(magstep -3)
         \override StaffSymbol.thickness = #(magstep -3)
         firstClef = ##f
       }
       \fixed c' {f2 e4}
       \layout { indent = 0\cm ragged-last = ##t}
     }
   } $m
#} )

\fixed c' {
   \time 3/4
   c c c
   \myfootnote e2 f4
   c c c
}
%%%%

-- Aaron Hill

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


Yes Aaron, to me it looks a good solution. Thanks a lot!
g.

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: put footnote in a variable

Gianmaria Lari
Ahem.... I found another issue Aaron.

Suppose you have a variable containing the music and the reference to your footnote code. Something like this: 

var = {a b c d \myfootnote e f g a}

If you 'use' the variable multiple time in your score you probably don't want to display the footnote multiple times. So if you write

{ \var \var \var }

you probably want just one footnote.

So I tried to write

var = {a b c d \tag #'footnotetag {} e f g a}

and then...

{\pushToTag #'footnotetag \myfootnote \var \var \var}

but this does not compile.
Does exists a simple workaround to make it working? (I made different experiments without success). If there is no simple solution, no problem, don't waste your time. Consider this just a curiosity. Thanks a lot, gianmaria

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: put footnote in a variable

Aaron Hill
On 2018-11-01 2:59 am, Gianmaria Lari wrote:

> Ahem.... I found another issue Aaron.
>
> Suppose you have a variable containing the music and the reference to
> your
> footnote code. Something like this:
>
> var = {a b c d \myfootnote e f g a}
>
>
> If you 'use' the variable multiple time in your score you probably
> don't
> want to display the footnote multiple times. So if you write
>
> { \var \var \var }
>
>
> you probably want just one footnote.
>
> So I tried to write
>
> var = {a b c d \tag #'footnotetag {} e f g a}
>
>
> and then...
>
> {\pushToTag #'footnotetag \myfootnote \var \var \var}
>
>
> but this does not compile.
> Does exists a simple workaround to make it working? (I made different
> experiments without success). If there is no simple solution, no
> problem,
> don't waste your time. Consider this just a curiosity. Thanks a lot,
> gianmaria

To clarify, when you use { \var \var \var }, is it your intention that
you want the footnote to be shared amongst the multiple instantiations?

If that is the case, then there is an edge case that would need to be
addressed too.  Imagine if \var occurs on multiple pages.  Each one
would ideally need a footnote on its own page, but if two (or more)
instances of \var occur on the same page, then you would ideally want
them to be able to share.

Unfortunately, I haven't dug into the footnote code enough to know
whether such a scheme is possible.  I think each \footnote is uniquely
identified behind the scenes.  Obviously, you can always cheat and
simulate the footnote markup wherever you see fit, but it would be handy
to have a more automated system.

-- Aaron Hill

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: put footnote in a variable

Gianmaria Lari


On Thu, 1 Nov 2018 at 11:12, Aaron Hill <[hidden email]> wrote:
On 2018-11-01 2:59 am, Gianmaria Lari wrote:
> Ahem.... I found another issue Aaron.
>
> Suppose you have a variable containing the music and the reference to
> your
> footnote code. Something like this:
>
> var = {a b c d \myfootnote e f g a}
>
>
> If you 'use' the variable multiple time in your score you probably
> don't
> want to display the footnote multiple times. So if you write
>
> { \var \var \var }
>
>
> you probably want just one footnote.
>
> So I tried to write
>
> var = {a b c d \tag #'footnotetag {} e f g a}
>
>
> and then...
>
> {\pushToTag #'footnotetag \myfootnote \var \var \var}
>
>
> but this does not compile.
> Does exists a simple workaround to make it working? (I made different
> experiments without success). If there is no simple solution, no
> problem,
> don't waste your time. Consider this just a curiosity. Thanks a lot,
> gianmaria

To clarify, when you use { \var \var \var }, is it your intention that
you want the footnote to be shared amongst the multiple instantiations?

If that is the case, then there is an edge case that would need to be
addressed too.  Imagine if \var occurs on multiple pages.  Each one
would ideally need a footnote on its own page, but if two (or more)
instances of \var occur on the same page, then you would ideally want
them to be able to share.

Sure, this is the first thing that came to mind. And yes, probably it would be nice to be able to automatically manage the two situations. But I didn't want to go so far; that's why I wanted to see if it existed a reasonable solution with the tools I know (tag).

Thank you Aaron!
g.

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