Skip to content

How to add caption to figure exported to PDF? #569

Open
@rhstanton

Description

@rhstanton

Here's a sample code block and some result-block headers to create a figure:

#+name: plot_test
#+BEGIN_SRC jupyter-python :file junk.png :exports both :display image/png
import numpy as np
import matplotlib.pyplot as plt
plt.plot([1,2,3], [4,5,2])
#+END_SRC

#+name: sample_plot
#+caption: A sample plot
#+results: plot_test

When I execute the code block, the figure displays very nicely in my org buffer, but when I export it to PDF (via LaTeX), although the graph shows up, it has no caption or figure number.

The problem seems to be that the resultant figure is enclosed in a :RESULTS: drawer. Here's the full results block after executing the code block:

#+name: sample_plot
#+caption: A sample plot
#+ATTR_LATEX: :float t :placement [htbp]
#+results: plot_test
:RESULTS:
[[file:junk.png]]
:END:

If I manually delete :RESULTS: and :END:, the figure exports with the desired caption.

What's the simplest way to get this to work as desired without manually deleting the :RESULTS: drawer delimiters?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions