From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Lindner Subject: Re: Add caption to babel-generated images Date: Tue, 30 Aug 2016 12:40:51 +0200 Message-ID: References: <87a8fuin1u.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beh0l-0006Li-5Y for emacs-orgmode@gnu.org; Tue, 30 Aug 2016 07:15:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beh0f-00020B-OL for emacs-orgmode@gnu.org; Tue, 30 Aug 2016 07:15:22 -0400 Received: from [195.159.176.226] (port=52028 helo=blaine.gmane.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beh0f-0001zP-H5 for emacs-orgmode@gnu.org; Tue, 30 Aug 2016 07:15:17 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1begTS-0007Uk-FA for emacs-orgmode@gnu.org; Tue, 30 Aug 2016 12:40:58 +0200 In-Reply-To: <87a8fuin1u.fsf@saiph.selenimh> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Am 30.08.2016 um 12:11 schrieb Nicolas Goaziou: > Hello, > > Florian Lindner 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