* example or source blocks with captions
@ 2011-04-27 15:57 Neilen Marais
2011-04-27 19:36 ` Sébastien Vauban
2011-04-27 21:21 ` Thomas S. Dye
0 siblings, 2 replies; 6+ messages in thread
From: Neilen Marais @ 2011-04-27 15:57 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: example or source blocks with captions
2011-04-27 15:57 example or source blocks with captions Neilen Marais
@ 2011-04-27 19:36 ` Sébastien Vauban
2011-04-30 5:00 ` Jambunathan K
2011-04-27 21:21 ` Thomas S. Dye
1 sibling, 1 reply; 6+ messages in thread
From: Sébastien Vauban @ 2011-04-27 19:36 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Neilen,
Neilen Marais wrote:
> 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.
Would such block be better for you?
--8<---------------cut here---------------start------------->8---
#+srcname: dipole_analytical_balanis.mac
#+begin_src mac
....
#+end_src
--8<---------------cut here---------------end--------------->8---
The source name should be exported in HTML. If not, this is a feature.[1]
Best regards,
Seb
Footnotes:
[1] I know for sure it does when the block has "grounded" parameters (ie, with
a given value).
--
Sébastien Vauban
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: example or source blocks with captions
2011-04-27 15:57 example or source blocks with captions Neilen Marais
2011-04-27 19:36 ` Sébastien Vauban
@ 2011-04-27 21:21 ` Thomas S. Dye
2011-04-28 7:46 ` Sébastien Vauban
1 sibling, 1 reply; 6+ messages in thread
From: Thomas S. Dye @ 2011-04-27 21:21 UTC (permalink / raw)
To: Neilen Marais; +Cc: emacs-orgmode
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
# <<caption-link-type>>
#+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 "<span class=\"caption\">%s</span>" desc))
((eq format 'latex)
(format "\\caption[%s]{%s}" path desc)))))
#+end_src
[[caption:A new caption link type][A new caption link type.]]
# <<fig:caption-link>>
#+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
: <source block>
: #+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.]]
# <<fig: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: <style>.listing {margin: 1em; padding: 1em; border: 1px
solid black}</style>
#+end_src
[[caption:A simple CSS style for listings][A simple CSS style for
listings.]]
# <<fig:css>>
#+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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: example or source blocks with captions
2011-04-27 21:21 ` Thomas S. Dye
@ 2011-04-28 7:46 ` Sébastien Vauban
0 siblings, 0 replies; 6+ messages in thread
From: Sébastien Vauban @ 2011-04-28 7:46 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Thomas,
"Thomas S. Dye" wrote:
> 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
> # <<caption-link-type>>
> #+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 "<span class=\"caption\">%s</span>" desc))
> ((eq format 'latex)
> (format "\\caption[%s]{%s}" path desc)))))
> #+end_src
> [[caption:A new caption link type][A new caption link type.]]
> # <<fig:caption-link>>
> #+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.
Interesting read. Could you share the definition of your `latex' link type?
Best regards,
Seb
--
Sébastien Vauban
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: example or source blocks with captions
2011-04-27 19:36 ` Sébastien Vauban
@ 2011-04-30 5:00 ` Jambunathan K
0 siblings, 0 replies; 6+ messages in thread
From: Jambunathan K @ 2011-04-30 5:00 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ
Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
writes:
> Hi Neilen,
>
> Neilen Marais wrote:
>> 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.
>
> Would such block be better for you?
>
> #+srcname: dipole_analytical_balanis.mac
> #+begin_src mac
> ....
> #+end_src
>
> The source name should be exported in HTML. If not, this is a feature.[1]
>
A cursory look suggests that
org-export-format-source-code-or-example takes caption as an arg. This
is used only if htmlize or org-export-latex-listings is configured by
the user - Both of these are not part of factory settings and wouldn't
work out of the box. (Seems like the situation could be improved)
ASCII export always exports a caption without fail.
So if I export
* Source Block
** Emacs Lisp Block
--8<---------------cut here---------------start------------->8---
#+CAPTION: HelloWorldCaption
#+srcname: HelloWorldSrcName
#+begin_src emacs-lisp
(defun helloworld ()
""
(message "hello world"))
#+end_src
--8<---------------cut here---------------end--------------->8---
I get something like
--8<---------------cut here---------------start------------->8---
1 Source Block
---------------
1.1 Emacs Lisp Block
=====================
(defun helloworld ()
""
(message "hello world"))
--8<---------------cut here---------------end--------------->8---
meaning that captions are not possibly passed into
org-export-format-source-code-or-example.
A cursory look at org-export-attach-captions-and-attributes where
('org-caption text property is added) suggests that captions are not
getting associated with the src blocks.
In summary, there seems to be a clear intent to attach a caption to
example or source blocks but somehow things are turning out otherwise.
Jambunathan K.
> Best regards,
> Seb
>
> Footnotes:
>
> [1] I know for sure it does when the block has "grounded" parameters (ie, with
> a given value).
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: example or source blocks with captions
@ 2011-04-30 5:00 Jambunathan K
0 siblings, 0 replies; 6+ messages in thread
From: Jambunathan K @ 2011-04-30 5:00 UTC (permalink / raw)
To: emacs-orgmode
(Forwarding it - Looks like the original mail didn't make it's way to
the list)
> Hi Neilen,
>
> Neilen Marais wrote:
>> 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.
>
> Would such block be better for you?
>
> #+srcname: dipole_analytical_balanis.mac
> #+begin_src mac
> ....
> #+end_src
>
> The source name should be exported in HTML. If not, this is a feature.[1]
>
A cursory look suggests that
org-export-format-source-code-or-example takes caption as an arg. This
is used only if htmlize or org-export-latex-listings is configured by
the user - Both of these are not part of factory settings and wouldn't
work out of the box. (Seems like the situation could be improved)
ASCII export always exports a caption without fail.
So if I export
* Source Block
** Emacs Lisp Block
--8<---------------cut here---------------start------------->8---
#+CAPTION: HelloWorldCaption
#+srcname: HelloWorldSrcName
#+begin_src emacs-lisp
(defun helloworld ()
""
(message "hello world"))
#+end_src
--8<---------------cut here---------------end--------------->8---
I get something like
--8<---------------cut here---------------start------------->8---
1 Source Block
---------------
1.1 Emacs Lisp Block
=====================
(defun helloworld ()
""
(message "hello world"))
--8<---------------cut here---------------end--------------->8---
meaning that captions are not possibly passed into
org-export-format-source-code-or-example.
A cursory look at org-export-attach-captions-and-attributes where
('org-caption text property is added) suggests that captions are not
getting associated with the src blocks.
In summary, there seems to be a clear intent to attach a caption to
example or source blocks but somehow things are turning out otherwise.
Jambunathan K.
> Best regards,
> Seb
>
> Footnotes:
>
> [1] I know for sure it does when the block has "grounded" parameters (ie, with
> a given value).
--
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-04-30 5:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-27 15:57 example or source blocks with captions Neilen Marais
2011-04-27 19:36 ` Sébastien Vauban
2011-04-30 5:00 ` Jambunathan K
2011-04-27 21:21 ` Thomas S. Dye
2011-04-28 7:46 ` Sébastien Vauban
-- strict thread matches above, loose matches on Subject: below --
2011-04-30 5:00 Jambunathan K
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.