html - 在 Pandoc 中编号和引用图像

标签 html latex preprocessor pandoc

我想在 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/

相关文章:

html - 如何使内容在div内垂直对齐

javascript - 如何使用javascript在单击图像时获取音频,并在播放两个或多个图像时暂停,其中一个图像必须在其他图像正在播放时暂停

还原转换预处理插入符

latex - 如何使用 Minted Latex 包更改行号的字体大小

r - 如何在 R 中的 Hmisc 中将注释附加到 latex 表?

react-native - react-native bundle 程序可以检测未使用的文件吗?

ios - 如何在头文件中使用预处理器检查?

javascript - Fullpage.js 在滚动条上水平滑动

jquery - 如何使这个消失/重新出现的 AJAX 加载 GIF 停止移动其他元素?

ubuntu - 如何让 LaTeX 在 IPython notebook 中工作?