emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Source blocks with captions
@ 2014-06-23 15:19 Alexander Baier
  2014-06-23 15:43 ` Thorsten Jolitz
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Baier @ 2014-06-23 15:19 UTC (permalink / raw)
  To: emacs-orgmode

Hello org-moders!

I just tried to put a caption under/on/above (or anywhere for that
matter) my source code block.  When exporting to latex, I didn't see any
caption belonging to my code block.  Other backends have not been
tried.  How can I achieve this?

For reference, I run Org-mode version 8.2.6 (release_8.2.6 @
/home/delexi/.emacs.d/ext/org-mode/lisp/) and this is the org file:

* Test
#+CAPTION: Test
#BEGIN_SRC java
  // some code
#END_SRC

Thanks in advance,
-- 
Alexander Baier

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Source blocks with captions
  2014-06-23 15:19 Source blocks with captions Alexander Baier
@ 2014-06-23 15:43 ` Thorsten Jolitz
  2014-06-23 18:47   ` Alexander Baier
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2014-06-23 15:43 UTC (permalink / raw)
  To: emacs-orgmode

Alexander Baier <alexander.baier@mailbox.org> writes:

> Hello org-moders!
>
> I just tried to put a caption under/on/above (or anywhere for that
> matter) my source code block.  When exporting to latex, I didn't see any
> caption belonging to my code block.  Other backends have not been
> tried.  How can I achieve this?
>
> For reference, I run Org-mode version 8.2.6 (release_8.2.6 @
> /home/delexi/.emacs.d/ext/org-mode/lisp/) and this is the org file:
>
> * Test
> #+CAPTION: Test
> #BEGIN_SRC java
>   // some code
> #END_SRC

shouldn't that be 

,----
| #+NAME: Test
`----

instead of 

,----
| #+CAPTION: Test
`----

?

-- 
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Source blocks with captions
  2014-06-23 15:43 ` Thorsten Jolitz
@ 2014-06-23 18:47   ` Alexander Baier
  2014-06-23 19:23     ` Thomas S. Dye
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Baier @ 2014-06-23 18:47 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode

On 2014-06-23 17:43 Thorsten Jolitz wrote:
> Alexander Baier <alexander.baier@mailbox.org> writes:
>
>> Hello org-moders!
>>
>> I just tried to put a caption under/on/above (or anywhere for that
>> matter) my source code block.  When exporting to latex, I didn't see any
>> caption belonging to my code block.  Other backends have not been
>> tried.  How can I achieve this?
>>
>> For reference, I run Org-mode version 8.2.6 (release_8.2.6 @
>> /home/delexi/.emacs.d/ext/org-mode/lisp/) and this is the org file:
>>
>> * Test
>> #+CAPTION: Test
>> #BEGIN_SRC java
>>   // some code
>> #END_SRC
>
> shouldn't that be 
>
> ,----
> | #+NAME: Test
> `----
>
> instead of 
>
> ,----
> | #+CAPTION: Test
> `----
>
> ?

This does not work for me - I still see no caption or a similar thing in
the vicinity of my code block.  Does "#+NAME" work for you?

