Are there any macros or other way in Atlassian Confluence documentation tool (wiki) to create automatically numbered figure / table captions?
-
Check out this plugin: marketplace.atlassian.com/plugins/com.tensixtwo.conf.numcapt– boileauMay 26, 2014 at 21:25
-
I know that it's been about 4 years since you've asked and answered this question but I'm curious if you ever come up with something else than your macro since then.– Montag451Jun 30, 2016 at 8:23
-
No, I did not deal with this topic since then– MrTJJun 30, 2016 at 8:52
Add a comment
|
1 Answer
Well, I came up with this macro:
## Macro title: Subtitle
## Macro has a body: Y
##
## Developed by: Janos Tolgyesi
## Date created: 27/04/2012
##
## @param AnchorName:title=Anchor Name|type=string|required=true
## @param SubtitleText:title=Subtitle|type=string|required=true
## @param Prefix:title=Prefix (Figure, Table, etc.)|type=string|required=true
## Hack to detect Table Of Contents macro that messes up numbering
## by calling user macros two times
#set($Q = '"')
#set ($isToc = $content.getBodyAsString().contains("<ac:macro ac:name=${Q}toc${Q} />"))
#if (!$req.getAttribute("${paramAnchorName}SubtitleMacro") && ($isToc == "true"))
## Here we are called first time from TOC macro
#set ($dummy = $req.setAttribute("${paramAnchorName}SubtitleMacro", 1))
#else
## The real code
#set ($counterName = "${paramPrefix}Counter")
#if (!$req.getAttribute($counterName))
$!req.setAttribute($counterName, 0)
#end
#if (!$req.getAttribute("xrefMap"))
$!req.setAttribute("xrefMap", {})
#end
#set ($counter = $req.getAttribute($counterName) + 1)
#set ($fullSubtitle = "$paramPrefix $counter. $paramSubtitleText")
$!req.setAttribute($counterName, $counter)
#set ($dummy = $!req.getAttribute("xrefMap").put($paramAnchorName, $fullSubtitle))
<ac:macro ac:name="anchor">
<ac:default-parameter>$paramAnchorName</ac:default-parameter>
</ac:macro>
<span style="display:inline-block;">
$body
<div style="text-align:center; padding-bottom:1em">$fullSubtitle</div>
</span>
#end
-
Greetings from the future, whilst possibly a good answer (I have the exact same problem as the OP), it would be good to know exactly what your macro does. Being new to Confluence macros, I'm a little hestiant to inject yours into our corporate instance. Thanks buddy– DeletedJan 16, 2017 at 6:05