16.2 Customizing Footnotes

In the default case footnotes are numbered. If NUMBER_FOOTNOTES is set to 0, a ‘*’ is used instead, or the NO_NUMBER_FOOTNOTE_SYMBOL customization variable value, if set.

Redefinition of @footnote conversion reference and footnote formatting references is needed for further customization.

@footnote @-commands appearing in the Texinfo elements tree are converted like any other elements associated with @-commands (see Command Tree Element Conversion Functions). It is therefore possible to redefine their formatting by registering a user defined function.

To pass information on footnotes between the conversion function processing the @footnote command at the location they appear in the document and the functions formatting their argument elsewhere, two functions are available: register_footnote to be called where they appear in the document, and get_pending_footnotes to be called where they are formatted.

Function: $converter->register_footnote (\%element, $footnote_id, $foot_in_doc_id, $number_in_doc, $footnote_location_filename, $multi_expanded_region)

\%element is the footnote Texinfo tree element. $footnote_id is the identifier for the location where the footnote arguments are expanded. $foot_in_doc_id is the identifier for the location where the footnote appears in the document. $number_in_doc is the number of the footnote in the document. $footnote_location_filename is the filename of the output unit of the footnote in the document. If the footnote appears in a region that is expanded multiple times, the information on the expansion is $multi_expanded_region (see Other Dynamic Information).

register_footnote is normally called in the @footnote @-command conversion function reference. The default conversion function also call command_href to link to the location where the footnote text will be expanded (see Target Tree Element Link).

Function: \@pending_footnotes_information = $converter->get_pending_footnotes ()

Returns in \@pending_footnotes_information the information gathered in register_footnote. Each of the array reference element in \@pending_footnotes_information is an array reference containing the arguments of register_footnote in the same order.

The formatting of footnotes content is done by the format_footnotes_sequence formatting reference (see Registering Specific Formating Functions):

Function Reference: $footnotes_sequence format_footnotes_sequence ($converter)

Formats and returns the footnotes that need to be formatted. This function normally calls get_pending_footnotes. The default function also calls footnote_location_href to link to the location in the document where the footnote appeared, and the format_single_footnote formatting function to format a single footnote.

The formatting of one footnote is done by the format_single_footnote formatting reference:

Function Reference: $footnote format_single_footnote ($converter, \%element, $footnote_id, $number_in_doc, $footnote_location_href, $footnote_mark)

Formats and returns a single footnote. \%element is the footnote Texinfo tree element. $footnote_id is the identifier for the location where the footnote arguments are expanded. $number_in_doc is the number of the footnote in the document. $footnote_location_href is the href that links to the footnote location in the main document. $footnote_mark is the footnote number or mark.

If footnotes are in a separate output unit (see Output Units), the default footnote special output unit body formatting function calls format_footnotes_sequence (see Special Unit Body Formatting Functions).

If the footnotes are not in a separate output unit, or there is no separate unit because there is only one output unit or no output unit, the format_footnotes_segment formatting reference is called when pending footnotes need to be formatted. This function reference can be replaced by a user defined function.

Function Reference: $footnotes_segment format_footnotes_segment ($converter)

Returns the footnotes formatted. In the default case, the function reference calls format_footnotes_sequence and also sets up a header with format_heading_text (see Basic Formatting Customization), using the customization variables FOOTNOTE_END_HEADER_LEVEL and the special footnotes element heading information (see Special Units Information Customization).

To get the id of a footnote in the main document, use footnote_location_target:

Function: $target = $converter->footnote_location_target (\%footnote_element)

Return the id for the location of the footnote \%footnote_element in the main document (where the footnote number or symbol appears).

To get an href to link to a footnote location in the main document, use footnote_location_href:

Function: $href = $converter->footnote_location_href (\%footnote_element, $source_filename, $specified_target, $target_filename)

Return string for linking to \%footnote_element location in the main document with <a href>. $source_filename is the file the link comes from. If not set, the current file name is used. $specified_target is an optional identifier that overrides the target identifier if set. $target_filename is an optional file name that overrides the file name href part if set.

See Target Tree Element Link to get link information for the location where footnote text is output.