## In order to find the XDOM representing the footnote content, we need to look for the matching XDOM content
## generated by the putFootnotes macro.
## Step 1: Get the anchor id from the footnote macro marker
#set ($formatBlock = $latex.block.getChildren().get(0))
#set ($linkBlock = $formatBlock.getChildren().get(0))
#set ($footnoteId = $linkBlock.getReference().getParameter('anchor'))
## Step 2: Find the matching LinkBlock inside the putFootnotes macro marker block
#foreach ($macroMarkerBlock in $latex.block.root.getBlocks('class:MacroMarkerBlock', 'DESCENDANT'))
  #if ($macroMarkerBlock.id == 'putFootnotes')
    #foreach ($listItemBlock in $macroMarkerBlock.getChildren().get(0).getChildren())
      #set ($linkBlock = $listItemBlock.getChildren().get(0))
      #set ($footnoteId2 = $linkBlock.getParameter('id'))
      #if ($footnoteId == $footnoteId2)
        ## The XDOM we want to extract is made of the blocks just after the next sibling block which is a SpaceBlock
        #set ($footnoteBlocks = $latex.tool.getSiblings($linkBlock.getNextSibling()))
        #break
      #end
    #end
  #end
#end
\footnote{$latex.processor.process($footnoteBlocks)}##