Hi, I added the :options to :attr_latex when exporting example blocks for more control over them
Best, /PA -- Fragen sind nicht da, um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler "Sagen's Paradeiser" (ORF: Als Radiohören gefährlich war) => write BE! Year 2 of the New Koprocracy
From b6808b0f02877ea58c944cb5d0166386ebe92b0d Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" <[email protected]> Date: Wed, 11 Feb 2026 08:41:48 +0100 Subject: [PATCH] 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 818bf0b59..5945b66f9 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -14808,6 +14808,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 1a7ba4661..6ee5ca46b 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -513,6 +513,11 @@ font (i.e. the Roman font). This option prepends LaTeX code before the LaTeX preamble. +*** ~#+BEGIN_EXAMPLE~ now checks for ~:options~ in ~#+ATTR_LATEX:~ + +You can now pass options to the environment you choose for the +~#+BEGIN_EXAMPLE~ environments. + ** New functions and changes in function arguments # This also includes changes in function behavior from Elisp perspective. diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 82828730b..15121ecda 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2225,11 +2225,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)))) -- 2.43.0
