4

I want to include the output of inline code blocks in the LaTeX/PDF output of an org-mode document, but not in a monospaced font. I tried the following:

The mean petal length is src_R[:exports results :results raw]{mean(iris$Petal.Length)}. 

which gives me this output in the LaTeX file:

The mean petal length is 3.758
. 

The period in the sentence appears on a new line in the LaTeX file, which causes a space to appear between the code output and the period in the PDF.

enter image description here

Is there a way I can get the LaTeX output to appear all on one line so the PDF formatting is correct?

  • 1
    If this is a one-of thing, you could edit ob-R.el (and re-compile it, if you previously compiled it) by editing the function org-babel-R-evaluate-external-process, specifically, the place where it says (buffer-string), replace it with (org-trim (buffer-string)). But I'm not sure how this will affect multiline results. – wvxvw Mar 13 '16 at 21:46
6

One way to do this is to change the variable org-babel-inline-result-wrap from =%s=, which formats the output, to just %s, which does not.

You can do this with a non-exporting lisp code block somewhere in your file if you don't want to change it globally.

#+BEGIN_SRC lisp :exports none
  (setq org-babel-inline-result-wrap "%s")
#+END_SRC

This is a test of text: 4 and code: src_R{2+2}.
  • 1
    This worked! I changed lisp to emacs-lisp as the former wasn't working (probably I don't have slime set up correctly or something). – Kara Woo Mar 16 '16 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.