我想在 Pandoc 中为我的图像添加诸如“图 1:Blah Blah”之类的标题,并能够像查看@Figure1 那样引用它们。我正在使用 gpp(预处理器)为我的图像添加标题并执行各种奇特的操作,例如更改大小、格式等。但是,我无法为 Figure1、Figure2 等图像实现计数器。
我在我的 gpp 脚本中定义了以下函数:
\define{\counter}{0}
\defeval{count}{\eval{\counter+ 1}
我在我的脚本中这样调用它:\count
但是,\counter
没有在我的 gpp 脚本中得到评估,我看到以下 error: unfinished macro
我应该如何实现这个计数器?我在 gpp 中使用 -T (tex) 模式
最佳答案
我找到了部分解决我的问题的方法。我发现使用 CSS 的反增量属性可以帮助自动编号图像,如下所示:http://www.w3schools.com/cssref/pr_gen_counter-reset.asp
但是,问题仍然存在,每次调用我的 gpp 标记时,我都在使用 gpp 复制同一段代码。因此,计数器永远不会增加。例如:我的 gpp 代码是:
\define{\image{src}{width}{caption}{tag}}{
<div style=" margin:50px auto; text-align:center;" class="figures">
<a href="\src" id="\tag" style="margin:0px 20px; display:inline-block;
text-decoration:none; color:black; "><img src="\src" width="\width px"
alt="\caption" style="padding-bottom:0.5em;"> <div> \caption </div></a></div>}
\define{\imageref{label}}{
<span style="white-space:nowrap;"><a href="#\label" style="display:inline-block">\label</a></span>
}
我的 style.css 看起来像这样:
div .figures{
counter-reset:figure;
}
a.figure-caption:before{
counter-increment:figure;
content: "Figure" counter(figure) ":";
}
因此,每次我包含一张带有标签 \image
的图片时,它总是得到计数器 Figure1
关于html - 在 Pandoc 中编号和引用图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16181090/