From c2e39f5f3046d7a8e90878351b35c89656dacdfc Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias 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