* LaTeX export with Code
@ 2013-10-06 21:50 Sam Flint
2013-10-07 16:20 ` Charles Berry
0 siblings, 1 reply; 2+ messages in thread
From: Sam Flint @ 2013-10-06 21:50 UTC (permalink / raw)
To: Org-Mode
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?
Thanks,
Sam
--
Sam Flint
swflint@flintfam.org
freenode: swflint
(402) 517-8468
http://flintfam.org/~swflint
BAFBF3FF
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: LaTeX export with Code
2013-10-06 21:50 LaTeX export with Code Sam Flint
@ 2013-10-07 16:20 ` Charles Berry
0 siblings, 0 replies; 2+ messages in thread
From: Charles Berry @ 2013-10-07 16:20 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-07 16:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-06 21:50 LaTeX export with Code Sam Flint
2013-10-07 16:20 ` Charles Berry
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).