Reference to figure and table numbers with Pandoc
Asked Answered
C

3

9

I'm trying to make a document with Markdown/restructuredText which will be converted with pandoc to PDF using xelatex.

I would like to return reference to figure and tables numbers in the text body.

In both Markdown and reSt markup languages, the cross reference return a link to the figure but not the figure number.

for example [the figure](#myfig) with markdown or myfig_ with reST links to the figure but don't automaticly update the figure number.

Is it possible with Markdown or ReST markup languages to refer to figure and tables number?

Christophany answered 12/8, 2018 at 13:59 Comment(1)
I can't figure out what you want, so I'll just toss out what I think you mean with a link to possibly relevant docs: sphinx-doc.org/en/master/usage/restructuredtext/…Sidewalk
V
11

I suggest using the pandoc-crossref filter with pandoc. The demo gives you a good idea of the syntax. You invoke it by calling pandoc with --filter pandoc-crossref.

Vouvray answered 13/8, 2018 at 5:12 Comment(0)
A
3

The pandoc-fignos and pandoc-tablenos filters from the pandoc-xnos filters suite are good choices for cross-referencing in markdown with pandoc.

To mark a figure for numbering, add an identifier to its attributes:

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

To reference the figure, use @fig:id.

Similarly, to mark a table for numbering, add an identifier to its attributes:

A B
- -
0 1

Table: Caption. {#tbl:id}

To reference the table, use @tbl:id.

When processing the markdown document, simply add --filter pandoc-fignos --filter pandoc-tablenos to the pandoc command.

Aphelion answered 18/9, 2019 at 3:11 Comment(0)
I
0

You may simply add \label{fig: cat} and \ref{fig:cat}. LaTeX will take care of the rest.

Inbound answered 13/9, 2024 at 14:43 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.