18

I have a figure declared like this:

#+CAPTION: Google NGrams Viewer Search
#+NAME: fig:ngrams
[[file:ngrams.png]]

And I'd like to reference it, so that I can write, e.g. Please refer to Figure [[some magic thing here]] and have it output Please refer to Figure 1. I'm using pandoc to convert from .org to .pdf.

I've been trying writing [[fig:ngrams]], as in Please refer to Figure [[fig:ngrams]], but neither Pandoc nor pandoc-citeproc seem to understand that kind of link, and they transform it to Please refer to Figure fig:ngrams.

2
  • 2
    In Org, one refers to a figure like you suggested, e.g. Figure [[fig:ngrams]]. This works with ox.el, e.g. ox-latex.el. If you must use pandoc instead of ox-latex.el for your PDFs needs, perhaps the right approach would be to file a bug to the Pandoc org-parser maintainers to let them know that it does not support the links syntax fully.
    – rasmus
    May 8, 2017 at 14:38
  • Your question has a lot of traffic, and the up to date answer is the one with the least votes (from @kostas-tsiligkiris). Could you consider accepting his answer?
    – pietrodito
    May 19, 2022 at 13:01

3 Answers 3

5

There is another way to reference figures, by using #+NAME: before the figure. For example:

#+CAPTION: Example of the process
#+NAME: fig:theprocess
[[./Images/process.png]]

And later in the place where you need the reference, you add an internal link:

And as can be seen in figure [[fig:theprocess]], the process...

This works nicely with latex export.

10

Figured it out myself. Turns out with the latest pandoc and pandoc-crossref you can do this:

#+CAPTION: Google NGrams Viewer Searches
#+LABEL: fig:ngrams
[[file:ngrams.png]]

Then:

Please refer to [cite:@fig:ngrams].

1
  • 1
    No longer working in my installation : Emacs version: GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20) : of 2020-08-25 : org version: 9.3.7
    – Reb.Cabin
    Oct 26, 2020 at 0:59
9

You can also use org-ref. Then you can use ref:ngrams to reference a figure. This works well with LaTeX export. It probably works with pandoc too.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.