emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Jacob Gerlach <jacobgerlach@gmail.com>
Cc: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: Treat custom environment as verbatim on export
Date: Sat, 23 May 2015 09:32:28 -0700	[thread overview]
Message-ID: <alpine.OSX.2.00.1505230859140.632@charles-berrys-macbook.local> (raw)
In-Reply-To: <CAA6UvuHzdeu=8OFtr0gLYs=1_Ze1Z4Syv6CfkC+8xqJ+QjK+Cw@mail.gmail.com>

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

      parent reply	other threads:[~2015-05-23 16:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-23  3:09 Treat custom environment as verbatim on export Jacob Gerlach
2015-05-23  9:48 ` Rasmus
2015-05-24 15:29   ` Nicolas Goaziou
2015-05-24 17:29     ` Rasmus
2015-05-24 19:43     ` Charles C. Berry
2015-05-25 12:17       ` Jacob Gerlach
2015-05-23 16:32 ` Charles C. Berry [this message]

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=alpine.OSX.2.00.1505230859140.632@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=jacobgerlach@gmail.com \
    /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).