Pandoc Numbering and Image Links

I would like to add captions such as โ€œFigure 1: Blah Blahโ€ to my images in Pandoc, and be able to reference them as shown. Figure 1. I use gpp (preprocessor) to add captions to my images and do all kinds of fancy things like resize, format, etc. However, I cannot implement a counter for images like Figure1, Figure2, etc.

I defined the following function in my gpp script:

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

and I call it in my script: \count

However, \counter does not get the score in my gpp script, and I see the following error: unfinished macro

How do I execute this counter? I use -T (tex) mode in gpp

+4
source share
2 answers

I found a somewhat partial solution to my problem. I found that using the CSS counter-increment property can help to automatically record such images: http://www.w3schools.com/cssref/pr_gen_counter-reset.asp

However, the problem remains that I use gpp to copy the same code every time my gpp tag is called. Therefore, the counter will never increase. For example, for my gpp code:

 \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> } 

My style.css looks like this:

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

So every time I turn on the image with the \image tag, it always gets the counter Figure1

+2
source

Instead, you can try pandoc-fignos : it automatically creates figure numbers and includes links to shapes.

In short, you can add a shortcut to an image like this:

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

... and then refer to it as follows:

 @fig:description 

See the pandoc-fignos page on github for installation and use instructions. There is also a pandoc-eqnos filter to do the same type of thing using equations.

0
source

All Articles