[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Add caption to babel-generated images
From: |
Florian Lindner |
Subject: |
Re: [O] Add caption to babel-generated images |
Date: |
Tue, 30 Aug 2016 12:40:51 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
Am 30.08.2016 um 12:11 schrieb Nicolas Goaziou:
> Hello,
>
> Florian Lindner <address@hidden> writes:
>
>> I have this code block:
>>
[...]
>> When exporting to latex it nicely compiles into
>> \includegraphics[width=.9\linewidth]{rbf-gaussian-4.pdf}.
>>
>> Now I want to have this \includegraphics in a figure environement including
>> a label (to reference it) and a caption.
>>
>> How can do this best?
>
>> I have found:
>> http://emacs.stackexchange.com/questions/12150/add-caption-to-an-image-generated-by-a-code-block
>>
>> but it doesn't work for me.
>
> What did you write? What doesn't work?
This org mode document
#+NAME: fig:org_fig
#+BEGIN_SRC python :exports results :results file
import matplotlib.pyplot as plt, numpy as np
x = np.linspace(-2, 2, 1000)
plt.plot(x, np.exp(-np.power(4*x, 2)), label="shape-parameter=4")
for i in range(-4, 5): plt.axvline(1/6 * i, ymax = 0.1, ls = "-.", color="r")
plt.grid()
plt.savefig('rbf-gaussian-4.pdf')
return "rbf-gaussian-4.pdf"
#+END_SRC
#+CAPTION: Org Fig
#+LABEL: fig:org_fig
Exports to:
\begin{document}
\maketitle
\tableofcontents
\includegraphics[width=.9\linewidth]{rbf-gaussian-4.pdf} \\
% Emacs 24.5.1 (Org mode 8.2.10)
\end{document}
Additionally, when evaluating it's changed to:
[...]
#+END_SRC
#+RESULTS: fig:org_fig
[[file:rbf-gaussian-4.pdf]]
#+CAPTION: Org Fig
#+LABEL: fig:org_fig
Splitting off the caption and label.
Best,
Florian