From 8ff31bd0cf9179d7952d933d4638b658b3c9b3ba Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 23 Jun 2015 08:43:07 +0200 Subject: [PATCH] ox-latex: Introduce :environment attribute for example blocks * lisp/ox-latex.el (org-latex-example-block): Implement :environment attribute, which allows to override "verbatim" environment. * doc/org.texi (@LaTeX{} specific attributes): Document change. --- doc/org.texi | 20 +++++++++++++++++++- lisp/ox-latex.el | 15 ++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 5fc48d9c6..c92df74a6 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -12072,7 +12072,8 @@ All lines between these markers are exported literally @cindex #+ATTR_LATEX @LaTeX{} understands attributes specified in an @code{ATTR_LATEX} line. They -affect tables, images, plain lists, special blocks and source blocks. +affect tables, images, plain lists, source blocks, example blocks and special +blocks. @subsubheading Tables in @LaTeX{} export @cindex tables, in @LaTeX{} export @@ -12291,6 +12292,23 @@ counterpart to @code{org-latex-listings-options} and #+END_SRC @end example +@subsubheading Example blocks in @LaTeX{} export +@cindex example blocks, in @LaTeX{} export +@cindex verbatim blocks, in @LaTeX{} export + +By default, when exporting to @LaTeX{}, example blocks contents are wrapped +in a @samp{verbatim} environment. It is possible to use a different +environment globally using an appropriate export filter (@pxref{Advanced +configuration}). You can also change this per block using +@code{:environment} parameter. + +@example +#+ATTR_LATEX: :environment myverbatim +#+BEGIN_EXAMPLE +This sentence is false. +#+END_EXAMPLE +@end example + @subsubheading Special blocks in @LaTeX{} export @cindex special blocks, in @LaTeX{} export @cindex abstract, in @LaTeX{} export diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 63191bac3..5fb5d9ee4 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1488,11 +1488,16 @@ contextual information." CONTENTS is nil. INFO is a plist holding contextual information." (when (org-string-nw-p (org-element-property :value example-block)) - (org-latex--wrap-label - example-block - (format "\\begin{verbatim}\n%s\\end{verbatim}" - (org-export-format-code-default example-block info)) - info))) + (let ((environment (or (org-export-read-attribute + :attr_latex example-block :environment) + "verbatim"))) + (org-latex--wrap-label + example-block + (format "\\begin{%s}\n%s\\end{%s}" + environment + (org-export-format-code-default example-block info) + environment) + info)))) ;;;; Export Block -- 2.11.4.GIT