Sam Flint <swflint <at> 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