#set ($figureCaptionBlock = $latex.block)
#if ($latex.tool.figureTool.displayFigureCaption($figureCaptionBlock))
  #set ($discard = $latex.tool.getStack('isInContainerAcceptingStandalone').push(true))
  ## If the caption is last then add a NL before the caption so that the caption is on a new line
  #if ($latex.tool.figureTool.isFigureCaptionLast($figureCaptionBlock))
  
  #end
  ## Convert the caption for List of figures/tables to be inline content (discard or convert standalone elements)
  ## Note: getInlineDescendants() doesn't ensure that the conversion to LaTeX will result in some valid content inside
  ## the \caption command.
  \caption[$latex.processor.process($latex.tool.getInlineDescendants($figureCaptionBlock))]{##
  $latex.processor.process($figureCaptionBlock.getChildren())##
  }##
  ## If the caption is first then add a NL after the caption so that next element is on a new line
  #if (!$latex.tool.figureTool.isFigureCaptionLast($figureCaptionBlock))
  
  #end
  #set ($discard = $latex.tool.getStack('isInContainerAcceptingStandalone').pop())
#end