From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Berry Subject: Re: LaTeX export with Code Date: Mon, 7 Oct 2013 16:20:06 +0000 (UTC) Message-ID: References: <878uy6kr17.fsf@wall.flintfam.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDXv-0006Dj-Qk for emacs-orgmode@gnu.org; Mon, 07 Oct 2013 12:20:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTDXq-0007s2-4f for emacs-orgmode@gnu.org; Mon, 07 Oct 2013 12:20:35 -0400 Received: from plane.gmane.org ([80.91.229.3]:60361) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDXp-0007rv-NP for emacs-orgmode@gnu.org; Mon, 07 Oct 2013 12:20:29 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VTDXn-0001gt-KE for emacs-orgmode@gnu.org; Mon, 07 Oct 2013 18:20:27 +0200 Received: from 137.110.36.132 ([137.110.36.132]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Oct 2013 18:20:27 +0200 Received: from ccberry by 137.110.36.132 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Oct 2013 18:20:27 +0200 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: emacs-orgmode@gnu.org Sam Flint flintfam.org> writes: > > I regularly use org-mode for LP, and would like to be able to export the > name of a code chunk as a caption in LaTeX. I have looked at the > manual, and don't see any way of doing this, are there? Yes. Quite a few. If you want is the src block name to be used as the caption, you can put this line: #+CAPTION: use-name-as-caption before the named src block and execute this code before you export: #+BEGIN_SRC emacs-lisp (defun org-export-use-name-as-caption (text &optional back-end info) "Use the block name as the caption." (replace-regexp-in-string "label{\\([^}]*\\)}\\(use-name-as-caption\\)" "label{\\1}\\1" text)) (add-to-list 'org-export-filter-src-block-functions 'org-export-use-name-as-caption) #+END_SRC Then when you export this #+CAPTION: use-name-as-caption #+NAME: y-plus-z-becomes-x #+BEGIN_SRC R x <- y+z #+END_SRC the result is \begin{figure}[H] \begin{verbatim} x <- y+z \end{verbatim}\caption{\label{y-plus-z-becomes-x}y-plus-z-becomes-x} \end{figure} HTH, Chuck