* exporting cross-references to source block results
@ 2013-04-11 8:46 Vikas Rawal
2013-04-11 9:42 ` Christian Moe
0 siblings, 1 reply; 10+ messages in thread
From: Vikas Rawal @ 2013-04-11 8:46 UTC (permalink / raw)
To: emacs-orgmode
I had raised this on the mailing list earlier but my problem has not
been resolved. I shall be grateful if somebody could help debug.
My org-version is:
Org-mode version 8.0-pre(release_8.0-pre-247-gbc3ccd @ /home/vikas/lisp/org-mode/lisp/)
When I have a named source block (say crop_median), I get named
results in a table with #+RESULTS: crop_median at the top of it. I
then add a #+CAPTION to it.
Then I cross-refer to crop_median using [[crop_median]] elsewhere in
the file. When I export this to latex, the tex file shows that this
cross-reference is convered to \texttt{crop_median} rather than to
\ref(crop_median}.
The pdf file, accordingly, says crop_median where it should say the
table number.
On the other hand, a named table which is directly entered with
"#+NAME: crop_median" and is not result of a source block is
cross-referred correctly.
The same behaviour is seen when I export to odt. That is, the
cross-references to tables having #+RESULTS show up literally (as
crop_median etc) while cross-references to tables named using #+NAME
show up correctly.
Could somebody help debug. Is there something in the setup I need to
specify how to export cross-references?
Vikas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: exporting cross-references to source block results
2013-04-11 8:46 exporting cross-references to source block results Vikas Rawal
@ 2013-04-11 9:42 ` Christian Moe
2013-04-11 9:57 ` Vikas Rawal
0 siblings, 1 reply; 10+ messages in thread
From: Christian Moe @ 2013-04-11 9:42 UTC (permalink / raw)
To: Vikas Rawal; +Cc: emacs-orgmode
Hi,
I confirm the same behavior, in ODT and HTML, and think it's a
bug. Additional info:
Vikas Rawal didn't say if he also added a `#+NAME: foo' line above the
generated table. I expected that to solve it, so I tried. This did give
the table an `id="foo"' attribute on HTML export for a cross-reference
to target. However, the cross-reference still behaved the same way.
Yours,
Christian
Vikas Rawal writes:
> I had raised this on the mailing list earlier but my problem has not
> been resolved. I shall be grateful if somebody could help debug.
>
> My org-version is:
>
> Org-mode version 8.0-pre(release_8.0-pre-247-gbc3ccd @ /home/vikas/lisp/org-mode/lisp/)
>
> When I have a named source block (say crop_median), I get named
> results in a table with #+RESULTS: crop_median at the top of it. I
> then add a #+CAPTION to it.
>
> Then I cross-refer to crop_median using [[crop_median]] elsewhere in
> the file. When I export this to latex, the tex file shows that this
> cross-reference is convered to \texttt{crop_median} rather than to
> \ref(crop_median}.
>
> The pdf file, accordingly, says crop_median where it should say the
> table number.
>
> On the other hand, a named table which is directly entered with
> "#+NAME: crop_median" and is not result of a source block is
> cross-referred correctly.
>
> The same behaviour is seen when I export to odt. That is, the
> cross-references to tables having #+RESULTS show up literally (as
> crop_median etc) while cross-references to tables named using #+NAME
> show up correctly.
>
> Could somebody help debug. Is there something in the setup I need to
> specify how to export cross-references?
>
> Vikas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: exporting cross-references to source block results
2013-04-11 9:42 ` Christian Moe
@ 2013-04-11 9:57 ` Vikas Rawal
2013-04-11 10:37 ` exporting cross-references to source block results CORRECTION Christian Moe
0 siblings, 1 reply; 10+ messages in thread
From: Vikas Rawal @ 2013-04-11 9:57 UTC (permalink / raw)
To: Christian Moe; +Cc: emacs-orgmode
> I confirm the same behavior, in ODT and HTML, and think it's a
> bug. Additional info:
>
> Vikas Rawal didn't say if he also added a `#+NAME: foo' line above the
> generated table. I expected that to solve it, so I tried. This did give
> the table an `id="foo"' attribute on HTML export for a cross-reference
> to target. However, the cross-reference still behaved the same way.
Thanks Christian for confirming this.
The previous discussion is at
http://thread.gmane.org/gmane.emacs.orgmode/67727/
I had mentioned that everything works fine if you change the variable
org-babel-results-keyword to NAME. But Nicolas said that should not be
done and that the exporter should work correctly with #+RESULTS. But
at least for me, it does not work correctly.
Vikas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: exporting cross-references to source block results CORRECTION
2013-04-11 9:57 ` Vikas Rawal
@ 2013-04-11 10:37 ` Christian Moe
2013-04-11 10:46 ` Vikas Rawal
0 siblings, 1 reply; 10+ messages in thread
From: Christian Moe @ 2013-04-11 10:37 UTC (permalink / raw)
To: Vikas Rawal; +Cc: emacs-orgmode
Oops, sorry, I take back my last message, there was an error in my test
example.
Adding a #+NAME above the generated table DOES result in a correct
cross-reference. That seems like reasonable behavior to me.
Vikas, can you try this? Simply add a name to the generated table when
you also add a caption, and use that name to link.
Yours,
Christian
>> Vikas Rawal didn't say if he also added a `#+NAME: foo' line above the
>> generated table. I expected that to solve it, so I tried. This did give
>> the table an `id="foo"' attribute on HTML export for a cross-reference
>> to target. However, the cross-reference still behaved the same way.
>
> Thanks Christian for confirming this.
>
> The previous discussion is at
> http://thread.gmane.org/gmane.emacs.orgmode/67727/
>
> I had mentioned that everything works fine if you change the variable
> org-babel-results-keyword to NAME. But Nicolas said that should not be
> done and that the exporter should work correctly with #+RESULTS. But
> at least for me, it does not work correctly.
>
> Vikas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: exporting cross-references to source block results CORRECTION
2013-04-11 10:37 ` exporting cross-references to source block results CORRECTION Christian Moe
@ 2013-04-11 10:46 ` Vikas Rawal
2013-04-11 11:31 ` Christian Moe
2013-04-11 12:00 ` Nicolas Goaziou
0 siblings, 2 replies; 10+ messages in thread
From: Vikas Rawal @ 2013-04-11 10:46 UTC (permalink / raw)
To: Christian Moe; +Cc: emacs-orgmode
>
> Oops, sorry, I take back my last message, there was an error in my test
> example.
>
> Adding a #+NAME above the generated table DOES result in a correct
> cross-reference. That seems like reasonable behavior to me.
The intended behaviour, as documented by Nicolas, is that a named
source block will result in output with #+RESULTS, and that the
cross-reference will pick that up correctly.
If #+RESULT is not to work, it is better to change
org-babel-results-keyword to NAME, and then what you are suggesting
happens automatically. But in the earlier thread on the topic, Nicolas
said that was not the right way.
Vikas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: exporting cross-references to source block results CORRECTION
2013-04-11 10:46 ` Vikas Rawal
@ 2013-04-11 11:31 ` Christian Moe
2013-04-11 12:00 ` Nicolas Goaziou
1 sibling, 0 replies; 10+ messages in thread
From: Christian Moe @ 2013-04-11 11:31 UTC (permalink / raw)
To: Vikas Rawal; +Cc: emacs-orgmode
Vikas Rawal writes:
>> Oops, sorry, I take back my last message, there was an error in my test
>> example.
>>
>> Adding a #+NAME above the generated table DOES result in a correct
>> cross-reference. That seems like reasonable behavior to me.
>
> The intended behaviour, as documented by Nicolas, is that a named
> source block will result in output with #+RESULTS, and that the
> cross-reference will pick that up correctly.
I confirm that I don't get a correct cross-reference to a table that
is identified only by its #+RESULTS name.
> If #+RESULT is not to work, it is better to change
> org-babel-results-keyword to NAME, and then what you are suggesting
> happens automatically. But in the earlier thread on the topic, Nicolas
> said that was not the right way.
I see. Sorry for not following the discussion. In that way, you get both
code block and result identified by the same NAME line, and Babel
appears to be smart enough to handle that without the code block
overwriting itself...
But this solution gives faulty exports if you're exporting both code and
results (`:exports both'). In HTML, you get two different elements with
the same id attribute, the code block and the table. That shouldn't
happen. I find Firefox resolves the conflict by jumping to whichever of
the two elements appears first.
It seems to me that you would have the same problem even if the exporter
did pick up the name from the RESULTS line and make a cross-reference to
it, as you expect it to. The target would still be ambiguous.
I submit that the best way to get a cross-reference to a generated table
in all circumstances is to manually name that table with a #+NAME line
and a *unique* name, i.e. *different* from that of the source block that
generated it. This seems a reasonable requirement.
Yours,
Christian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: exporting cross-references to source block results CORRECTION
2013-04-11 10:46 ` Vikas Rawal
2013-04-11 11:31 ` Christian Moe
@ 2013-04-11 12:00 ` Nicolas Goaziou
2013-04-11 12:18 ` Vikas Rawal
1 sibling, 1 reply; 10+ messages in thread
From: Nicolas Goaziou @ 2013-04-11 12:00 UTC (permalink / raw)
To: Christian Moe; +Cc: emacs-orgmode
Hello,
Vikas Rawal <vikaslists@agrarianresearch.org> writes:
>>
>> Oops, sorry, I take back my last message, there was an error in my test
>> example.
>>
>> Adding a #+NAME above the generated table DOES result in a correct
>> cross-reference. That seems like reasonable behavior to me.
>
> The intended behaviour, as documented by Nicolas, is that a named
> source block will result in output with #+RESULTS, and that the
> cross-reference will pick that up correctly.
>
> If #+RESULT is not to work, it is better to change
> org-babel-results-keyword to NAME, and then what you are suggesting
> happens automatically. But in the earlier thread on the topic, Nicolas
> said that was not the right way.
We are misunderstanding each other.
#+results are never used for cross-references. This is a Babel internal
keyword used to refer to the source that generated this element.
Cross-references only react to #+name keyword.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: exporting cross-references to source block results CORRECTION
2013-04-11 12:00 ` Nicolas Goaziou
@ 2013-04-11 12:18 ` Vikas Rawal
2013-04-11 14:30 ` Nicolas Goaziou
0 siblings, 1 reply; 10+ messages in thread
From: Vikas Rawal @ 2013-04-11 12:18 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode, Christian Moe
> > cross-reference will pick that up correctly.
> >
> > If #+RESULT is not to work, it is better to change
> > org-babel-results-keyword to NAME, and then what you are suggesting
> > happens automatically. But in the earlier thread on the topic, Nicolas
> > said that was not the right way.
>
> We are misunderstanding each other.
>
> #+results are never used for cross-references. This is a Babel internal
> keyword used to refer to the source that generated this element.
>
> Cross-references only react to #+name keyword.
>
Sorry, this is confusing. Is it then the case that we are naming the
source block to ensure that captions stick to the corresponding
results block? And then, we need to separately name the results block,
and use a different name for it, so that the cross-references pick it
up correctly?
Vikas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: exporting cross-references to source block results CORRECTION
2013-04-11 12:18 ` Vikas Rawal
@ 2013-04-11 14:30 ` Nicolas Goaziou
2013-04-11 15:24 ` Vikas Rawal
0 siblings, 1 reply; 10+ messages in thread
From: Nicolas Goaziou @ 2013-04-11 14:30 UTC (permalink / raw)
To: Christian Moe; +Cc: emacs-orgmode
Vikas Rawal <vikaslists@agrarianresearch.org> writes:
>> > cross-reference will pick that up correctly.
>> >
>> > If #+RESULT is not to work, it is better to change
>> > org-babel-results-keyword to NAME, and then what you are suggesting
>> > happens automatically. But in the earlier thread on the topic, Nicolas
>> > said that was not the right way.
>>
>> We are misunderstanding each other.
>>
>> #+results are never used for cross-references. This is a Babel internal
>> keyword used to refer to the source that generated this element.
>>
>> Cross-references only react to #+name keyword.
>>
>
>
> Sorry, this is confusing. Is it then the case that we are naming the
> source block to ensure that captions stick to the corresponding
> results block?
Source block captions apply to the source block, not to the results. You
have to define a separate caption for the results.
Source block name will be used both as a label for cross referencing and
as a Babel internal code for results correspondence.
> And then, we need to separately name the results block, and use
> a different name for it, so that the cross-references pick it up
> correctly?
Yes, the name given to the results block doesn't depend on the results
keyword. You can give it any name, as long as it is unique.
Here is an example:
#+caption: Src block caption
#+name: my-src
#+begin_src emacs-lisp
(+ 1 2)
#+end_src
#+name: anything
#+caption: Element caption
#+results: my-src
: 3
As far as affiliated keywords go, the only one you needn't provide is
"#+results:".
HTH,
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: exporting cross-references to source block results CORRECTION
2013-04-11 14:30 ` Nicolas Goaziou
@ 2013-04-11 15:24 ` Vikas Rawal
0 siblings, 0 replies; 10+ messages in thread
From: Vikas Rawal @ 2013-04-11 15:24 UTC (permalink / raw)
To: emacs-orgmode
>
> > And then, we need to separately name the results block, and use
> > a different name for it, so that the cross-references pick it up
> > correctly?
>
> Yes, the name given to the results block doesn't depend on the results
> keyword. You can give it any name, as long as it is unique.
>
> Here is an example:
>
> #+caption: Src block caption
> #+name: my-src
> #+begin_src emacs-lisp
> (+ 1 2)
> #+end_src
>
> #+name: anything
> #+caption: Element caption
> #+results: my-src
> : 3
>
> As far as affiliated keywords go, the only one you needn't provide is
> "#+results:".
Abundantly clear. Thank you.
Have already started cleaning my file and it is working the way it
should :)
Vikas
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-04-11 15:24 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-11 8:46 exporting cross-references to source block results Vikas Rawal
2013-04-11 9:42 ` Christian Moe
2013-04-11 9:57 ` Vikas Rawal
2013-04-11 10:37 ` exporting cross-references to source block results CORRECTION Christian Moe
2013-04-11 10:46 ` Vikas Rawal
2013-04-11 11:31 ` Christian Moe
2013-04-11 12:00 ` Nicolas Goaziou
2013-04-11 12:18 ` Vikas Rawal
2013-04-11 14:30 ` Nicolas Goaziou
2013-04-11 15:24 ` Vikas Rawal
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).