Regards,
-- 
Alexander Baier

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Source blocks with captions
  2014-06-23 18:47   ` Alexander Baier
@ 2014-06-23 19:23     ` Thomas S. Dye
  2014-06-24 12:31       ` Alexander Baier
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas S. Dye @ 2014-06-23 19:23 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode

Aloha Alexander,

Alexander Baier <alexander.baier@mailbox.org> writes:

> On 2014-06-23 17:43 Thorsten Jolitz wrote:
>> Alexander Baier <alexander.baier@mailbox.org> writes:
>>
>>> Hello org-moders!
>>>
>>> I just tried to put a caption under/on/above (or anywhere for that
>>> matter) my source code block.  When exporting to latex, I didn't see any
>>> caption belonging to my code block.  Other backends have not been
>>> tried.  How can I achieve this?
>>>
>>> For reference, I run Org-mode version 8.2.6 (release_8.2.6 @
>>> /home/delexi/.emacs.d/ext/org-mode/lisp/) and this is the org file:
>>>
>>> * Test
>>> #+CAPTION: Test
>>> #BEGIN_SRC java
>>>   // some code
>>> #END_SRC
>>
>> shouldn't that be 
>>
>> ,----
>> | #+NAME: Test
>> `----
>>
>> instead of 
>>
>> ,----
>> | #+CAPTION: Test
>> `----
>>
>> ?
>
> This does not work for me - I still see no caption or a similar thing in
> the vicinity of my code block.  Does "#+NAME" work for you?
>
> Regards,

There are two errors in your Org mode file on the BEGIN_SRC and END_SRC
lines.

With this code:

 * Test

 #+CAPTION: Test
 #+BEGIN_SRC java
    // some code
 #+END_SRC

I get a figure with a caption when exporting to LaTeX:

 \section{Test}
 \label{sec-1}

 \begin{figure}[H]
 \begin{verbatim}
 // some code
 \end{verbatim}\caption{Test}

 \end{figure}

You don't need to name the source code block, although it is typically a
good idea to do so.

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Source blocks with captions
  2014-06-23 19:23     ` Thomas S. Dye
@ 2014-06-24 12:31       ` Alexander Baier
  2014-06-25 11:20         ` [Latex] Don't push code blocks to end of document (was: Source blocks with captions) Alexander Baier
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Baier @ 2014-06-24 12:31 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode, Thorsten Jolitz

On 2014-06-23 21:23 Thomas S. Dye wrote:
> Aloha Alexander,
>
> Alexander Baier <alexander.baier@mailbox.org> writes:
>
>> On 2014-06-23 17:43 Thorsten Jolitz wrote:
>>> Alexander Baier <alexander.baier@mailbox.org> writes:
>>>
>>>> Hello org-moders!
>>>>
>>>> I just tried to put a caption under/on/above (or anywhere for that
>>>> matter) my source code block.  When exporting to latex, I didn't see any
>>>> caption belonging to my code block.  Other backends have not been
>>>> tried.  How can I achieve this?
>>>>
>>>> For reference, I run Org-mode version 8.2.6 (release_8.2.6 @
>>>> /home/delexi/.emacs.d/ext/org-mode/lisp/) and this is the org file:
>>>>
>>>> * Test
>>>> #+CAPTION: Test
>>>> #BEGIN_SRC java
>>>>   // some code
>>>> #END_SRC
>>>
>>> shouldn't that be 
>>>
>>> ,----
>>> | #+NAME: Test
>>> `----
>>>
>>> instead of 
>>>
>>> ,----
>>> | #+CAPTION: Test
>>> `----
>>>
>>> ?
>>
>> This does not work for me - I still see no caption or a similar thing in
>> the vicinity of my code block.  Does "#+NAME" work for you?
>>
>> Regards,
>
> There are two errors in your Org mode file on the BEGIN_SRC and END_SRC
> lines.

You are of course right! This was just a mistake I made whilst putting
together this short example.  In my "normal" setup the source code
blocks have the right form.

> With this code:
>
>  * Test
>
>  #+CAPTION: Test
>  #+BEGIN_SRC java
>     // some code
>  #+END_SRC
>
> I get a figure with a caption when exporting to LaTeX:
>
>  \section{Test}
>  \label{sec-1}
>
>  \begin{figure}[H]
>  \begin{verbatim}
>  // some code
>  \end{verbatim}\caption{Test}
>
>  \end{figure}
>
> You don't need to name the source code block, although it is typically a
> good idea to do so.

I always only looked at the generated PDF to see if there was a caption
added.  When opening the generated .tex file I found the same code you
are seeing.  It seems the document class I am using just drops the
caption.

The class in question is LLNCS, does anyone know why this could happen?

