From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gNGQGKU+lmAqLgAAgWs5BA (envelope-from ) for ; Sat, 08 May 2021 09:32:53 +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 MNQKFKU+lmAiUgAAbx9fmQ (envelope-from ) for ; Sat, 08 May 2021 07:32: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 B9D6525125 for ; Sat, 8 May 2021 09:32:52 +0200 (CEST) Received: from localhost ([::1]:33516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfHSF-0001UH-SJ for larch@yhetil.org; Sat, 08 May 2021 03:32:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfHRS-0001RM-V6 for emacs-orgmode@gnu.org; Sat, 08 May 2021 03:32:02 -0400 Received: from mout02.posteo.de ([185.67.36.66]:58399) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfHRQ-0003F7-A1 for emacs-orgmode@gnu.org; Sat, 08 May 2021 03:32:02 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 66BB52400FD for ; Sat, 8 May 2021 09:31:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1620459116; bh=fBIsAS41QlDQ7KHYlgEFVYt3WpUpXr0SUlGpAUDtCUw=; h=From:To:Cc:Subject:Date:From; b=g4yMgaq1XryhJCgRW4z6Uzikf3yqqiSK3QUZGJtbWIuWtn30UA2DQXa68Vq1JxX4Q VGc/peLhCNbsKjFzo3X9413wF/sYc7K0OEPUjNLER29NPMsPkp7bbE2sr984FLxxNO N7u6Lk1aPlualL7DcNNZBN+9b+tWYA3MvbZYm4sF6UtQW6wHor5mcdZ9+UJy/LWkJd PTn7efUZkYqJ/K/1YorUzagu3dahA/1xKJEoVvpV11WP5IodK2Fu1leOzBic7hLowU vFJTXTHYNJBLeLMpCURWPnOFvYnmz9+YN0m2xQNQXQ0N4PMK8m4s40u4e9iuSG4WNU jpdDriieeLMFw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FcfCH2zXzz9rxN; Sat, 8 May 2021 09:31:55 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: Re: [PATCH] A proposal to add LaTeX attributes to verse blocks References: <87pn38s5wo.fsf@posteo.net> <87ft3itiu2.fsf@gmail.com> <87sg7ijhi5.fsf@posteo.net> <87eej2ta4e.fsf@gmail.com> <87ble0pojq.fsf@posteo.net> <878s4y7mbh.fsf@gnu.org> Date: Sat, 08 May 2021 07:31:54 +0000 In-Reply-To: <878s4y7mbh.fsf@gnu.org> (Bastien's message of "Sat, 01 May 2021 12:58:10 +0200") Message-ID: <874kfdn0k5.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; 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_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: , Cc: Bastien , TEC , Eric Fraga 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=1620459173; 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=2JyMclRRuhz4DE2M+Z1ga5Q63Mtv+63Qd/MAnp3npH4=; b=Wb8s+iGYgsNtXM0c3Ex7dCU+VxzOxiKO22m5lLIDNb10/jBhs9K6LoLMpZEna8Fp9bc/G3 QD+6Ru/zgiCkXWzI5S+jEaFY2WlKv6tiKscDyYsLn885Z8EeeX67UiuC5KIvx4QJkMMlSh RUzQgfh8gdpwe9LPf5kbcwrMrA+MQOMEW2s3xVAFQCucDzRcty9skzf56fTCR0GMbuyQk0 STWjmUE7bvdv/lE5Ka2PyjuTydbyo0zf86tBC7pyuZsvPeA0zQeNUeUrWrDNC8BcNFH7Th N9aP12bCbZl2NEEtDDK4450Kg+DRwIF6/ecBOdaIz+64RwJmlfk9zE2l1DckDg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620459173; a=rsa-sha256; cv=none; b=YKdjmkdz39rthqSTm21dNN8fie6hdjay+prQlOrsFnhHCnqTeu213mj502VvD2RvvM+2tW 2x/q7qoG7Tvx1QBhRbQHzCIh+2jXyFdZN6IOERywykWMs5k/gTylaS5kNzL7w+2FVdxEoM e3CGesz/AS7NFJCafucL1VmMqE2I4aE5DbamLEnZ95Iv6/rrZkTB6hrNR0e89mB1DXXd/M 79e6hGJqnJsbiIRdRbYM4K3ORJgZ6le5x/AbMLtYobBEQqaBf353UmCYrksw/zEV4p1C3c Oy8EvxqlAbUvFa2Sqkx464jhZVerqhMpfqYPTAPC2jgjGPnhBt5PVivgvTPVeA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=g4yMgaq1; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=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: -1.25 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=g4yMgaq1; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=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: B9D6525125 X-Spam-Score: -1.25 X-Migadu-Scanner: scn0.migadu.com X-TUID: LELdU49ZbfsQ --=-=-= Content-Type: text/plain Hi all, Here I am attaching a new version of the patch that includes a commit message. I put here an example for those who want to try it, a fragment of a poem by W.H. Auden. Best regards, Juan Manuel #+begin_src org ,#+LaTeX_Header: \usepackage{verse} ,#+ATTR_LATEX: :center t ,#+ATTR_LATEX: :versewidth Teach the free man how to praise. ,#+ATTR_LATEX: :lines 5 :latexcode \small ,#+begin_verse Earth, receive an honoured guest: William Yeats is laid to rest. Let the Irish vessel lie Emptied of its poetry. In the nightmare of the dark All the dogs of Europe bark, And the living nations wait, Each sequestered in its hate; Intellectual disgrace Stares from every human face, And the seas of pity lie Locked and frozen in each eye. Follow, poet, follow right To the bottom of the night, With your unconstraining voice Still persuade us to rejoice; With the farming of a verse Make a vineyard of the curse, Sing of human unsuccess In a rapture of distress; In the deserts of the heart Let the healing fountain start, In the prison of his days Teach the free man how to praise. ,#+end_verse #+end_src https://juanmanuelmacias.com/ --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Add-LaTeX-attributes-for-verse-blocks.patch Content-Transfer-Encoding: quoted-printable >From 337014731e89f7f28873b8f5d9a917901e810c95 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Sat, 8 May 2021 09:03:10 +0200 Subject: [PATCH] Add LaTeX attributes for verse blocks --- doc/org-manual.org | 48 ++++++++++++++++++++++++++++++++++++++++++++++ lisp/ox-latex.el | 20 +++++++++++++++---- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index ab12fa70a..c752ce46d 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -13861,6 +13861,54 @@ The LaTeX export back-end converts horizontal rule= s by the specified ----- #+end_example =20 +*** Verse blocks in LaTeX export +:PROPERTIES: +:DESCRIPTION: Attributes specific to special blocks. +:END: + +#+cindex: verse blocks, in @LaTeX{} export +#+cindex: @samp{ATTR_LATEX}, keyword + +The LaTeX export back-end accepts four attributes for verse blocks: +=3D:lines=3D, =3D:center=3D, =3D:versewidth=3D and =3D:latexcode=3D. The t= hree first +require the external LaTeX package =3Dverse.sty=3D, wich is an extension +of the standard LaTeX environment. The purpose of these attributes is +explained below. + +- =3D:lines=3D :: To add marginal verse numbering. Its value is an + integer, the sequence in which the verses should be numbered. +- =3D:center=3D :: With value =3Dt=3D all the verses on the page are optic= ally + centered (a typographic convention for poetry), taking as a + reference the longest verse, which must be indicated by the + attribute =3D:versewidth=3D. +- =3D:versewidth=3D :: Its value is a literal text string with the longest + verse. +- =3D:latexcode=3D :: It accepts any arbitrary LaTeX code that can be + included within a LaTeX =3Dverse=3D environment. + +A complete example with Shakespeare's first sonnet: + +#+begin_src org +,#+ATTR_LaTeX: :center t :latexcode \color{red} :lines 5 +,#+ATTR_LaTeX: :versewidth Feed=E2=80=99st thy light=E2=80=99st flame with= 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 + ** Markdown Export :PROPERTIES: :DESCRIPTION: Exporting to Markdown. diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index c3fc83b1b..0376dffd1 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -3513,6 +3513,17 @@ 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)) + (latcode (org-export-read-attribute :attr_latex verse-block :latexc= ode)) + (cent (org-export-read-attribute :attr_latex verse-block :center)) + (attr (concat + (if cent "[\\versewidth]" "") + (if lin (format "\n\\poemlines{%s}" lin) "") + (if latcode (format "\n%s" latcode) ""))) + (versewidth (org-export-read-attribute :attr_latex verse-block :ver= sewidth)) + (vwidth (if versewidth (format "\\settowidth{\\versewidth}{%s}\n" v= ersewidth) "")) + (linreset (if lin "\n\\poemlines{0}" ""))) (concat (org-latex--wrap-label verse-block @@ -3520,19 +3531,20 @@ 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}%s" + vwidth + attr (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" - contents nil t) nil t) nil t)) + contents nil t) nil t) nil t) linreset) 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)))) =20 ;;; End-user functions --=20 2.26.0 --=-=-=--