all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] ox-latex.el: add LaTeX attributes to quote block
@ 2021-05-24 12:14 Juan Manuel Macías
  2021-05-25  9:21 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Juan Manuel Macías @ 2021-05-24 12:14 UTC (permalink / raw)
  To: orgmode

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

Hi all,

The `quote' block is exported to LaTeX as a `quote' environment.
However, standard LaTeX classes have two environments for quotes:
`quote' and `quotation', with certain format differences: it is often
said that `quotation' is intended for longer quotes with several
paragraphs and applies a first line indent to each paragraph. In
addition there are several very popular packages that offer more
environments and features for quoting, for example `quoting' or
`csquotes', which includes a set of quote environments and very powerful
options. Even some languages as Spanish option for Babel have their own
quoting environment. Given all this variety, I think it would be nice to
offer the user at least a couple of LaTeX attributes to choose:
`:environment' (by default the environment would remain `quote') and
`:options'. I attach a possible patch for it (if the patch sounds good,
I can add the documentation for the new features).

An example with a quote in German:

#+LaTeX_Header:\usepackage[german,english]{babel}
#+LaTeX_Header:\usepackage{quoting}
#+LaTeX_Header:\usepackage[babel=true,autostyle=true,german=quotes]{csquotes}
#+LaTeX_Header:\SetBlockEnvironment{quoting}

#+ATTR_LaTeX: :environment foreigndisplayquote :options {german}
#+begin_quote

Eine Erklärung, wie sie einer Schrift in einer Vorrede nach der
Gewohnheit vorausgeschickt wird ---über den Zweck, den der Verfasser
sich in ihr vorgesetzt, sowie über die Veranlassungen und das
Verhältnis, worin er sie zu andern frühern oder gleichzeitigen
Behandlungen desselben Gegenstandes zu stehen glaubt--- scheint bei
einer philosophischen Schrift nicht nur überflüssig, sondern um der
Natur der Sache willen sogar unpassend und zweckwidrig zu sein (Hegel).

#+end_quote

Best regards,

Juan Manuel


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-latex.el-add-LaTeX-attributes-to-quote-block.patch --]
[-- Type: text/x-patch, Size: 2368 bytes --]

From 1164c3066f0ea7e639382b01c5da2d7b5b46efb8 Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias <maciaschain@posteo.net>
Date: Mon, 24 May 2021 13:19:01 +0200
Subject: [PATCH] ox-latex.el: add LaTeX attributes to quote block

* lisp/ox-latex.el: 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'
---
 lisp/ox-latex.el | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index b9ecf070a..3704267c9 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' environment."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
 (defcustom org-latex-default-table-mode 'table
   "Default mode for tables.
 
@@ -2895,9 +2903,17 @@ 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* ((env (org-export-read-attribute :attr_latex quote-block :environment))
+	     (opt (org-export-read-attribute :attr_latex quote-block :options))
+	     (current-env (if env env org-latex-default-quote-environment))
+	     (current-opt (if opt opt "")))
   (org-latex--wrap-label
-   quote-block (format "\\begin{quote}\n%s\\end{quote}" contents) info))
-
+   quote-block (format "\\begin{%s}%s\n%s\\end{%s}"
+			     current-env
+			     current-opt
+			     contents
+			     current-env)
+   info)))
 
 ;;;; Radio Target
 
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ox-latex.el: add LaTeX attributes to quote block
  2021-05-24 12:14 [PATCH] ox-latex.el: add LaTeX attributes to quote block Juan Manuel Macías
@ 2021-05-25  9:21 ` Nicolas Goaziou
  2021-05-25 12:42   ` Juan Manuel Macías
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2021-05-25  9:21 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

Hello,

Juan Manuel Macías <maciaschain@posteo.net> writes:

> Subject: [PATCH] ox-latex.el: add LaTeX attributes to quote block

Thank you. Some comments follow.

> +(defcustom org-latex-default-quote-environment "quote"
> +  "Default environment used to `quote' environment."

-->  Default environment used for "quote" blocks.

> +  :group 'org-export-latex
> +  :version "24.4"
> +  :package-version '(Org . "8.0")

You can remove the :version keyword. And :package-version is wrong.

> +  :type 'string)

You also need to add :safe t