Regards,
-- 
Alexander Baier

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Latex] Don't push code blocks to end of document (was: Source blocks with captions)
  2014-06-24 12:31       ` Alexander Baier
@ 2014-06-25 11:20         ` Alexander Baier
  2014-06-25 12:22           ` [Latex] Don't push code blocks to end of document Alexander Baier
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Baier @ 2014-06-25 11:20 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode, Thorsten Jolitz

On 2014-06-24 14:31 Alexander Baier wrote:

[...]

>> With this code:
>>
>>  * Test
>>
>>  #+CAPTION: Test
>>  #+BEGIN_SRC java
>>     // some code
>>  #+END_SRC
>>
>> I get a figure with a caption when exporting to LaTeX:
>>
>>  \section{Test}
>>  \label{sec-1}
>>
>>  \begin{figure}[H]
>>  \begin{verbatim}
>>  // some code
>>  \end{verbatim}\caption{Test}
>>
>>  \end{figure}
>>
>> You don't need to name the source code block, although it is typically a
>> good idea to do so.
>
> I always only looked at the generated PDF to see if there was a caption
> added.  When opening the generated .tex file I found the same code you
> are seeing.  It seems the document class I am using just drops the
> caption.
>
> The class in question is LLNCS, does anyone know why this could happen?

In fact, the document class does not drop those captions, it just moves
the listings to the end of the document, where I did not see them.

How do I prevent this from happening? It is not much use to me if _all_
my listings are pushed to the very end of my document. I would like
latex to place them in the vicinity of where I defined my code block in
org.

This is the test file showing the behaviour described above:

----------------------------------------------------------------
#+LANGUAGE: de
#+OPTIONS: tasks:nil num:3 toc:nil ':t ":t
#+LATEX_CLASS: llncs
#+TITLE: Test

* A headline
Some words before the source code block.
For good measure, here is a link to listing [[src:foo]].

#+NAME: src:foo
#+CAPTION: test caption.
#+BEGIN_SRC java
  interface Foo {
      void bar();
  }
#+END_SRC

And some words after the block.
----------------------------------------------------------------


Thanks,
-- 
Alexander Baier

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Latex] Don't push code blocks to end of document
  2014-06-25 11:20         ` [Latex] Don't push code blocks to end of document (was: Source blocks with captions) Alexander Baier
@ 2014-06-25 12:22           ` Alexander Baier
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Baier @ 2014-06-25 12:22 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode, Thorsten Jolitz

Hello again,

this is another follow up, I am sorry for so much noise.

On 2014-06-25 13:20 Alexander Baier wrote:
> On 2014-06-24 14:31 Alexander Baier wrote:
>
> [...]
>
>>> With this code:
>>>
>>>  * Test
>>>
>>>  #+CAPTION: Test
>>>  #+BEGIN_SRC java
>>>     // some code
>>>  #+END_SRC
>>>
>>> I get a figure with a caption when exporting to LaTeX:
>>>
>>>  \section{Test}
>>>  \label{sec-1}
>>>
>>>  \begin{figure}[H]
>>>  \begin{verbatim}
>>>  // some code
>>>  \end{verbatim}\caption{Test}
>>>
>>>  \end{figure}
>>>
>>> You don't need to name the source code block, although it is typically a
>>> good idea to do so.
>>
>> I always only looked at the generated PDF to see if there was a caption
>> added.  When opening the generated .tex file I found the same code you
>> are seeing.  It seems the document class I am using just drops the
>> caption.
>>
>> The class in question is LLNCS, does anyone know why this could happen?
>
> In fact, the document class does not drop those captions, it just moves
> the listings to the end of the document, where I did not see them.
>
> How do I prevent this from happening? It is not much use to me if _all_
> my listings are pushed to the very end of my document. I would like
> latex to place them in the vicinity of where I defined my code block in
> org.

I fixed this by using the listings package. I set "org-latex-listings"
to true and followed the instructions in the doc string of said
variable. Now, my code blocks are placed where I want them and are even
syntax highlighted!

[...]

Regards,
-- 
Alexander Baier

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-25 12:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-23 15:19 Source blocks with captions Alexander Baier
2014-06-23 15:43 ` Thorsten Jolitz
2014-06-23 18:47   ` Alexander Baier
2014-06-23 19:23     ` Thomas S. Dye
2014-06-24 12:31       ` Alexander Baier
2014-06-25 11:20         ` [Latex] Don't push code blocks to end of document (was: Source blocks with captions) Alexander Baier
2014-06-25 12:22           ` [Latex] Don't push code blocks to end of document Alexander Baier

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).