andreas-h
andreas-h

Reputation: 11090

Change format of inline code evaluation in org-mode's LaTeX-export

I have a code block in an org document

#+NAME: result_whatever
#+BEGIN_SRC python :session data :results value :exports none 
return(8.1 - 5)
#+END_SRC

which I evaluate inline:

Now, does this work? Let's see: call_result_whatever(). I'd be surprised ...

When exporting to LaTeX, this generates the following:

Now, does this work? Let's see:  \texttt{3.1}. I'd be surprised \ldots{}

However, I don't want the results to be displayed in monospace. I want it to be formatted in "normal" upright font, without any special markup.

How can I achieve this?

Upvotes: 0

Views: 1035

Answers (3)

Greg Minshall
Greg Minshall

Reputation: 627

this is 5 years later. apparently in org-mode 8.2 or so, a new variable was introduced (documenting in "Evaluating Code Blocks" in the org-mode manual, but this from etc/ORG-NEWS in the source tree):

*** New option: org-babel-inline-result-wrap

If you set this to the following

: (setq org-babel-inline-result-wrap "$%s$")

then inline code snippets will be wrapped into the formatting string.

so, to eliminate \texttt{}

(setq org-babel-inline-result-wrap "%s")

Upvotes: 1

Jonathan Leech-Pepin
Jonathan Leech-Pepin

Reputation: 7874

You should be able to get it work using the optional header arguments which can be added to call_function().

I don't have LaTeX installed on this system so can't fully test the outputs to ensure they come out exactly as desired, I'm using the plain text output to compare instead. However you can use the following syntax as part of your call to modify the results.

Now, does this work? Let's see call_results_whatever()[:results raw].
I'd be surprised ...

Without the [:results raw] the output to Plain Text (Ascii buffer) is Let's see `3.0999999999999996'.. With the added results it becomes Let's see 3.0999999999999996.

For full details of the available results keywords as well as other optional header arguments for the inline blocks please see Evaluation Code Blocks and Results arguments.

Upvotes: 1

abo-abo
abo-abo

Reputation: 20342

The problem of this type can be solved in two ways:

1: Easy does it:

A plain query-replace on the exported buffer. Once you're in the LaTeX buffer,

  1. beginning-of-buffer or M-<
  2. query-replace or M-%
    • enter \texttt as the string that you want to replace
    • enter nothing as the replacement
    • continue to replace each match interactively with y/n or just replace everything with !

2: But I wanna!

The second way is to nag the org-mode mailing list into implementing a switch or an option for your specific case. While it's necessary sometimes, it also produces a system with thousands of switches, which can become unwieldy. You can try, but I don't recommend.

Upvotes: 0

Related Questions