>  (defcustom org-latex-default-table-mode 'table
>    "Default mode for tables.
>  
> @@ -2895,9 +2903,17 @@ 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* ((env (org-export-read-attribute :attr_latex quote-block :environment))
> +	     (opt (org-export-read-attribute :attr_latex quote-block :options))
> +	     (current-env (if env env org-latex-default-quote-environment))
> +	     (current-opt (if opt opt "")))

We don't use global variables directly as above, but use

  (plist-get info :latex-default-quote-environment)

instead. This could be written as


   (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)
              "")))
     ...)

Could you send an updated patch?

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ox-latex.el: add LaTeX attributes to quote block
  2021-05-25  9:21 ` Nicolas Goaziou
@ 2021-05-25 12:42   ` Juan Manuel Macías
  2021-05-25 15:52     ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Juan Manuel Macías @ 2021-05-25 12:42 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: orgmode

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

Hi Nicolas,

Thank you for your indications. Attached the updated patch.

Do you need me to prepare another patch to document the modifications
and add them to org-NEWS?

Best regards,

Juan Manuel 

Nicolas Goaziou writes:

> Hello,
>
> Juan Manuel Macías <maciaschain@posteo.net> writes:
>
>> Subject: [PATCH] ox-latex.el: add LaTeX attributes to quote block
>
> Thank you. Some comments follow.
>
>> +(defcustom org-latex-default-quote-environment "quote"
>> +  "Default environment used to `quote' environment."
>
> -->  Default environment used for "quote" blocks.
>
>> +  :group 'org-export-latex
>> +  :version "24.4"
>> +  :package-version '(Org . "8.0")
>
> You can remove the :version keyword. And :package-version is wrong.
>
>> +  :type 'string)
>
> You also need to add :safe t
>
>>  (defcustom org-latex-default-table-mode 'table
>>    "Default mode for tables.
>>  
>> @@ -2895,9 +2903,17 @@ 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* ((env (org-export-read-attribute :attr_latex quote-block :environment))
>> +	     (opt (org-export-read-attribute :attr_latex quote-block :options))
>> +	     (current-env (if env env org-latex-default-quote-environment))
>> +	     (current-opt (if opt opt "")))
>
> We don't use global variables directly as above, but use
>
>   (plist-get info :latex-default-quote-environment)
>
> instead. This could be written as
>
>
>    (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)
>               "")))
>      ...)
>
> Could you send an updated patch?
>
> Regards,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-latex.el-add-LaTeX-attributes-to-quote-block_updated.patch --]
[-- Type: text/x-patch, Size: 2348 bytes --]

From eea6956e1baa07c9a9753ed71be48a1e962442a9 Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias <maciaschain@posteo.net>
Date: Tue, 25 May 2021 14:02:06 +0200
Subject: [PATCH] ox-latex.el: add LaTeX attributes to quote block

* 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'
---
 lisp/ox-latex.el | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index b9ecf070a..c4f2c6f53 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,10 +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)
+	      "")))
   (org-latex--wrap-label
-   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
 
--
2.31.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ox-latex.el: add LaTeX attributes to quote block
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2021-05-25 15:52 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

Juan Manuel Macías <maciaschain@posteo.net> writes:

> Thank you for your indications. Attached the updated patch.

Thanks. 

I forgot to ask: could you add some documentation about it in the
manual, too?

> Do you need me to prepare another patch to document the modifications
> and add them to org-NEWS?

You can do it in the same patch.

Regards,


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ox-latex.el: add LaTeX attributes to quote block
  2021-05-25 15:52     ` Nicolas Goaziou
@ 2021-05-25 20:50       ` Juan Manuel Macías
  2021-05-26 21:05         ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Juan Manuel Macías @ 2021-05-25 20:50 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: orgmode

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

Hi Nicolas,

Nicolas Goaziou writes:

> You can do it in the same patch.

Here is the updated patch, with the corresponding additions in the
manual and ORG-NEWS.

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 987566d52cd36c990d3db3f83d2c6433254ac2e3 Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias <maciaschain@posteo.net>
Date: Tue, 25 May 2021 22:18:06 +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.
 ,#+END_VERSE
 #+end_src
 
+*** Quote blocks in LaTeX export
+:PROPERTIES:
+:DESCRIPTION: Attributes specific to quote blocks.
+:END:
+
+#+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:
+
+#+begin_example
+,#+ATTR_LATEX: :environment quotation
+,#+BEGIN_QUOTE
+some text...
+,#+END_QUOTE
+#+end_example
+
+To choose the =foreigndisplayquote= environment, included in the LaTeX
+package =csquotes=, with the =german= option, use this syntax:
+
+#+begin_example
+,#+LATEX_HEADER:\usepackage[autostyle=true]{csquotes}
+,#+ATTR_LATEX: :environment foreigndisplayquote :options {german}
+,#+BEGIN_QUOTE
+some text in German...
+,#+END_QUOTE
+#+end_example
+
+#+texinfo: @noindent
+which is exported to LaTeX as
+
+#+begin_example
+\begin{foreigndisplayquote}{german}
+some text in German...
+\end{foreigndisplayquote}
+#+end_example
+
 ** Markdown Export
 :PROPERTIES:
 :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
+=:options=.
+
 *** =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,10 +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)
