From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id AGjPJ6LnfWC+YwAAgWs5BA (envelope-from ) for ; Mon, 19 Apr 2021 22:27:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id uMdcI6LnfWAtaAAAbx9fmQ (envelope-from ) for ; Mon, 19 Apr 2021 20:27:14 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B0F23F863 for ; Mon, 19 Apr 2021 22:27:13 +0200 (CEST) Received: from localhost ([::1]:58296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYaUC-0001Zc-9V for larch@yhetil.org; Mon, 19 Apr 2021 16:27:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYZcJ-0003Tp-I6 for emacs-orgmode@gnu.org; Mon, 19 Apr 2021 15:31:31 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:35011) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYZcG-0006kK-VT for emacs-orgmode@gnu.org; Mon, 19 Apr 2021 15:31:31 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 465B020002; Mon, 19 Apr 2021 19:31:24 +0000 (UTC) From: Nicolas Goaziou To: James Powell 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/)] References: <35a09991-d1c9-647e-4f14-fa3b3274c3a2@pdx.edu> <87lf9eb22e.fsf@nicolasgoaziou.fr> Mail-Followup-To: James Powell , emacs-orgmode@gnu.org Date: Mon, 19 Apr 2021 21:31:23 +0200 In-Reply-To: (James Powell's message of "Mon, 19 Apr 2021 11:48:12 -0700") Message-ID: <878s5eax6c.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=217.70.183.200; envelope-from=mail@nicolasgoaziou.fr; helo=relay7-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1618864034; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5s7SUKWHoooyYHXubOiQDbkL1/wHYte/yhtX8zd4Zl4=; b=Ch9fUjDrvYfJIgx7OpETWNDH0xShZOV1jJ/jQfYWCMaUzr+1eM39ZPHy/h4PDEy1OdAgN4 e66rpRj72GJghQQhB2U0YLi5MB26v7/M5X7GN80wHBBGw1FK2R3XYwmaxYgQqNOeLxaAYL 9uCIf3bVK+OjUIJRyXl5N9qwlGWlZnSy7auONJsX5lWE+dPApQwEhBSCUUAWafRlLrkyuq 9VvO5rEg2CgbP2ZZc+uFe9iiNcZ7hJwU69T8pH2TcNR1gQu+e1Bq66LgB5Q0mH6Jr5SvJ5 ztMwftYK4pyKh3lm8TJWFR1CIJrPAlDbK3R9OIiedU05AujxW/XYf5kNCU7FMg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618864034; a=rsa-sha256; cv=none; b=YiDvbedBw+WfWdw3ZnWchbgzrt7FGEscrU+NYDlI1r5ggZZgdvthX1B7UTiwbLcduEjNy2 vOl+WBW91e+m3SQ0RmBM9J9f0pAwpqZShCuc0JXHYmB3qqQf4pqogTRX5J/dAktxpy8pOE TDDa11r6hVCnhQU6aKnVhbmU24mrGo5KuCnUbbMaUo7qt9ms88b6uhY4LcUVWiRykKiOVB M/fbPgJueDJ7vrxkU5jf6iKrm31E7AVsD3XOKDsOdnDhAfewGr2zF0NNwKU7RidXY4aA48 8QO/Pw0IhPftTdTaiEYaKVBCqvCdQJSOr/LUx+z/UysvZDi/tmY3FopUnMTVOQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -0.94 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: B0F23F863 X-Spam-Score: -0.94 X-Migadu-Scanner: scn0.migadu.com X-TUID: UhT+e6vXHDe5 James Powell writes: > 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=20 > twice in the latex output: > <> > > #+begin_src R :exports both > =C2=A0 library(tidyverse) > =C2=A0 x <- tribble(~a, ~b, 1, 3) > =C2=A0 x > #+end_src > > #+NAME: t1 > #+CAPTION: Org Table > > #+RESULTS: t1 > | 1 | 3 | > > > I want to refer to Table [[t1]]. > <> OK. My explanation was a bit short. Let me expound it a bit. There are two important keywords in this situation: #+name and #+results. The former is used to reference a specific element in a document. The latter is used to know what source code block produced an element. #+results keywords are automatically generated by Org whereas #+name keywords are always written by the user. When you see "#+results: t1" above a table in the previous example, you and Org know a source block named (with #+name) "t1" generated this table. Example: #+name: some name #+begin_src R :exports both library(tidyverse) x <- tribble(~a, ~b, 1, 3) x #+end_src generates #+results: some name | 1 | 3 | If you then write "tribble(~a, ~b, 1, 4)" in the source block, evaluating it again will replace the table because Org knows what table you are generating: #+results: some name | 1 | 4 | Note that since the table itself doesn't have any "#+name", you cannot reference it with an internal link yet. Had you seen "#+results:" instead, you would have known that an unnamed source block, located right above the table, had created the table. Example: #+begin_src R :exports both library(tidyverse) x <- tribble(~a, ~b, 1, 3) x #+end_src #+results: | 1 | 3 | > After C-c C-c in the code block, the table appears twice in the org mode= =20 > file: Let's analyze your document, which I paste here for easier reading: #+begin_src R :exports both library(tidyverse) x <- tribble(~a, ~b, 1, 3) x #+end_src =20=20 #+NAME: t1 #+CAPTION: Org Table #+RESULTS: t1 | 1 | 3 | Your source block is now unnamed. Upon evaluating it, Org looks for some generated structure right below it. Unfortunately, the table below claims (per #+results keyword) to come from a source block named "t1". Consequently, it cannot be the output of the code block Org is currently evaluating, and Org deduces no previous output has been created so far by the code block: it inserts a new table in the document. Moreover, an element, here the table, cannot realistically have both #+name and #+results set to the same value, as it raises a chicken and egg problem. It is not really an error though. So, the correct document would be the following: #+name: t1 #+begin_src R :exports both library(tidyverse) x <- tribble(~a, ~b, 1, 3) x #+end_src =20=20 #+caption: Org Table #+results: t1 | 1 | 3 | With it, evaluating (with C-c C-c) the source code block will not create a new table, because references are appropriately set. If you later want to refer to the table, you can write, e.g., #+name: t1 #+begin_src R :exports both library(tidyverse) x <- tribble(~a, ~b, 1, 3) x #+end_src =20=20 #+name: t1_output #+caption: Org Table #+results: t1 | 1 | 3 | so [[t1_output]] links jump to the table. HTH, --=20 Nicolas Goaziou