From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 2OaoKco6iWPdIwAAbAwnHQ (envelope-from ) for ; Fri, 02 Dec 2022 00:37:46 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id GKa+KMo6iWOqRgEAG6o9tA (envelope-from ) for ; Fri, 02 Dec 2022 00:37:46 +0100 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 846693A8BD for ; Fri, 2 Dec 2022 00:37:46 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0t6s-0005eq-3c; Thu, 01 Dec 2022 18:36:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0t6q-0005eJ-9h for emacs-orgmode@gnu.org; Thu, 01 Dec 2022 18:36:52 -0500 Received: from whuk14.whukhost.com ([5.77.41.174]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0t6m-0004sc-Qe for emacs-orgmode@gnu.org; Thu, 01 Dec 2022 18:36:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=heagren.com ; s=default; h=Content-Type:Message-ID:Subject:To:From:Date:MIME-Version: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=klkh7voHgJCSDMHpb5Ng2REM37WDc/tOTCWA+M+Jo78=; b=e16T/VStkyVDdjJw/DXKWchDdS sgOw+kQW/4fUoAnLTOBfs1d5SLjbj56+EOsdiACn5ccs5UPyAoH0FIIahSnZkKi3rEYBk1FgI55bA 8ElTzCcprbH9Y/Rk30DGgSk6zM4koXIqm3CJ6SpY6Xf9Z38Q/RMC4yjTS0ggCS+M8QwoLXnR3Ta07 AT3L+U7/1aVEO9M6p5N9xApEz7reW7v/QkT1IPZI2ncA9wnAEB82bAor8pt+uaOCajqsSOa8q7V34 asGhDWqYKOadpVlwHwz15jcbTKPHlozZWuXeV8rg+KPVWEUcmUma+Wdfwm0xcfPFGDA0Gp7vd1j+D QQ3LBIvg==; Received: from [::1] (port=40958 helo=whuk14.whukhost.com) by whuk14.whukhost.com with esmtpa (Exim 4.95) (envelope-from ) id 1p0t63-009mfU-QF for emacs-orgmode@gnu.org; Thu, 01 Dec 2022 23:36:04 +0000 MIME-Version: 1.0 Date: Thu, 01 Dec 2022 23:36:04 +0000 From: hugo@heagren.com To: Emacs Orgmode Subject: [PATCH] lisp/ox-latex.el: put labels inside example blocks User-Agent: Roundcube Webmail/1.5.2 Message-ID: X-Sender: hugo@heagren.com Content-Type: multipart/mixed; boundary="=_5801739738eef15c1d1a691d56ce23c8" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - whuk14.whukhost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - heagren.com X-Get-Message-Sender-Via: whuk14.whukhost.com: authenticated_id: hugo@heagren.com X-Authenticated-Sender: whuk14.whukhost.com: hugo@heagren.com X-Source: X-Source-Args: X-Source-Dir: Received-SPF: pass client-ip=5.77.41.174; envelope-from=hugo@heagren.com; helo=whuk14.whukhost.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-TUID: TITekPbycSti --=_5801739738eef15c1d1a691d56ce23c8 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed I exported an essay written in org mode to a LaTeX file (and then a pdf) today. It had `example' blocks in several consequent sections, each with a name (i.e. `#+name'). I have `org-latex-prefer-user-labels' set to t, and used these names to refer to the examples later on. I noticed that some of these labels were resolved wrong (i.e. printed as the wrong number) in the resulting pdf. Examining the tex source, this was because the labels had been printed outside (just before) the example blocks, thus: ,--- | \label{ex:foo} | \begin{example} | My example here | \end{example} `--- In tnhese cases, sometimes LaTeX interpreted the surrounding section as the subject of the label, and printed the number of that section when the label was referred to. The attached patch forces example environments to be printed thus: ,--- | \begin{example}\label{ex:foo} | My example here | \end{example} `--- This solves the problem. The logic/conditions for when to print a label, and how it is generated remain unchanged. Hope this is helpful for someone else too! Hugo --=_5801739738eef15c1d1a691d56ce23c8 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=0001-lisp-ox-latex.el-put-labels-inside-example-blocks.patch Content-Disposition: attachment; filename=0001-lisp-ox-latex.el-put-labels-inside-example-blocks.patch; size=1423 RnJvbSBjZTkyMDc1MjA4NGVhYTc3NmE4ODVkNDAzYzE4ZGRkOTgxZTkyMjAzIE1vbiBTZXAgMTc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CiAJ CQkgICAidmVyYmF0aW0iKSkpCi0gICAgICAob3JnLWxhdGV4LS13cmFwLWxhYmVsCi0gICAgICAg ZXhhbXBsZS1ibG9jawotICAgICAgIChmb3JtYXQgIlxcYmVnaW57JXN9XG4lc1xcZW5keyVzfSIK LQkgICAgICAgZW52aXJvbm1lbnQKLQkgICAgICAgKG9yZy1leHBvcnQtZm9ybWF0LWNvZGUtZGVm YXVsdCBleGFtcGxlLWJsb2NrIGluZm8pCi0JICAgICAgIGVudmlyb25tZW50KQotICAgICAgIGlu Zm8pKSkpCisgICAgICAoZm9ybWF0ICJcXGJlZ2lueyVzfSVzXG4lc1xcZW5keyVzfSIKKwkgICAg ICBlbnZpcm9ubWVudAorICAgICAgICAgICAgICAoaWYgKG9yZy1lbGVtZW50LXByb3BlcnR5IDpu YW1lIGV4YW1wbGUtYmxvY2spCisgICAgICAgICAgICAgICAgICAob3JnLWxhdGV4LS1sYWJlbCBl eGFtcGxlLWJsb2NrIGluZm8gbmlsICdmdWxsKQorICAgICAgICAgICAgICAgICIiKQorCSAgICAg IChvcmctZXhwb3J0LWZvcm1hdC1jb2RlLWRlZmF1bHQgZXhhbXBsZS1ibG9jayBpbmZvKQorCSAg ICAgIGVudmlyb25tZW50KSkpKQogCiAKIDs7OzsgRXhwb3J0IEJsb2NrCi0tIAoyLjIwLjEKCg== --=_5801739738eef15c1d1a691d56ce23c8--