11

Please consider the following, self-contained .org file MVE, which I hope is self-explanatory:

#+OPTIONS: toc:nil

Figure [[captions-work-for-src-blocks]] shows that captions are correctly exported
for SRC blocks. The second figure, in an EXAMPLE block, does not receive an
exported caption. Furthermore, cross references to figure
[[captions-dont-work-for-example-blocks]] incorrectly resolve to figure
[[captions-work-for-src-blocks]].

-----
#+NAME: captions-work-for-src-blocks
#+CAPTION: Captions work for SRC blocks
#+BEGIN_SRC
  foo(bar) == baz(qux);
#+END_SRC
-----

-----
#+NAME: captions-dont-work-for-example-blocks
#+CAPTION: Captions don't work for EXAMPLE blocks
#+BEGIN_EXAMPLE
  foo(bar) == baz(qux);
#+END_EXAMPLE
-----

On org-latex-export-to-pdf, it produces the following output:

enter image description here

I'm using the following versions of the software:

: Emacs version: GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911))
:  of 2016-09-17
: org version: 9.0.7

I looked at the official org-mode documentation, but I could not find information relating to this issue.

1

1 Answer 1

4

By trial and error (and by digging into the suggestion by @Hatshepsut), I discovered that the following works:

#+begin_example
/usr/local/share/guile/site/2.2$ tree math/
math/
`-- bessel.scm
#+end_example
#+latex: \caption{Directory structure for Guile extension module}

whereas the following does NOT work:

#+caption: Directory structure for Guile extension module
#+begin_example
/usr/local/share/guile/site/2.2$ tree math/
math/
`-- bessel.scm
#+end_example

For src blocks and for results output, I am currently using the following because #+caption does not work on #+RESULTS blocks, just as it does not work on #+begin_example (no idea whether this pattern is optimal):

#+caption: How to find out where Guile expects to find extension modules
#+begin_src scheme :exports both
(%site-dir)
#+end_src

#+RESULTS:
: /usr/local/share/guile/site/2.2
#+latex: \caption{This is the answer that Guile gives, live in org-babel}

Iirc, there is some mention of captioning #+RESULTS blocks somewhere in the org-mode manual. I have not been able to find it a second time. The following link is a bit vague:

https://orgmode.org/manual/Captions.html

In no cases have I yet tried org-mode name, nor LaTeX label and ref.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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