emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: James Powell <powellj@pdx.edu>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: Bug: redundant and undocumented #label is required to link to a table [9.4.4 (9.4.4-dist @ /home/powellj/elisp/org-9.4.4/lisp/)]
Date: Mon, 19 Apr 2021 11:48:12 -0700	[thread overview]
Message-ID: <b5a3b02b-03d6-2e04-fc6f-6b793504c197@pdx.edu> (raw)
In-Reply-To: <87lf9eb22e.fsf@nicolasgoaziou.fr>

If I put #+name before the table, the link does indeed work, but now
the table is reproduced twice in the latex output and also C-c C-c in
the code block writes a new table into the file instead of updating
the current table.

Before C-c C-c in the code block, this org snippet produces the table 
twice in the latex output:
<<begin>>
#+begin_src R :exports both
   library(tidyverse)
   x <- tribble(~a, ~b, 1, 3)
   x
#+end_src
#+NAME: t1
#+CAPTION: Org Table
#+RESULTS: t1
| 1 | 3 |

I want to refer to Table [[t1]].
<<end>>

After C-c C-c in the code block, the table appears twice in the org mode 
file:
<<begin>>
#+begin_src R :exports both
   library(tidyverse)
   x <- tribble(~a, ~b, 1, 3)
   x
#+end_src

#+RESULTS:
| 1 | 3 |

#+NAME: t1
#+CAPTION: Org Table
#+RESULTS: t1
| 1 | 3 |

I want to refer to Table [[t1]].
<<end>>

The literature and the Library of Babel do not seem to address the
case, which is so common in peer-reviewed literature, of a captioned
and referenced table that was produced by code.  It was only through a
large investment in trial and error and searching that I was able to
build the example above, in which the code does indeed generate a
table that is captioned and referenced.

- JP

On 4/19/21 10:45 AM, Nicolas Goaziou wrote:
> Hello,
>
> James Powell <powellj@pdx.edu> writes:
>
>> Using Org mode version 9.4.4 I build this document:
>>
>> <<begin>>
>>
>> #+NAME: t1
>> #+begin_src R :exports both
>>
>>     library(tidyverse)   x <- tribble(~a, ~b, 1, 3)   x #+end_src
>>
>> #+CAPTION: Org Table
>> #+RESULTS: t1
>>
>> | 1 | 3 |
>>
>> I want to refer to Table [[t1]].
>> <<end>>
>>
>> What I expect: the latex export will include the table and link to it.
>>
>> What happens instead: the code and table appear, numbered and captioned.
>> However, the link is broken ("I want to refer to Table ??"). Looking in
>> the latex, this line reads
>>
>>   > I want to refer to Table \ref{org993764c}.
>>
>> but that label org993764c appears nowhere else in the file.
>>
>> Org-lint doesn't complain about the file at all.  I posted this
>> earlier to this list and learned about a workaround
>>
>> " It works if you put a #+label on the table ... which confuses me,
>> because I looked through the manual for #+label and there's no mention
>> of it at all, but a bunch of my Org files use it (for LaTeX export). "
> #+label is an outdated equivalent for #+name.
>
> In this case, you are referencing the source code block whereas you want
> to reference the table. So #+name should go before the table.
>
> Note that if you follow [[t1]] link, point will move to the source code
> block, not the table.
>
> Regards,

-- 
James E. Powell, MS
Pronouns: he/him/his
Applied Physics PhD Candidate
Department of Physics
Portland State University
Home page: http://web.pdx.edu/~powellj
Office: SRTC 409B Phone: +1-503-725-8515



  reply	other threads:[~2021-04-19 18:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 17:18 Bug: redundant and undocumented #label is required to link to a table [9.4.4 (9.4.4-dist @ /home/powellj/elisp/org-9.4.4/lisp/)] James Powell
2021-04-19 17:45 ` Nicolas Goaziou
2021-04-19 18:48   ` James Powell [this message]
2021-04-19 19:31     ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5a3b02b-03d6-2e04-fc6f-6b793504c197@pdx.edu \
    --to=powellj@pdx.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).