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 iMHtJ4Sc8V9lKwAA0tVLHw (envelope-from ) for ; Sun, 03 Jan 2021 10:29:24 +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 IDKAI4Sc8V8eEAAA1q6Kng (envelope-from ) for ; Sun, 03 Jan 2021 10:29:24 +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 B5B699401C0 for ; Sun, 3 Jan 2021 10:29:23 +0000 (UTC) Received: from localhost ([::1]:43648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kw0dW-0007cy-NR for larch@yhetil.org; Sun, 03 Jan 2021 05:29:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kw0dA-0007cs-Jq for emacs-orgmode@gnu.org; Sun, 03 Jan 2021 05:29:00 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:41330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kw0d8-0002Ek-Qx for emacs-orgmode@gnu.org; Sun, 03 Jan 2021 05:29:00 -0500 Received: by mail-pl1-x62d.google.com with SMTP id y8so12874313plp.8 for ; Sun, 03 Jan 2021 02:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=YToPX6qN5EDFa3FgdrIjFYoRD4EvDnfnDTrvq36uSkQ=; b=vNmOj78YonGfDZsr5vjKyeMzpLhoPx9ZebxJ3hoF7o+c2lj2oWsSN8vZx54QXbziTQ O/JteLzpa81W1JRvjgwKKsJUcGfBfA2+GDa+yCXJRc9GmhshugS5Z98BEE+qI1R4nCpf m0fw30nnEA8I+sgKksmRIkakNfZUi4pRfq+rlMyJQNv07CPmBh7BVnOMb4ubA414NNCM kRU2mikhwKN2Kc5KFTCRjtsXxHETSJU7hMA/sL3WhjZllpsb4IXE4isUmtuy1rG0z3H4 mVK/GtKn3nTkht9h286pBB0rfasqMq0Jeajo07e2Sf1S8obyWXbgWAamMyLAea5zJsaM J5DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding; bh=YToPX6qN5EDFa3FgdrIjFYoRD4EvDnfnDTrvq36uSkQ=; b=Y3j/uwLiyqMv43chWzFYDQIOw4jEPcmLMcnFgW/y57u441CQCCqeatYQwdV2+rOATP +WZ4qHFPJ00qnbnA2vphtxrzkBe+5QlOsSSh/ifh3Sxquu5VZXPtSje8YkPQayBJrq53 ASnvbr6ppsSCeJ9sQ2i+kRHJ+vDCzuPOgCnFgZz93I/lpWk4RbVjSeDYnIbf0Um1TXEy 5lj2g2ciEU8cmiiUkTbx8SiVEBxZHhG0FdkrskFFeL0PS5SRIVH9SsAMe1mZU2NTmvQS jkO6h2F3E4i/vp6vqZ1xrkMv1uydIfT7CVpTfMPSdk+aOJ2DSfyZAf1VtnfQjPajqeRP MWDw== X-Gm-Message-State: AOAM530dI4uXG69LW21yULSnRSu9wE+Jomau4wW8fWCSw5WaCGuMLKyq en2AkquiWceSJ1PIk7TohP7mXUR4ZO0= X-Google-Smtp-Source: ABdhPJw6RBeL3rfqjTf4sr2y7lIKoiAPDMkU0IwLYcV3/ICyittlqvYAWoKCKMXzPdnjR8Q+xWHMjA== X-Received: by 2002:a17:902:8bcc:b029:dc:45d9:f8b2 with SMTP id r12-20020a1709028bccb02900dc45d9f8b2mr50698416plo.62.1609669737367; Sun, 03 Jan 2021 02:28:57 -0800 (PST) Received: from localhost (180-150-91-8.b4965b.per.nbn.aussiebb.net. [180.150.91.8]) by smtp.gmail.com with ESMTPSA id 3sm59937419pgk.81.2021.01.03.02.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jan 2021 02:28:56 -0800 (PST) References: <87pn38s5wo.fsf@posteo.net> User-agent: mu4e 1.4.13; emacs 27.1 From: TEC To: Juan Manuel =?utf-8?Q?Mac=C3=ADas?= Subject: Re: [PATCH] A proposal to add LaTeX attributes to verse blocks Date: Sun, 03 Jan 2021 18:25:08 +0800 In-reply-to: <87pn38s5wo.fsf@posteo.net> Message-ID: <87ft3itiu2.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=tecosaur@gmail.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.03 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=vNmOj78Y; dmarc=pass (policy=none) header.from=gmail.com; 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: B5B699401C0 X-Spam-Score: -3.03 X-Migadu-Scanner: scn1.migadu.com X-TUID: Jn0SSh+CPaXm Hi Juan, Thanks for your patch.=20 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=C3=ADas writes: > (Sorry, due to a mistake, the text of my message did not appear in my pre= vious email) > > Hi, > > I would like to propose this patch to add some LaTeX attributes to the ve= rse block, > especially to be able to apply certain features from the verse.sty packag= e, which is an > extension (widely used in Humanities) of the standard LaTeX 'verse' envir= onment. > > 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 typogr= aphic 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 environmen= t. > > 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 w= ith 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 = self-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 :v= ersewidth)) > + (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