How to resolve anchor/numbering not working as expected after upgrading Confluence

This article explains how to resolve the issue of LaTeX Math anchor/numbering not working in Confluence server after an upgrade.

When you encounter LaTeX Math issues in Confluence Server after updating to a new version, such as anchors not working or numbers not displaying, you may have an issue with the velocity templates. The velocity templates (Math Block velocity template and Math Block Reference velocity template) for the LaTeX Math app must be updated to resolve the problem.

Instructions

  1. Log in to Jira, click the Cogwheel icon in the top right corner, and select Manage Apps from the dropdown menu.

  2. Search or scroll down until you see LaTeX Math and select it. Click LaTeX Math Configuration.

  3. Scroll down until you see Math Block velocity template and Math Block Reference velocity template, as shown below.

    LaTeX Math Templates
  4. Click anywhere within the block to edit a block. This opens the corresponding velocity template, which you can compare with the templates available below. If you notice any differences, replace the existing template with the new one. Ensure to take the back up of the existing codes.

Math Block velocity template

#* Copyright (c) 2022 Appfire Technologies, LLC. All rights reserved. This software is licensed under the provisions of the "Appfire EULA" (https://appfire.com/eula/) as well as under the provisions of the "Standard EULA" from the "Atlassian Marketplace Terms of Use" as a "Marketplace Product" (http://www.atlassian.com/licensing/marketplace/termsofuse). See the LICENSE file for more details. *# #htmlSafe() ## Put parenthesis around equation number: #if ($!captionHtml && ($!captionHtml.length()>0)) #set ($captionHtml = "($captionHtml)") #end ## ## Write block equation: <table border=0 cellspacing=0 cellpadding=0 width=100% align="center" class="latexmath-mathblock" style="width: 100% !important;"> <tbody><tr> <td nowrap class="latexmath-numbering">$!captionHtml</td> <td nowrap class="latexmath-$halign">$!latexHtml</td> </tr></tbody> </table>

Math Block Reference velocity template

#* Copyright (c) 2022 Appfire Technologies, LLC. All rights reserved. This software is licensed under the provisions of the "Appfire EULA" (https://appfire.com/eula/) as well as under the provisions of the "Standard EULA" from the "Atlassian Marketplace Terms of Use" as a "Marketplace Product" (http://www.atlassian.com/licensing/marketplace/termsofuse). See the LICENSE file for more details. *# #htmlSafe() #macro(doNothing)#end ## Add colon to page name: #if ($pageNameHtml && ($pageNameHtml.length()>0)) #set ($pageNameHtml = $pageNameHtml+'<span class="latexmath-refpagejoiner">:</span>') #end ## <a href="$!{anchorURLHtml}" class="latexmath-mathblock-ref"$!{dataParamsHtml}>($!{pageNameHtml}$!{captionHtml})</a>#doNothing()

5. Make sure to save your changes after replacing the templates.

6. Refresh the Confluence page containing the LaTeX Math macros to see if anchors and numbers display correctly.

  • Perform the above steps in a staging environment before implementing them in production.

  • Ensure to have appropriate permissions to change this setting.

Â