From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id wzzDNFuX21/XPwAA0tVLHw (envelope-from ) for ; Thu, 17 Dec 2020 17:37:31 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qGQYMFuX218wPQAA1q6Kng (envelope-from ) for ; Thu, 17 Dec 2020 17:37:31 +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 28E73940105 for ; Thu, 17 Dec 2020 17:37:31 +0000 (UTC) Received: from localhost ([::1]:33934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpxDU-0002FD-Si for larch@yhetil.org; Thu, 17 Dec 2020 12:37:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpx0K-0000Uq-Oa for emacs-orgmode@gnu.org; Thu, 17 Dec 2020 12:23:52 -0500 Received: from mout02.posteo.de ([185.67.36.66]:35729) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpx0I-0007My-4d for emacs-orgmode@gnu.org; Thu, 17 Dec 2020 12:23:52 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 3B7082400FD for ; Thu, 17 Dec 2020 18:23:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1608225826; bh=F+KGA3jX6n3/uPwgTysHkNR8NbU6lK9H/kTC8Ts+1WA=; h=From:To:Subject:Date:From; b=APME2mJHWIf3NHo+s3tss847V4Czkn5fWAVROZC1/cn7GUeCyrnl3nq8sRoqCENn1 jpJcnzKHw/5xhH67TWuXZq+qZT2Dn5FdwyTIhSTdWkgDtOZnL147hDf485WGa55j9q 99u/zeVdnmn71Cr2gX36t/TA0Ixbr5ol0aZiKImjlZ/rK8u5xBJNvQWFCYrOrSV/LP 23yI9IGPAzo9UnIsOZfYZz2L9eh1dsqMxg5RT3k9gGW49jBgwegN7zfUftGVCoYy71 3bV/Tvb512NZpZcNby1WpbtES5LgK2YHiUCC1Y9NzUqdp0oB1StJVldvF6lgPZ0hU/ gAOwjVrKTh8CA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Cxf3X4My5z6tmP for ; Thu, 17 Dec 2020 18:23:36 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [PATCH] A proposal to add LaTeX attributes to verse blocks Date: Thu, 17 Dec 2020 18:23:35 +0100 Message-ID: <87pn38s5wo.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.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_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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.01 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=APME2mJH; 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: 28E73940105 X-Spam-Score: -3.01 X-Migadu-Scanner: scn0.migadu.com X-TUID: ILgtLA8sFIL5 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable (Sorry, due to a mistake, the text of my message did not appear in my previ= ous email) Hi, I would like to propose this patch to add some LaTeX attributes to the vers= e block, especially to be able to apply certain features from the verse.sty package,= which is an extension (widely used in Humanities) of the standard LaTeX 'verse' environ= ment. These attributes would be: - `:lines' to add verse numbers, according to any numbering sequence - `:center' to apply the optical centering of the poem, which is a typograp= hic convention whereby a poem or a group of verses is centered on the page, taking the w= idth of the longest verse as a reference. In fact, optical centering is the correct a= rrangement of verses in a document. - `:versewidth' which expects a text string that is the longest verse of th= e poem, required when applying the `:center' attribute. As I said, these three attributes require the LateX package verse.sty. A fo= urth `:options' attribute would be used to add arbitrary code within the verse environment. Consider this complete example with Shakespeare's first sonnet: #+begin_src org ,#+ATTR_LaTeX: :center t :options \small :lines 5 ,#+ATTR_LaTeX: :versewidth Feed=E2=80=99st thy light=E2=80=99st flame wit= h self-substantial fuel, ,#+begin_verse From fairest creatures we desire increase, That thereby beauty=E2=80=99s rose might never die, But as the riper should by time decrease, His tender heir mught bear his memeory: But thou, contracted to thine own bright eyes, Feed=E2=80=99st thy light=E2=80=99st flame with self-substantial fuel, Making a famine where abundance lies, Thyself thy foe, to thy sweet self too cruel. Thou that art now the world=E2=80=99s fresh ornament And only herald to the gaudy spring, Within thine own bud buriest thy content And, tender churl, makest waste in niggarding. Pity the world, or else this glutton be, To eat the world=E2=80=99s due, by the grave and thee. ,#+end_verse #+end_src when exporting to LaTeX we get: #+begin_src latex \settowidth{\versewidth}{Feed=E2=80=99st thy light=E2=80=99st flame with se= lf-substantial fuel,} \begin{verse}[\versewidth] \poemlines{5} \small >From fairest creatures we desire increase,\\ That thereby beauty=E2=80=99s rose might never die,\\ But as the riper should by time decrease,\\ His tender heir mught bear his memeory:\\ But thou, contracted to thine own bright eyes,\\ Feed=E2=80=99st thy light=E2=80=99st flame with self-substantial fuel,\\ Making a famine where abundance lies,\\ Thyself thy foe, to thy sweet self too cruel.\\ Thou that art now the world=E2=80=99s fresh ornament\\ And only herald to the gaudy spring,\\ Within thine own bud buriest thy content\\ And, tender churl, makest waste in niggarding.\\ Pity the world, or else this glutton be,\\ To eat the world=E2=80=99s due, by the grave and thee.\\ \end{verse} #+end_src In an attached image I send a screenshot with the typographic result And finally, this is the patch I would propose #+begin_src diff diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 2a14b25d5..bc6b64e78 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -3506,6 +3506,16 @@ channel." "Transcode a VERSE-BLOCK element from Org to LaTeX. CONTENTS is verse block contents. INFO is a plist holding contextual information." +(let* + ((lin (org-export-read-attribute :attr_latex verse-block :lines)) + (opt (org-export-read-attribute :attr_latex verse-block :options)) + (cent (org-export-read-attribute :attr_latex verse-block :center)) + (attr (concat + (if cent "[\\versewidth]" "") + (if lin (format "\n\\poemlines{%s}" lin) "") + (if opt (format "\n%s" opt) ""))) + (versewidth (org-export-read-attribute :attr_latex verse-block :ver= sewidth)) + (vwidth-attr (if versewidth (format "\\settowidth{\\versewidth}{%s}= \n" versewidth) ""))) (concat (org-latex--wrap-label verse-block @@ -3513,7 +3523,9 @@ contextual information." ;; 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}" + (format "%s\\begin{verse}%s\n%s\\end{verse}" + vwidth-attr + attr (replace-regexp-in-string "^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m))) (replace-regexp-in-string @@ -3524,7 +3536,7 @@ contextual information." info) ;; Insert footnote definitions, if any, after the environment, so ;; the special formatting above is not applied to them. - (org-latex--delayed-footnotes-definitions verse-block info))) + (org-latex--delayed-footnotes-definitions verse-block info)))) #+end_src Regards, Juan Manuel --=-=-= Content-Type: text/html --=-=-=--