From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: example or source blocks with captions Date: Wed, 27 Apr 2011 11:21:02 -1000 Message-ID: <525733B6-041C-462B-A08D-9A841F13ED95@tsdye.com> References: Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:58967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFCAd-0002rQ-CR for emacs-orgmode@gnu.org; Wed, 27 Apr 2011 17:21:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFCAc-0007rL-4L for emacs-orgmode@gnu.org; Wed, 27 Apr 2011 17:21:15 -0400 Received: from oproxy6-pub.bluehost.com ([67.222.54.6]:37793) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1QFCAb-0007qu-T6 for emacs-orgmode@gnu.org; Wed, 27 Apr 2011 17:21:14 -0400 In-Reply-To: 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: Neilen Marais Cc: emacs-orgmode@gnu.org Aloha Neilen Marais, A while back I took a stab at an overly ambitious project that I've subsequently dropped. In that project I did manage to establish captions that work with org-special-blocks. What follows is a cut and paste job from the bones of the project that might help you solve the problem of captioning constructs other than figures and tables. It was aimed primarily at LaTeX export, but I seem to recall that it worked for html as well. All the best, Tom This link establishes a caption that works with both LaTeX and html and can be used to mark blocks that Org-mode doesn't recognize by default. Note that you currently have to enter these links by hand and not with the usual =org-insert-link= function, which doesn't allow spaces in the =PATH= argument. #+BEGIN_listing # <> #+source: define-caption-link #+begin_src emacs-lisp :exports code (org-add-link-type "caption" nil (lambda (path desc format) (cond ((eq format 'html) (format "%s" desc)) ((eq format 'latex) (format "\\caption[%s]{%s}" path desc))))) #+end_src [[caption:A new caption link type][A new caption link type.]] # <> #+END_listing Block-level markup is accomplished with the help of the [[latex:package][org-special-blocks]] package. It is used in this file to wrap the [[latex:progstruct][listing]] environment defined by the [[latex:package][minted]] package around a source code block to get a floating listing in the LaTeX document. LaTeX will keep track of floating listings and will also prepare a list of listings that can be placed between the table of contents and the first section of the article. [[latex:classfile][Org-article]] makes the [[latex:progstruct][listing]] environment available with the [[latex:package][listings]] package, as well, so this facility can be used regardless of the package chosen to highlight syntax and typeset source code listings. Use a construct like this to wrap the source block in a [[latex:progstruct][listing]] environment. Typically, you will want to include a figure caption and a label for cross referencing. This can be done with a =#+LATEX:= line. : #+BEGIN_listing : : #+LATEX: \caption{The caption.}\ref{fig:src_blk} : #+END_listing To use this facility, you'll need to load [[latex:package][org-special- blocks]] (Listing \ref{fig:org-special-blocks}). This code can go in =.emacs=, or you can load it for the session by executing the following source code block with =C-c C-c=. #+BEGIN_listing #+source: special-blocks #+begin_src emacs-lisp :exports code :results silent (require 'org-special-blocks) #+end_src [[caption:Require org-special-blocks][Require org-special-blocks.]] # <> #+END_listing The [[latex:package][org-special-blocks]] package leaves it up to the user to see that the HTML output is styled correctly. A line of code like Listing \ref{fig:css}, or something similar, when added to the [[latex:proglang][Org-mode]] buffer, styles listings by putting a black box around them. #+BEGIN_listing #+source: css #+begin_src org :exports code #+STYLE: #+end_src [[caption:A simple CSS style for listings][A simple CSS style for listings.]] # <> #+END_listing On Apr 27, 2011, at 5:57 AM, Neilen Marais wrote: > Hi, > > Is it possible to caption a #+begin_src or #+begin_example block? > Doing > > #+CAPTION: dipole_analytical_balanis.mac > #+begin_example > .... > #+end_example > > doesn't seem to do the trick. I would find this useful to include > suggested filenames when quoting source on a web page. > > Thanks > Neilen >