2013-04-23 38 views
4

我想在Pandoc的图像中添加像“图1:Blah Blah”这样的标题,并能像see @ Figure1一样引用它们。我正在使用gpp(预处理器)为我的图像添加字幕,并做各种花式的事情,如更改大小,格式等。但是,我无法实现像图1,图2等图像计数器。编号和参考Pandoc中的图像

我在GPP脚本中定义的以下功能:

\define{\counter}{0} 

\defeval{count}{\eval{\counter+ 1} 

,我在我的脚本中调用它像这样:\count

然而,\counter犯规在我的GPP脚本得到评估,我看到下面的error: unfinished macro

我应该如何实施这个柜台?我在gpp中使用-T(tex)模式

回答

2

我发现我的问题有些部分的解决方案。我发现使用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> 
} 

我的style.css看起来是这样的:

div .figures{ 
counter-reset:figure; 
} 

a.figure-caption:before{ 
counter-increment:figure; 
content: "Figure" counter(figure) ":"; 
} 

所以,每次我包括与标签\image的图片,它总是得到计数器Figure1

0

您可以尝试使用pandoc-fignos过滤器:它会自动创建图形编号并启用图形参考。

简单地说,你可以像这样的标签添加到图像:

![Caption.](image.png) {#fig:description} 

...然后像这样引用它:

@fig:description 

在Github上查看安装的pandoc-fignos页和使用说明。还有pandoc-eqnos过滤器可以用方程式来做同样的事情。