branch: externals/org
commit 211da6cab90bcda5f2b1c5145936e3d3844bdf9f
Author: Pedro A. Aranda <[email protected]>
Commit: Ihor Radchenko <[email protected]>

    ox-latex: Pass :options to #+begin_example
    
    * liso/ox-latex.el: (org-latex-example-block): Get :options from
    :attr_latex and put it after \begin{myenv}.
    * etc/ORG-NEWS: Announce.
    * doc/org-manual.org: Add examples in the LaTeX export section.
---
 doc/org-manual.org | 18 ++++++++++++++++++
 etc/ORG-NEWS       |  5 +++++
 lisp/ox-latex.el   |  9 ++++++---
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 69fa8dd954..3a0d0761e2 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -14804,6 +14804,24 @@ to specify a custom environment.
 ,#+END_EXAMPLE
 #+end_example
 
+You can also pass options to the environment with the ~:options~
+parameter. For example:
+
+#+begin_example
+,#+ATTR_LATEX: :environment Verbatim :options [fontsize=\footnotesize]
+,#+BEGIN_EXAMPLE
+  This sentence is false.
+,#+END_EXAMPLE
+#+end_example
+
+exports to:
+
+#+begin_example
+\begin{Verbatim}[fontsize=\footnotesize]
+  This sentence is false.
+\end{Verbatim}
+#+end_example
+
 *** Special blocks in LaTeX export
 :PROPERTIES:
 :DESCRIPTION: Attributes specific to special blocks.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 472f7ef767..fe1a3fe36f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -59,6 +59,11 @@ cookie =[N%]=.
 
 ** Miscellaneous
 
+*** =ox-latex=: ~#+BEGIN_EXAMPLE~ now checks for ~:options~ in ~#+ATTR_LATEX:~
+
+You can now pass options to the environment you choose for the
+~#+BEGIN_EXAMPLE~ environments.
+
 *** The percent cookie is now non-zero when any sub-task is complete
 
 With a large number of tasks (N > 100) the percent cookie previously
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 3db1903d0b..c752e1e26a 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2226,11 +2226,14 @@ information."
   (when (org-string-nw-p (org-element-property :value example-block))
     (let ((environment (or (org-export-read-attribute
                            :attr_latex example-block :environment)
-                          "verbatim")))
+                          "verbatim"))
+          (options (or (org-export-read-attribute
+                        :attr_latex example-block :options)
+                       "")))
       (org-latex--wrap-label
        example-block
-       (format "\\begin{%s}\n%s\\end{%s}"
-              environment
+       (format "\\begin{%s}%s\n%s\\end{%s}"
+              environment options
               (org-export-format-code-default example-block info)
               environment)
        info))))

Reply via email to