2013-04-23 55 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過濾器可以用方程式來做同樣的事情。