From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id HxYGN5Eyxl+AZgAA0tVLHw (envelope-from ) for ; Tue, 01 Dec 2020 12:09:53 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id MEY+MpEyxl/AMgAAbx9fmQ (envelope-from ) for ; Tue, 01 Dec 2020 12:09:53 +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 67B29940466 for ; Tue, 1 Dec 2020 12:09:53 +0000 (UTC) Received: from localhost ([::1]:49250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kk4Tf-0002l9-MN for larch@yhetil.org; Tue, 01 Dec 2020 07:09:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kk4Sg-0002jp-Oq for emacs-orgmode@gnu.org; Tue, 01 Dec 2020 07:08:51 -0500 Received: from mout01.posteo.de ([185.67.36.65]:47322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kk4Sb-0003Nt-NM for emacs-orgmode@gnu.org; Tue, 01 Dec 2020 07:08:50 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id EB19316005C for ; Tue, 1 Dec 2020 13:08:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1606824522; bh=ikb9+mz3vwMsFvHzqpAYbmybmhGmXU9707G99c4pC3g=; h=From:To:Subject:Date:From; b=ALtLuCzuWnnBQM3RQWUxFTysvyzkb/puB5lHtSV99eM8yRKFeSyysGQkYKr/ciwzt j9qkL8E4X7MSSD7Wm/nVVuUUFMf195UjV2P/Rug8FcBfuL8PZayKHkYzeSvVd+U+aF QYBaMs28X3kNHePKBwaLm3NnZoGETmNWC3v9ZbRhJSeXvACG3fO/vPdwehNg0hgJ3R FUyYGxWFjHGNYymQnFESPbYt20vszk8pa/cUdoapfmqvOYpYmi3Tld/MAgXlePODJN LmMbq2V9ROoHWladUUTeH/GHjfShomOmvHZxIwTXvv3O/R19ZLefc0tyCxEwFEj0Tw J2PIF34M6/Klw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4ClgqY0Pj4z6tm8 for ; Tue, 1 Dec 2020 13:08:40 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: Footnote definition within a verse block has spurious line breaks when exported to LaTeX Date: Tue, 01 Dec 2020 13:08:38 +0100 Message-ID: <87sg8prant.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_H4=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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.92 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=ALtLuCzu; dmarc=pass (policy=none) header.from=posteo.net; 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: 67B29940466 X-Spam-Score: -0.92 X-Migadu-Scanner: ns3122888.ip-94-23-21.eu X-TUID: j+tSsQXv9FxH --=-=-= Content-Type: text/plain; format=flowed Hi, When a verse block includes a footnote reference, the corresponding footnote definition is understood in the LaTeX export as if it were part of the verses. In other words, every line in a =\footnote{}= macro ends with the string =\\=, and the spaces between paragraphs are understood as spaces between stanzas (\vspace*{1em}). If the text of the footnote definition contains one or more filled paragraphs, then the export result is catastrophic. For example, if we have something like this: #+begin_src org ,#+begin_verse lorem ipsum[fn:1] dolor ,#+end_verse [fn:1] Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus. #+end_src in LaTeX we get this: #+begin_src latex \begin{verse} lorem\\ ipsum\footnote{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor\\ tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et, mattis eget,\\ convallis nec, purus.\\ \vspace*{1em} Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor tellus.\\ Donec pretium posuere tellus. Proin quam nisl, tincidunt et, mattis eget, convallis nec,\\ purus.}\\ dolor\\ \end{verse} #+end_src Since footnotes are allowed within a LaTeX =verse= environment, I think this behavior should be fixed. I'm wondering if it would make sense to modify the =org-latex-verse-block= function, in order to "save" the text formatting of the footnote definition, something like this (apologies in advance for my rudimentary Elisp: what I'm proposing is more of a concept, or a pedestrian solution, than a actual patch ;-): #+begin_src emacs-lisp (defun preserve-footnote-definition-in-verse-block (cont) (with-temp-buffer (insert cont) (save-excursion (goto-char (point-max)) (while (re-search-backward "}" nil t) (let ((from (point)) (to (save-excursion (re-search-backward "\\\\footnote{" nil t) (point)))) (save-restriction (narrow-to-region from to) (goto-char (point-min)) (while (re-search-forward "\n\n+" nil t) (replace-match "\\\\par\s" t nil)) (goto-char (point-min)) (while (re-search-forward "\n" nil t) (replace-match "\s" t nil)))))) (buffer-string))) (defun org-latex-verse-block (verse-block contents info) "Transcode a VERSE-BLOCK element from Org to LaTeX. CONTENTS is verse block contents. INFO is a plist holding contextual information." (org-latex--wrap-label verse-block ;; In a verse environment, add a line break to each newline ;; character and change each white space at beginning of a line ;; into a space of 1 em. Also change each blank line with ;; a vertical space of 1 em. (format "\\begin{verse}\n%s\\end{verse}" (replace-regexp-in-string "^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m))) (replace-regexp-in-string "^[ \t]*\\\\\\\\$" "\\vspace*{1em}" (replace-regexp-in-string "\\([ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n" (preserve-footnote-definition-in-verse-block contents) nil t) nil t) nil t)) info)) #+end_src Best, Juan Manuel --=-=-=--