+	      "")))
   (org-latex--wrap-label
-   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
 
--
2.31.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ox-latex.el: add LaTeX attributes to quote block
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2021-05-26 21:05 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

Hello,

Juan Manuel Macías <maciaschain@posteo.net> writes:

> Here is the updated patch, with the corresponding additions in the
> manual and ORG-NEWS.

Thanks.

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

There are also some nits, but I can fix them when applying your patch.
> +#+cindex: quote blocks, in @LaTeX{} export
> +#+cindex: @samp{ATTR_LATEX}, keyword

This is not related to your patch (it can be encountered elsewhere), but
the index entry above is too generic to be useful. Maybe 

  #+cindex: @samp{ATTR_LATEX}, in quote blocks

would be better.

> +#+cindex: org-latex-default-quote-environment

This should be #+vindex: ...

> +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-latex-default-quote-environment~ and ~"quote"~ since they both
refer to Lisp code, not Org syntax.

> +=:options=. For example, to choose the environment =quotation=,
> +included as an alternative to =quote= in standard LaTeX classes:
> +
> +#+begin_example
> +,#+ATTR_LATEX: :environment quotation
> +,#+BEGIN_QUOTE
> +some text...
> +,#+END_QUOTE
> +#+end_example

Note that you can currently write, perhaps more elegantly,

  #+begin_quotation
  some text...
  #+end_quotation

> +To choose the =foreigndisplayquote= environment, included in the LaTeX
> +package =csquotes=, with the =german= option, use this syntax:
> +
> +#+begin_example
> +,#+LATEX_HEADER:\usepackage[autostyle=true]{csquotes}
> +,#+ATTR_LATEX: :environment foreigndisplayquote :options {german}
> +,#+BEGIN_QUOTE
> +some text in German...
> +,#+END_QUOTE
> +#+end_example

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?

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ox-latex.el: add LaTeX attributes to quote block
  2021-05-26 21:05         ` Nicolas Goaziou
@ 2021-05-26 23:02           ` Juan Manuel Macías
  2021-05-29 20:22             ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Juan Manuel Macías @ 2021-05-26 23:02 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: orgmode

[-- 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.
 ,#+END_VERSE
 #+end_src
 
+*** Quote blocks in LaTeX export
+:PROPERTIES:
+:DESCRIPTION: Attributes specific to quote blocks.
+:END:
+
+#+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:
+
+#+begin_example
+,#+ATTR_LATEX: :environment quotation
+,#+BEGIN_QUOTE
+some text...
+,#+END_QUOTE
+#+end_example
+
+To choose the =foreigndisplayquote= environment, included in the LaTeX
+package =csquotes=, with the =german= option, use this syntax:
+
+#+begin_example
+,#+LATEX_HEADER:\usepackage[autostyle=true]{csquotes}
+,#+ATTR_LATEX: :environment foreigndisplayquote :options {german}
+,#+BEGIN_QUOTE
+some text in German...
+,#+END_QUOTE
+#+end_example
+
+#+texinfo: @noindent
+which is exported to LaTeX as
+
+#+begin_example
+\begin{foreigndisplayquote}{german}
+some text in German...
+\end{foreigndisplayquote}
+#+end_example
+
 ** Markdown Export
 :PROPERTIES:
 :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
+=:options=.
+
 *** =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)
+	      "")))
   (org-latex--wrap-label
-   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
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ox-latex.el: add LaTeX attributes to quote block
  2021-05-26 23:02           ` Juan Manuel Macías
@ 2021-05-29 20:22             ` Nicolas Goaziou
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2021-05-29 20:22 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

Hello,

Juan Manuel Macías <maciaschain@posteo.net> writes:

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

Applied. Thank you.

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-29 20:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-24 12:14 [PATCH] ox-latex.el: add LaTeX attributes to quote block 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
2021-05-29 20:22             ` Nicolas Goaziou

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.