From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Exporting source code blocks as LaTeX figures Date: Sat, 18 May 2013 09:39:49 +0200 Message-ID: <87r4h4ohx6.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:48927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Udbk7-0007J2-MT for Emacs-orgmode@gnu.org; Sat, 18 May 2013 03:39:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Udbk6-0006N2-NY for Emacs-orgmode@gnu.org; Sat, 18 May 2013 03:39:51 -0400 Received: from mail-we0-x22a.google.com ([2a00:1450:400c:c03::22a]:44751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Udbk6-0006Mx-H9 for Emacs-orgmode@gnu.org; Sat, 18 May 2013 03:39:50 -0400 Received: by mail-we0-f170.google.com with SMTP id u54so4224263wes.1 for ; Sat, 18 May 2013 00:39:49 -0700 (PDT) In-Reply-To: (James Harkins's message of "Fri, 17 May 2013 15:14:21 +0800") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: jamshark70@dewdrop-world.net Cc: "Emacs-orgmode@gnu.org" Hello, James Harkins writes: > Couple of questions about exporting LaTeX figures that are neither > tables nor images -- specifically, source code blocks using the > listings package. > > 1. Is there any way to use #+CAPTION with a #+BEGIN_figure block, so > that the caption will be rendered underneath the text in the figure? > > It seems (from reading the org manual and some experimentation on my > own) that the answer is no. That's rather inconvenient; the journal > specifies that captions should appear below their respective figures, > but as it is: > > #+CAPTION: Some code > #+NAME: code1 > #+BEGIN_figure > #+BEGIN_SRC {} > // blah blah Why don't you use: #+begin_figure #+caption: Some code #+name: code1 #+begin_src {} // blah blah instead? I.e., why don't you apply caption to src block? You can tweak the position of the caption with "captionpos" option in listings environment. Caption are not supported in special blocks because these could contain more than one object, and it wouldn't be clear which of them would have the caption. > 2. Is the customize variable "Org Latex Default Figure Position" only > used for tables and images? It would be nice if it applied to > BEGIN_figure as well (unless :options override that). "#+ATTR_LaTeX: > :options [htb]" is a mite inconvenient to replicate for every code > example. Certainly possible, but it would save a little effort if the > default were used here too. BEGIN_figure is a "special block", i.e. a generic environment. "[htb]" does not always make sense in every environment. Also, figure environment is created automatically in some cases (e.g., when `org-latex-listings' is nil and source block is captioned), so you generally don't need to write it explicitly. Anyway, you can easily add "[htb]" options to all figure environments in the output with a filter. Regards, -- Nicolas Goaziou