From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] ox-latex.el: add LaTeX attributes to quote block
Date: Mon, 24 May 2021 12:14:33 +0000 [thread overview]
Message-ID: <87h7is49cm.fsf@posteo.net> (raw)
[-- 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
next reply other threads:[~2021-05-24 12:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-24 12:14 Juan Manuel Macías [this message]
2021-05-25 9:21 ` [PATCH] ox-latex.el: add LaTeX attributes to quote block 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
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
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=87h7is49cm.fsf@posteo.net \
--to=maciaschain@posteo.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).