Org-mode mailing list
 help / color / mirror / Atom feed
From: "Juan Manuel Macías" <>
To: orgmode <>
Cc: TEC <>
Subject: Re: [PATCH] A proposal to add LaTeX attributes to verse blocks
Date: Thu, 07 Jan 2021 19:52:41 +0100
Message-ID: <> (raw)
In-Reply-To: <> (TEC's message of "Sun, 03 Jan 2021 21:08:30 +0800")

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]


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 (, 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.


Juan Manuel

[-- Attachment #2: verse-block-patch.diff --]
[-- Type: text/x-patch, Size: 5182 bytes --]

diff --git a/doc/ b/doc/
index b015b502c..fe21b5aca 100644
--- a/doc/
+++ b/doc/
@@ -13870,6 +13870,54 @@ The LaTeX export back-end converts horizontal rules by the specified
+*** Verse blocks in LaTeX export
+:DESCRIPTION: Attributes specific to special blocks.
+#+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,
+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.
 ** Markdown Export
 :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
+- =: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}" "")))
@@ -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
 	     "^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m)))
 	      "^[ \t]*\\\\\\\\$" "\\vspace*{1em}"
 	       "\\([ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n"
-	       contents nil t) nil t) nil t))
+	       contents nil t) nil t) nil t) linreset)
    ;; 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-user functions

[-- Attachment #3: Type: text/plain, Size: 1827 bytes --]

TEC <> writes:

> 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/
> 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.

  reply	other threads:[~2021-01-07 18:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 17:23 Juan Manuel Macías
2021-01-03 10:25 ` TEC
2021-01-03 13:07   ` Juan Manuel Macías
2021-01-03 13:08     ` TEC
2021-01-07 18:52       ` Juan Manuel Macías [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-12-17 17:11 [patch] " Juan Manuel Macías
2021-01-03 10:22 ` TEC

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ \
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:

AGPL code for this site: git clone