emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Treat custom environment as verbatim on export


From: Charles C. Berry
Subject: Re: [O] Treat custom environment as verbatim on export
Date: Sat, 23 May 2015 09:32:28 -0700
User-agent: Alpine 2.00 (OSX 1167 2008-08-23)

On Fri, 22 May 2015, Jacob Gerlach wrote:

Hello,

I want to use a one of several custom environments for some babel
results using, for example, ":wrap myverbatim" as a header argument.
(Since I have several possible environments, I think I need to use
:wrap rather than, say, replacing "verbatim" using an export filter).

However, since this block isn't recognized as an actual verbatim
environment, markup gets processed in undesirable ways.

For example:

-------------
#+BEGIN_SRC sh :exports results :wrap myverbatim
echo "Hello_world"
#+END_SRC

#+RESULTS:
#+BEGIN_myverbatim
Hello_world
#+END_myverbatim
-------------
exports to
-------------
\begin{myverbatim}
Hello\(_{\text{world}}\)
\end{myverbatim}
-------------
instead of
-------------
\begin{myverbatim}
Hello_world
\end{myverbatim}
-------------

A couple questions:

- Is there any way I've missed to specify verbatim export as an option
for an arbitrary block/environment?



You can use arbritrary latex environments inside a latex block with these header arguments:

:  :results raw :wrap latex :post postenv("env-name-goes-here")

If you define a wrapper for the results like this:

#+NAME: postenv
#+BEGIN_SRC emacs-lisp :var env="myverb"  :exports none
(format "\\begin{%s}\n%s\\end{%s}" env *this* env)
#+END_SRC

Then calling

#+header: :results raw :wrap latex :post postenv("myverbatim")
#+BEGIN_SRC sh :exports results
echo "Hello_world"
#+END_SRC

gives:

,----
| \begin{myverbatim}
| Hello_world
| \end{myverbatim}
`----

under latex export.

The `:results raw' is needed particularly for multiline results.

See the manual for each of those header args for more info.

You can also do this using :prologue and :epilogue, but I think :post is a bit neater.


HTH,

Chuck



reply via email to

[Prev in Thread] Current Thread [Next in Thread]