Shr*_*oor 5 html latex preprocessor pandoc
我想在 Pandoc 中的图像中添加诸如“图 1:废话”之类的标题,并能够像查看@Figure1 一样引用它们。我正在使用 gpp(一个预处理器)为我的图像添加标题并执行各种奇特的操作,例如更改大小、格式等。但是,我无法为图 1、图 2 等图像实现计数器。
我在我的 gpp 脚本中定义了以下函数:
\define{\counter}{0}
\defeval{count}{\eval{\counter+ 1}
Run Code Online (Sandbox Code Playgroud)
我在我的脚本中这样称呼它: \count
但是,\counter在我的 gpp 脚本中没有得到评估,我看到以下内容error: unfinished macro
我应该如何实现这个计数器?我在 gpp 中使用 -T (tex) 模式
我已经找到了解决我的问题的部分方法。我发现使用 CSS 的 counter-increment 属性可以帮助对图像进行自动编号,如下所示: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>
}
Run Code Online (Sandbox Code Playgroud)
我的 style.css 看起来像这样:
div .figures{
counter-reset:figure;
}
a.figure-caption:before{
counter-increment:figure;
content: "Figure" counter(figure) ":";
}
Run Code Online (Sandbox Code Playgroud)
因此,每次我包含带有标签的图片时\image,它总是会得到计数器Figure1