+#############################################################################
+### FOOTNOTE FORMATTING
+#############################################################################
+
+# Format footnotes in a nicer way: Instead of printing the number in a separate
+# (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
+# before the fn text.
+sub lilypond_foot_line_and_ref($$$$$$$)
+{
+ my $number_in_doc = shift;
+ my $number_in_page = shift;
+ my $footnote_id = shift;
+ my $place_id = shift;
+ my $document_file = shift;
+ my $footnote_file = shift;
+ my $lines = shift;
+ my $state = shift;
+
+ if ($document_file eq $footnote_file)
+ {
+ $document_file = $footnote_file = '';
+ }
+ # FN number printed before the fn text:
+ my $tmptxt = &$anchor($footnote_id, $document_file . "#$place_id",
+ "<sup>$number_in_doc</sup>");
+ # unfortunately, the @$lines contain the already formatted footnote in the
+ # from <p>...</p>. This means that we have to modify this string and
+ # insert the FN number manually. The default (nr) on a separate line before
+ # the FN text is just plain ugly:
+ $lines->[0] =~ s/<p>/<p>$tmptxt /;
+ # this is a bit obscure, this allows to add an anchor only if formatted
+ # as part of the document.
+ $place_id = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
+ # return FN lines and text to be inserted in the running text (link to FN)
+ return ($lines, &$anchor($place_id, $footnote_file . "#$footnote_id",
+ "<sup>$number_in_doc</sup>"));
+}
+
+
+