From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 8EtNK2ugs2VTIQEAe85BDQ:P1 (envelope-from ) for ; Fri, 26 Jan 2024 13:07:07 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 8EtNK2ugs2VTIQEAe85BDQ (envelope-from ) for ; Fri, 26 Jan 2024 13:07:07 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=ZZP52FKe; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1706270827; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=J0hmaRqxEzD6fRiDc6blhOIIzjXj6dIUn2frz/Ah4iM=; b=tH7xZjDTixkNAUCmg6+US3+HKww/QJIgljRCTEcrp5/s0NSucOrshX9VdfrdnwR/8Tzc5z 3bOMLQOl35t7/mhmhyDGTgBqLa3fgZ+p0ElNW9TikTQE12a3zRXpv+Ns4/OkGL9OqQjIzX Ro9RIR7zxvfl24XtJoNOKmoedlDDBaBJ0c+KBDhPWo834ngiFG68LJ/KsCOvKtuCKiQKZp pJRxsKfRFfYpOtCUHrsCmVi/6qzWN0U+Cm9Gy+OQadvpzRK866SobKP/5lw1Lq8dTzbrGq S/L5g2AO5v8gUZLQpC/vOH1HIHddZamm+rmVfCUuH08z6JAOUL3ybv8OFLjwTg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=ZZP52FKe; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1706270827; a=rsa-sha256; cv=none; b=oXbqqGaYRyrNqXO+g3Pz8fhsXbu/OlYbKMZeR8BfsqtLd64XsqgzuoEApImgxW1zjOAjy3 VX5QZU92bkJx2PDPVvjp2F7XGsAxUn3X3XO3zhzg/Cxk/fjHPOy5txo260Ns/0qwwUXnTy MUs1S+7wAPtfpQaHlnntv4RIry8i4AarcWeXvInJfi50Ma0+bGs/SvOdPQPp91g10BYkga B+i9YlBJoKPn1jsA2rHGJ103YpLyQSO5TmobnSkw9lbvnTOxrPbyqbOPaLOgrruf58SNzD 0M+aujWAPMe0XzAGtZWfbRWmoHeDGQXlH010pF9Eq6v/Pxb7RAiuHr6PaWjvQQ== 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 47A315C045 for ; Fri, 26 Jan 2024 13:07:07 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTKyb-0007Fz-8M; Fri, 26 Jan 2024 07:06:29 -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 1rTKyY-0007AT-Uu for emacs-orgmode@gnu.org; Fri, 26 Jan 2024 07:06:27 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTKyW-00023t-29 for emacs-orgmode@gnu.org; Fri, 26 Jan 2024 07:06:26 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 27B15240103 for ; Fri, 26 Jan 2024 13:06:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1706270780; bh=4fSyD6enrN5URN0oSjjzwAMxaKtaZe4YARd+iYZjhdA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=ZZP52FKehj5clRqpkHH79KDQpWIfc3ALYG+fclKgbYufY1qffwvnv29vbvwzSfQ2t DtRv+IfhgwJZViho4RFb5pcn3UQ7Ws0ZPmdAOssPVTOB0RhigBPnwplle09axR6AfD UBFWqiMPJVjGc3E3uzUC4L3ZoeT0OTFBNeUQ+Ncuj2lK9YEWyuP6KATDnc91NbhZm5 LdFxpwD3lESAZIzxe81aUBkQ6CrInrMr+w6hd3p4FytOJc8vUZSua3i+XlPzweCOAj mWxOd6s0tnUWI+okE/TlnNGlZAxFrc/1P564ZqIVnh8MZXU9kBM5v9YDuKbVp61LgQ NaXYF2E5Hf0QQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TLxHb1Kqmz6tw2; Fri, 26 Jan 2024 13:06:18 +0100 (CET) From: Ihor Radchenko To: Max Nikulin Cc: Eric Anderson , Timothy , emacs-orgmode@gnu.org Subject: Re: [BUG] Footnotes in section titles In-Reply-To: <691643eb-49d0-45c3-ab7f-a1edbd093bef@gmail.com> References: <87sf2ngcd2.fsf@localhost> <691643eb-49d0-45c3-ab7f-a1edbd093bef@gmail.com> Date: Fri, 26 Jan 2024 12:09:52 +0000 Message-ID: <878r4cfg8f.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_SBL_A=0.1 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-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.88 X-Migadu-Queue-Id: 47A315C045 X-Spam-Score: -9.88 X-Migadu-Scanner: mx11.migadu.com X-TUID: YUq6VKdm3v7X --=-=-= Content-Type: text/plain Max Nikulin writes: > On 24/01/2024 19:11, Ihor Radchenko wrote: >> The \section[...]{...} approach may work, but it is tricky - it is >> completely up to the `org-latex-classes'. So, we may have to use regexp >> replacement, which might be fragile. > > ox supports the ALT_TITLE property and ox-latex already adds it using > regexp. So it should possible to define this property with stripped > footnote by an export filter. I have not tested it, but ALT_TITLE and > @@latex:\protect@@ might be a workaround. Good point. See the attached tentative patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-latex-headline-Prevent-footnotes-in-TOC-footers.patch >From b4d896f7daf5e7b2cf8dabfba5b9dbf212f0c54c Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date: Fri, 26 Jan 2024 13:07:13 +0100 Subject: [PATCH] org-latex-headline: Prevent footnotes in TOC/footers * lisp/ox-latex.el (org-latex-headline): When headline contains footnotes and does not have ALT_TITLE, arrange alternative title that will appear in TOC and footers to not have any footnotes. Reported-by: Eric Anderson Link: https://orgmode.org/list/691643eb-49d0-45c3-ab7f-a1edbd093bef@gmail.com --- lisp/ox-latex.el | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index df20345f8..4f5258ea1 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2312,9 +2312,22 @@ (defun org-latex-headline (headline contents info) ;; with \texttt. (code . (lambda (o _ _) (org-latex--protect-texttt (org-element-property :value o)))) (verbatim . (lambda (o _ _) (org-latex--protect-texttt (org-element-property :value o))))))) + ;; Create a temporary export backend that strips footnotes from title. + ;; Footnotes are not allowed in \section and similar + ;; commands that contribute to TOC and footers. + ;; See https://orgmode.org/list/691643eb-49d0-45c3-ab7f-a1edbd093bef@gmail.com + ;; https://texfaq.org/FAQ-ftnsect + (section-no-footnote-backend + (org-export-create-backend + :parent section-backend + :transcoders + `((footnote-reference . ignore)))) (text (org-export-data-with-backend (org-element-property :title headline) section-backend info)) + (text-no-footnote + (org-export-data-with-backend + (org-element-property :title headline) section-no-footnote-backend info)) (todo (and (plist-get info :with-todo-keywords) (let ((todo (org-element-property :todo-keyword headline))) @@ -2328,6 +2341,9 @@ (defun org-latex-headline (headline contents info) ;; The latter is required to remove tags from toc. (full-text (funcall (plist-get info :latex-format-headline-function) todo todo-type priority text tags info)) + (full-text-no-footnote + (funcall (plist-get info :latex-format-headline-function) + todo todo-type priority text-no-footnote tags info)) ;; Associate \label to the headline for internal links. (headline-label (org-latex--label headline info t t)) (pre-blanks @@ -2385,10 +2401,14 @@ (defun org-latex-headline (headline contents info) (string-match-p "\\" v) (format "\\stopcontents[level-%d]" level))))) info t))))) - (if (and opt-title - (not (equal opt-title full-text)) + (if (and (or (and opt-title (not (equal opt-title full-text))) + ;; Heading contains footnotes. Add optional title + ;; version without footnotes to avoid footnotes in + ;; TOC/footers. + (and (not (equal full-text-no-footnote full-text)) + (setq opt-title full-text-no-footnote))) (string-match "\\`\\\\\\(.+?\\){" section-fmt)) - (format (replace-match "\\1[%s]" nil nil section-fmt 1) + (format (replace-match "\\1[%s]" nil nil section-fmt 1) ;; Replace square brackets with parenthesis ;; since square brackets are not supported in ;; optional arguments. -- 2.43.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--