emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] ox-latex.el: add LaTeX attributes to quote block
Date: Wed, 26 May 2021 23:02:17 +0000	[thread overview]
Message-ID: <87wnrlumiu.fsf@posteo.net> (raw)
In-Reply-To: <87r1htdx3x.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 26 May 2021 23:05:38 +0200")

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

Nicolas Goaziou writes:

> I cannot apply it on top of master however. On what commit did you base
> it?

I'm sorry, it's my fault. It's already fixed. I think the patch attached
here should apply well...

> [...]
> I don't know if this example is a good illustration because you can
> currently achieve the same with:
>   #+attr_latex: :options {german}
>   #+begin_foreigndisplayquote
>   some text in German...
>   #+end_foreigndisplayquote
> Are there use cases that would be better than using special blocks as in
> the example above?

I think I have not explained well about the rationale for this patch,
sorry. The advantage (IMHO) of being able to choose between several
LaTeX environments to the export of the quote blocks has more to do with
the consistency between various output formats (and a single origin). Of
course, quotation, quoting, foreigndisplayquote and a few more can be
obtained using special blocks. But for LaTeX they are just different
styles and ways to create a quote environment. At the end of the day
they are all 'quote'. It's ok that Org has only one single quote block
that is exported indistinctly to LaTeX, html, odt, etc. (Org tends to be
format agnostic and focuses more on the logical structure of the text).
But in the case of LaTeX it would be nice if the user could choose
between several ways or formats to do quotes (in LaTeX), without
resorting to special blocks. On the other hand, the standard LaTeX
`quote' environment is already far exceeded by other more powerful
options, like the csquotes package.

Best regards,

Juan Manuel 

[-- Attachment #2: 0001-ox-latex.el-add-LaTeX-attributes-to-quote-block.patch --]
[-- Type: text/x-patch, Size: 4973 bytes --]

From c2e39f5f3046d7a8e90878351b35c89656dacdfc Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias <maciaschain@posteo.net>
Date: Wed, 26 May 2021 23:58:05 +0200
Subject: [PATCH] ox-latex.el: add LaTeX attributes to quote block

* doc/org-manual.org (Quote blocks in LaTeX export): manual updated
* etc/ORG-NEWS (Support quote blocks in LaTeX export): news updated
* lisp/ox-latex.el (latex): add `org-latex-default-quote-environment' to `:options-alist'
(org-latex-default-quote-environment): the default quote environment
is `quote'
(org-latex-quote-block): add two attributes: `environment' and `options'
 doc/org-manual.org | 42 ++++++++++++++++++++++++++++++++++++++++++
 etc/ORG-NEWS       |  7 +++++++
 lisp/ox-latex.el   | 22 ++++++++++++++++++++--
 3 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 118d97e0e..dd51df27e 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -13919,6 +13919,48 @@ To eat the world’s due, by the grave and thee.
+*** Quote blocks in LaTeX export
+:DESCRIPTION: Attributes specific to quote blocks.
+#+cindex: quote blocks, in @LaTeX{} export
+#+cindex: @samp{ATTR_LATEX}, keyword
+#+cindex: org-latex-default-quote-environment
+The LaTeX export back-end accepts two attributes for quote blocks:
+=:environment=, for an arbitrary quoting environment (the default
+value is that of =org-latex-default-quote-environment=: ="quote"=) and
+=:options=. For example, to choose the environment =quotation=,
+included as an alternative to =quote= in standard LaTeX classes:
+,#+ATTR_LATEX: :environment quotation
+some text...
+To choose the =foreigndisplayquote= environment, included in the LaTeX
+package =csquotes=, with the =german= option, use this syntax:
+,#+ATTR_LATEX: :environment foreigndisplayquote :options {german}
+some text in German...
+#+texinfo: @noindent
+which is exported to LaTeX as
+some text in German...
 ** Markdown Export
 :DESCRIPTION: Exporting to Markdown.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 8707222e0..c8a93c933 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -244,6 +244,13 @@ require the external LaTeX package =verse.sty=, wich is an extension
 of the standard LaTeX environment. The purpose of these attributes is
 explained below.
+*** Support quote blocks in LaTeX export
+The LaTeX export back-end accepts two attributes for quote blocks:
+=:environment=, for an arbitrary quoting environment (the default
+value is that of =org-latex-default-quote-environment=: ="quote"=) and
 *** =org-set-tags-command= selects tags from ~org-global-tags-completion-table~
 Let ~org-set-tags-command~ TAB fast tag completion interface complete
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index b9ecf070a..9e2e7be47 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -121,6 +121,7 @@
     (:latex-classes nil nil org-latex-classes)
     (:latex-default-figure-position nil nil org-latex-default-figure-position)
     (:latex-default-table-environment nil nil org-latex-default-table-environment)
+    (:latex-default-quote-environment nil nil org-latex-default-quote-environment)
     (:latex-default-table-mode nil nil org-latex-default-table-mode)
     (:latex-diary-timestamp-format nil nil org-latex-diary-timestamp-format)
     (:latex-footnote-defined-format nil nil org-latex-footnote-defined-format)
@@ -772,6 +773,13 @@ default we use here encompasses both."
   :package-version '(Org . "8.0")
   :type 'string)
+(defcustom org-latex-default-quote-environment "quote"
+  "Default environment used to `quote' blocks."
+  :group 'org-export-latex
+  :package-version '(Org . "9.5")
+  :type 'string
+  :safe t)
 (defcustom org-latex-default-table-mode 'table
   "Default mode for tables.
@@ -2895,9 +2903,19 @@ channel."
   "Transcode a QUOTE-BLOCK element from Org to LaTeX.
 CONTENTS holds the contents of the block.  INFO is a plist
 holding contextual information."
+  (let ((environment
+	  (or (org-export-read-attribute :attr_latex quote-block :environment)
+	      (plist-get info :latex-default-quote-environment)))
+	 (options
+	  (or (org-export-read-attribute :attr_latex quote-block :options)
+	      "")))
-   quote-block (format "\\begin{quote}\n%s\\end{quote}" contents) info))
+   quote-block (format "\\begin{%s}%s\n%s\\end{%s}"
+			     environment
+			     options
+			     contents
+			     environment)
+   info)))
 ;;;; Radio Target

  reply	other threads:[~2021-05-26 23:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 12:14 Juan Manuel Macías
2021-05-25  9:21 ` Nicolas Goaziou
2021-05-25 12:42   ` Juan Manuel Macías
2021-05-25 15:52     ` Nicolas Goaziou
2021-05-25 20:50       ` Juan Manuel Macías
2021-05-26 21:05         ` Nicolas Goaziou
2021-05-26 23:02           ` Juan Manuel Macías [this message]
2021-05-29 20:22             ` Nicolas Goaziou

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: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87wnrlumiu.fsf@posteo.net \
    --to=maciaschain@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --subject='Re: [PATCH] ox-latex.el: add LaTeX attributes to quote block' \


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

Code repositories for project(s) associated with this inbox:


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).