Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Hi Juan, Juan Manuel Macías writes: > Here I am attaching a new version of the patch that includes a commit > message. Correct me if I'm wrong but the patch did not contain a commit message, so I added it. Applied in master, together with an entry in etc/ORG-NEWS. Thanks, -- Bastien
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
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/ >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 rules by the specified - #+end_example +*** 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: +=:lines=, =:center=, =:versewidth= and =:latexcode=. The three first +require the external LaTeX package =verse.sty=, wich is an extension +of the standard LaTeX environment. The purpose of these attributes is +explained below. + +- =:lines= :: To add marginal verse numbering. Its value is an + integer, the sequence in which the verses should be numbered. +- =:center= :: With value =t= all the verses on the page are optically + centered (a typographic convention for poetry), taking as a + reference the longest verse, which must be indicated by the + attribute =:versewidth=. +- =:versewidth= :: Its value is a literal text string with the longest + verse. +- =:latexcode= :: It accepts any arbitrary LaTeX code that can be + included within a LaTeX =verse= 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’st thy light’st flame with self-substantial fuel, +,#+begin_verse +From fairest creatures we desire increase, +That thereby beauty’s 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’st thy light’st 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’s 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’s 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 :latexcode)) + (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 :versewidth)) + (vwidth (if versewidth (format "\\settowidth{\\versewidth}{%s}\n" versewidth) "")) + (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
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Timothy writes: > Eric S Fraga writes: > >> Is the verse package loaded automatically already? I did not see any >> change in the patch to that aspect and when I export a simple test, the >> package is not loaded. > > Wouldn't it be nice if there was something in-between loading the > kitchen sink and manually adding packages*... [ foreshadowing ;) ] Will be interesting to see what you are 'foreshadowing'. Personally, I find the current options pretty flexible with 'org-latex-classes and support for the macro like placeholders [PACKAGES, DEFAULT_PACKAGES, EXTRA and their negators] and the ability to add packages with LATEX_HEADER and LATEX_HEADER_EXTRA file options. I'm often quite surprised how little people seem to take advantage of 'org-latex-classes and the LATEX_CLASS; file option to define custom document formats. You can easily define an 'empty' class which only includes packages you add with LATEX_HEADER: or LATEX_HEADER_EXTRA for example. It is with 'tweaking' Latex packages I've seen people get into trouble. There can often be some unexpected results when you fail to load or load packages in a different order. Testing is notoriously difficult as you also need a lot of different test input data to get good coverage and adequately test the impact changes to loaded Latex packages causes. Without detailed knowledge of the latex based exporters, it isn't always obvious how/where specific Latex packages are used. It would be important to ensure any mechanism designed to make it easier to customize what packages are loaded that we don't also end up generating more bug rports about broken export formatting. -- Tim Cross
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Eric S Fraga writes: > Is the verse package loaded automatically already? I did not see any > change in the patch to that aspect and when I export a simple test, the > package is not loaded. Wouldn't it be nice if there was something in-between loading the kitchen sink and manually adding packages*... [ foreshadowing ;) ] -- Timothy * My prototype is now rather stable and I like the interface, I'm just wondering if I should generalise it for arbitrary backends or keep it as LaTeX-only, but don't let me take this thread on a tangent over this. I just thought it was worth mentioning.
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Hi Eric and all, Thank you for your comments. Eric S Fraga writes: > What is being proposed looks reasonable to me. I don't use =verse= very > often but have used it now and again and I can particular see the need > for numbering and centring, in particular. Indeed, optical centering is the correct typographic representation for poetry and poetry quotes. There would only be a couple exceptions: a) Certain types of avant-garde poetry (whose representation on paper is usually freer) and b) those poems whose verses spill over the margins and span several lines (in such case, the attribute :versewidth would have to take the value \textwidth, and then the verse package takes care of adjusting the overflowing part of the verses). Here I have uploaded two very illustrative examples of optical centering, two pages from a Tolkien book (/The Monsters and the Critics and Other Essays/) and another page from a book that I recently typesetted (here also includes verse numbering): https://imgur.com/a/cGi4CpD > Is the verse package loaded automatically already? I did not see any > change in the patch to that aspect and when I export a simple test, the > package is not loaded. For now, you need to load the verse package or add it to org-latex-packages-alist... Best regards, Juan Manuel
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
(resent: some receiving server complained about multiple recipients blah blah so I am testing with just the org mode mailing list as the recipient; apologies for noise if you receive this twice) On Saturday, 1 May 2021 at 12:58, Bastien wrote: > I'm copying Eric, a poweruser of the LaTeX backend, so that he can > perhaps comment on the general usefulness of this addition. "poweruser" :-) In any case, I think something is needed because =verse= stands out as being impossible to customize. Even special blocks will process a :options LaTeX attribute, allowing quite a bit of customization. What is being proposed looks reasonable to me. I don't use =verse= very often but have used it now and again and I can particular see the need for numbering and centring, in particular. Is the verse package loaded automatically already? I did not see any change in the patch to that aspect and when I export a simple test, the package is not loaded. -- : Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-405-g0a689b
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Hi Bastien, Thank you very much again for your kind suggestions. Bastien writes: > I'm copying Eric, a poweruser of the LaTeX backend, so that he can > perhaps comment on the general usefulness of this addition. I think these additions (line numbers, optical centering of the poem, etc.) can be useful (IMHO) for the correct representation of poetry (generally in Humanities), since the verse.sty package is a sort of 'unofficial' replacement for the standard LaTeX verse environment, which has certain limitations. > The patch lacks a commit message - see this explanations: > https://orgmode.org/worg/org-contribute.html#commit-messages Sorry again for not including a commit message. If the patch it is finally accepted, I can submit a new version that includes a commit message (and a few minor fixes I made to the code). Best regards, Juan Manuel
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Hi Juan, Sorry it's still taking a while for your patch to be looked at. Assuming it does get merged, it would be good to check if you'd be willing to write a manual entry to accompany this (in a separate patch works). Thanks again for the patch, Timothy. Juan Manuel Macías writes:
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Hi Juan, Juan Manuel Macías writes: > 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... thanks a lot -- we need to wait for the FSF copyright assignment process to be finished in order to accept this patch. I'm copying Eric, a poweruser of the LaTeX backend, so that he can perhaps comment on the general usefulness of this addition. The patch lacks a commit message - see this explanations: https://orgmode.org/worg/org-contribute.html#commit-messages Let us know if you need more directions and how to produce a patch that we can more easily apply. Thanks! -- Bastien
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
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 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 rules by the specified - #+end_example +*** 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: +=:lines=, =:center=, =:versewidth= and =:latexcode=. The three first +require the external LaTeX package =verse.sty=, wich is an extension +of the standard LaTeX environment. The purpose of these attributes is +explained below. + +- =:lines= :: To add marginal verse numbering. Its value is an + integer, the sequence in which the verses should be numbered. +- =:center= :: With value =t= all the verses on the page are optically + centered (a typographic convention for poetry), taking as a + reference the longest verse, which must be indicated by the + attribute =:versewidth=. +- =:versewidth= :: Its value is a literal text string with the longest + verse. +- =:latexcode= :: It accepts any arbitrary LaTeX code that can be + included within a LaTeX =verse= 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’st thy light’st flame with self-substantial fuel, +,#+begin_verse +From fairest creatures we desire increase, +That thereby beauty’s 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’st thy light’st 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’s 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’s 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 =u= mode flag for Calc formulas in Org tables has been added to enable Calc units simplification mode. +*** LaTeX attributes for verse blocks + +The LaTeX export back-end now accepts four attributes for verse +blocks: + +- =:lines=, for marginal verse numbering; +- =:center= and =:versewidth=, for optical centering of the verses; +- =:latexcode=, for any arbitrary LaTeX code that can be included + within a LaTeX =verse= environment. + +The three first require the external LaTeX package =verse.sty=, wich +is an extension of the standard LaTeX environment. + ** Miscellaneous *** =org-goto-first-child= now works before first heading 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 :latexcode)) + (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 :versewidth)) + (vwidth (if versewidth (format "\\settowidth{\\versewidth}{%s}\n" versewidth) "")) + (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
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Juan Manuel Macías 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.
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Hi Timothy, TEC writes: > Hi Juan, > > Thanks for your patch. > > This looks like a fairly sensible addition. Two comments from me: > > 1. I'm not sure that "options" is a good name for arbitrary LaTeX which >is included inside the verse block. Perhaps something like "insert" >or "include", etc. may be a better fit. > 2. It's considered generally nice to document features like this :) The >two documents which I'd think to note this in are ORG-NEWS and the >manual (docs/manual.org). Thank you very much for your response and your comments. I agree to name "Insert, include, etc." the attribute to include arbitrary LaTeX code, better than "options". 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? Best regards, Juan Manuel > All the best, > > Timothy. >
Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Hi Juan, Thanks for your patch. This looks like a fairly sensible addition. Two comments from me: 1. I'm not sure that "options" is a good name for arbitrary LaTeX which is included inside the verse block. Perhaps something like "insert" or "include", etc. may be a better fit. 2. It's considered generally nice to document features like this :) The two documents which I'd think to note this in are ORG-NEWS and the manual (docs/manual.org). All the best, Timothy. Juan Manuel Macías writes: > (Sorry, due to a mistake, the text of my message did not appear in my > previous email) > > Hi, > > I would like to propose this patch to add some LaTeX attributes to the verse > 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' > environment. > > 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 > typographic convention > whereby a poem or a group of verses is centered on the page, taking the > width of the > longest verse as a reference. In fact, optical centering is the correct > arrangement of > verses in a document. > - `:versewidth' which expects a text string that is the longest verse of the > poem, > required when applying the `:center' attribute. > > As I said, these three attributes require the LateX package verse.sty. A > fourth `: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’st thy light’st flame with self-substantial > fuel, > ,#+begin_verse > From fairest creatures we desire increase, > That thereby beauty’s 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’st thy light’st 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’s 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’s due, by the grave and thee. > ,#+end_verse > #+end_src > > when exporting to LaTeX we get: > > #+begin_src latex > \settowidth{\versewidth}{Feed’st thy light’st flame with self-substantial > fuel,} > \begin{verse}[\versewidth] > \poemlines{5} > \small > From fairest creatures we desire increase,\\ > That thereby beauty’s 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’st thy light’st 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’s 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’s 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 > :versewidth)) > + (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 >
Re: [patch] A proposal to add LaTeX attributes to verse blocks
Hi Juan, Since you've resent this in a second email, let's discuss this patch there. As such, I'm marking this patch as closed. -- Timothy.
[PATCH] A proposal to add LaTeX attributes to verse blocks
(Sorry, due to a mistake, the text of my message did not appear in my previous email) Hi, I would like to propose this patch to add some LaTeX attributes to the verse 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' environment. 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 typographic convention whereby a poem or a group of verses is centered on the page, taking the width of the longest verse as a reference. In fact, optical centering is the correct arrangement of verses in a document. - `:versewidth' which expects a text string that is the longest verse of the poem, required when applying the `:center' attribute. As I said, these three attributes require the LateX package verse.sty. A fourth `: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’st thy light’st flame with self-substantial fuel, ,#+begin_verse From fairest creatures we desire increase, That thereby beauty’s 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’st thy light’st 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’s 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’s due, by the grave and thee. ,#+end_verse #+end_src when exporting to LaTeX we get: #+begin_src latex \settowidth{\versewidth}{Feed’st thy light’st flame with self-substantial fuel,} \begin{verse}[\versewidth] \poemlines{5} \small >From fairest creatures we desire increase,\\ That thereby beauty’s 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’st thy light’st 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’s 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’s 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 :versewidth)) + (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