emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel issue with source blocks and latex block
@ 2011-02-15 17:56 Kieran Healy
  2011-02-15 18:49 ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Kieran Healy @ 2011-02-15 17:56 UTC (permalink / raw)
  To: emacs-org list

Hi, 

I have org-babel set up to use minted to format code blocks and it's terrific. I was wondering whether I could also get it to wrap the results it outputs using minted instead of verbatim environments (it seems not right now) when I noticed the following strange behavior. Here's a minimal example. This org file exports to latex as expected, with the src block in a minted environment and the results block as a verbatim environment: (As I say, wanting the results block wrapped by minted was what prompted this issue ...)

Org-mode file:
--------------------------------------------------------------------------------------------------
#+TITLE: Working with Org-Babel
#+AUTHOR: Kieran Healy
#+OPTIONS: toc:nil num:nil

** An Example

#+source: r-example-1
#+begin_src R :exports both
  2 + 1 + (5-2) * 5
#+end_src

The end.
--------------------------------------------------------------------------------------------------

Relevant bit of Latex file output:
--------------------------------------------------------------------------------------------------
\begin{document}

\title{Working with Org-Babel}
\author{Kieran Healy}
\date{15 February 2011}
\maketitle

\section*{An Example}
\label{sec-1}

\begin{minted}[]{R}
2 + 1 + (5-2) * 5
\end{minted}

\begin{verbatim}
 18
\end{verbatim}

The end.

\end{document}
--------------------------------------------------------------------------------------------------

But now if I insert a latex-specific section, which causes org-mode no trouble in the normal course of things, R is not called and the export only includes the source block and not the results:

Org-mode file:
--------------------------------------------------------------------------------------------------
#+TITLE: Working with Org-Babel
#+AUTHOR: Kieran Healy
#+OPTIONS: toc:nil num:nil

#+BEGIN_LaTeX
Anything can go here. 
#+END_LaTeX

** An Example

#+source: r-example-1
#+begin_src R :exports both
  2 + 1 + (5-2) * 5
#+end_src

The end.
--------------------------------------------------------------------------------------------------

Latex output:
--------------------------------------------------------------------------------------------------
\begin{document}

\title{Working with Org-Babel}
\author{Kieran Healy}
\date{15 February 2011}
\maketitle

Anything can go here. 

\section*{An Example}
\label{sec-1}

\begin{minted}[]{R}
2 + 1 + (5-2) * 5
\end{minted}

The end.

\end{document}
--------------------------------------------------------------------------------------------------

Is this behavior expected? 

Kieran

--
Kieran Healy :: http://www.kieranhealy.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: org-babel issue with source blocks and latex block
  2011-02-15 17:56 org-babel issue with source blocks and latex block Kieran Healy
@ 2011-02-15 18:49 ` Eric Schulte
  2011-02-15 21:15   ` Kieran Healy
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2011-02-15 18:49 UTC (permalink / raw)
  To: Kieran Healy; +Cc: emacs-org list

Kieran Healy <kjhealy@gmail.com> writes:

> Hi, 
>
> I have org-babel set up to use minted to format code blocks and it's
> terrific. I was wondering whether I could also get it to wrap the
> results it outputs using minted instead of verbatim environments (it
> seems not right now) when I noticed the following strange
> behavior. Here's a minimal example. This org file exports to latex as
> expected, with the src block in a minted environment and the results
> block as a verbatim environment: (As I say, wanting the results block
> wrapped by minted was what prompted this issue ...)
>

Hi Kieran,

This may be possible through the use of the ":results src" header
argument e.g., the following minimal code block

#+begin_src R :results code
  8
#+end_src

evaluates to the following

#+results:
#+BEGIN_SRC R
8
#+END_SRC

which should be exported using minted.

Hope this helps -- Eric

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: org-babel issue with source blocks and latex block
  2011-02-15 18:49 ` Eric Schulte
@ 2011-02-15 21:15   ` Kieran Healy
  0 siblings, 0 replies; 3+ messages in thread
From: Kieran Healy @ 2011-02-15 21:15 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-org list

Hi Eric, 

On Feb 15, 2011, at 1:49 PM, Eric Schulte wrote:

> This may be possible through the use of the ":results src" header
> argument e.g., the following minimal code block
> 
> #+begin_src R :results code
>  8
> #+end_src
> 
> evaluates to the following
> 
> #+results:
> #+BEGIN_SRC R
> 8
> #+END_SRC

That does work — thank you. But while experimenting with this I found that while doing

#+begin_src R :results value code :exports both
   x <- c(1:10)
  mean(x)
#+end_src

works as expected, with both code and result wrapped in a minted environment, replacing mean(x) with summary(x)

#+begin_src R :results value code :exports both
  x <- c(1:10)
  summary(x)
#+end_src

gives this garbled output:

> \begin{minted}[]{R}
> x <- c(1:10)
> summary(x)
> \end{minted}
> 
> \end{SRC}
> \begin{SRC}R

This also fails in HTML export, where the corresponding reversed/garbled bit is 

> <p>
> </div>
> <div class="SRC R">
> </p>


Finally, it's still the case that if the code block is preceded by a #+BEGIN_LaTeX block, e.g., 

> #+BEGIN_LaTeX
> \thispagestyle{kjhgit} % but anything will do it
> #+END_LaTeX

Then R is not called at all and I just get the src block in the exported .tex or .html file, and no results. 

Kieran


--
Kieran Healy :: http://www.kieranhealy.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-15 21:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-15 17:56 org-babel issue with source blocks and latex block Kieran Healy
2011-02-15 18:49 ` Eric Schulte
2011-02-15 21:15   ` Kieran Healy

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).