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 yLL7H5xY919QFgAA0tVLHw (envelope-from ) for ; Thu, 07 Jan 2021 18:53:16 +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 AGzDG5xY918hDgAAbx9fmQ (envelope-from ) for ; Thu, 07 Jan 2021 18:53:16 +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 CA5149403EB for ; Thu, 7 Jan 2021 18:53:15 +0000 (UTC) Received: from localhost ([::1]:60946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxaPK-0004Xo-60 for larch@yhetil.org; Thu, 07 Jan 2021 13:53:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxaOw-0004Xa-RH for emacs-orgmode@gnu.org; Thu, 07 Jan 2021 13:52:51 -0500 Received: from mout01.posteo.de ([185.67.36.65]:50947) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxaOs-0006B5-DL for emacs-orgmode@gnu.org; Thu, 07 Jan 2021 13:52:50 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 87859160061 for ; Thu, 7 Jan 2021 19:52:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1610045563; bh=UYEaLIYzjfbFWNbGYVdunQOgMNgfAaB6grkUt5p9cVw=; h=From:To:Cc:Subject:Date:From; b=Zd6ENXQtUj03282NhmwXa3PdCnhsWEcMozGWNHlXE+a4QvYrQ+K7O1E9uYhyjEuQZ cJngJJjCFoy4nFaA47y2XhFdiOSPGdyYJjBxCmKi3XkYUR4FD7EZUhSDw58vnUHdke P5LYH0VoDA/8q9B4Z8kdU20SQtQ50PGScEjv2K8JPDIEIsxM16fYpX0L+Brl7YqUDj KBgdRYj6qv+dKjEcLPNHQJJi0bFVAwnQR8UmPYkAxiTBy0ki9fd/B3jnTIzMdV0N1m dLsC26q9VSbeO9oU5LrL2wF8ThD0VCXYiYF6UAJ3qHHdEH2AxgnJPG45qRYJ0rnm62 uQpMmjAw/gRFg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DBb2f2X9sz6tmK; Thu, 7 Jan 2021 19:52:42 +0100 (CET) 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> Date: Thu, 07 Jan 2021 19:52:41 +0100 In-Reply-To: <87eej2ta4e.fsf@gmail.com> (TEC's message of "Sun, 03 Jan 2021 21:08:30 +0800") Message-ID: <87ble0pojq.fsf@posteo.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; 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: , Cc: TEC Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.95 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Zd6ENXQt; 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: CA5149403EB X-Spam-Score: -2.95 X-Migadu-Scanner: scn0.migadu.com X-TUID: WmbfOjzAK66G --=-=-= Content-Type: text/plain Hi, I am attaching a new version of my patch for adding LaTeX attributes to verse blocks. Following the kind suggestions from Timothy, I have also documented this new features that I propose. I don't know if I have done it correctly and in the right place... A short reminder: `lines', `versewidth', and `center' require loading the LaTeX package verse.sty (https://www.ctan.org/pkg/verse), which is an extension of the standard LaTeX `verse' environment, and that adds many features for typesetting poetry. `lines' deals with the marginal verse numbering; `versewidth' and `center' are related to the optical centering of the poem. The fourth attribute is to include arbitrary LaTeX code within the verse environment, so I have provisionally named it `latexcode'. Of course, Feedback is welcome. Regards, Juan Manuel --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=verse-block-patch.diff Content-Transfer-Encoding: quoted-printable diff --git a/doc/org-manual.org b/doc/org-manual.org index b015b502c..fe21b5aca 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -13870,6 +13870,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/etc/ORG-NEWS b/etc/ORG-NEWS index 5e5f1954d..47e0ec40e 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -149,6 +149,19 @@ Example: A new =3Du=3D mode flag for Calc formulas in Org tables has been added to enable Calc units simplification mode. =20 +*** LaTeX attributes for verse blocks + +The LaTeX export back-end now accepts four attributes for verse +blocks: + +- =3D:lines=3D, for marginal verse numbering; +- =3D:center=3D and =3D:versewidth=3D, for optical centering of the verses; +- =3D:latexcode=3D, for any arbitrary LaTeX code that can be included + within a LaTeX =3Dverse=3D environment. + +The three first require the external LaTeX package =3Dverse.sty=3D, wich +is an extension of the standard LaTeX environment. + ** Miscellaneous *** =3Dorg-goto-first-child=3D now works before first heading =20 diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index fb9fc3cd6..0931b7e9c 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -3506,6 +3506,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 @@ -3513,19 +3524,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 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable TEC writes: > Juan Manuel Mac=C3=ADas writes: > >> Thank you very much for your response and your comments. > > Seriously, thanks for the patch. I think the ML is usually a bit more > responsive, but it seems to be a bit quiet at the moment. > >> I agree to name "Insert, include, etc." the attribute to include >> arbitrary LaTeX code, better than "options". > > Glad my feedback seems to have gone down well :). If the only likely use > of this is adjusting the font, perhaps for the sake of consistency we > can match the behaviour of tables, which take a :font LaTeX attribute? > >> Of course, I can add the necessary documentation to the files you tell >> me. As I am new to submitting patches, I don't really know how to >> proceed: do I have to send you the new version of the patch, with the >> documentation? Should I send a new email with all of it to this list? > > Thanks for asking. Sometimes it seems the maintainers take the trouble of > adding an ORG-NEWS entry or minor touching ups to the patch, but I think > it's nice to leave as little for them to do as possible :) > > Announce changes in: etc/ORG-NEWS > Document new/different behaviour in: doc/org-manual.org > > I think Markup for /Rich Contents > Paragraphs/ may be the right place > to add a description of this functionality --- verse blocks are > discussed around line 10750. > > Regarding how patches on this ML work, this is what I've observed: > - Initial version of patch submitted, with justification/explanation > - Feedback may be given > - Revisions of the patch are attached in replies to feedback > - Process repeats until everyone's happy > - Patch is merged > > i.e. it all tends to happen in the same thread. > > Hope this helps, > > Timothy. > --=-=-=--