3

When I run a snippet of code (C-c C-c) (e.g. for making a PlantUML diagram), there is a trailing new line in the results, e.g.:

#+BEGIN_SRC plantuml file hello.png
...
#+END_SRC

#+results
[[img]
   <<<<<<< new line here :-|

I then have to manually delete that line as it messes with some of my header formatting.

[edit] As per comment below, I tried:

#+NAME: diagram123
#+BEGIN_SRC plantuml :file ./img/img_2015_03_11__09_32_36.png
start 
:meh;
end
#+END_SRC


#+CALL: diagram123()

But this generates a result block with a new line at the end also :-|

13
  • See if you could work around it with call_<name>([arguments]) syntax (explained here: orgmode.org/manual/Evaluating-code-blocks.html ).
    – wvxvw
    Commented Mar 10, 2015 at 15:28
  • I can't figure out what to do based on the link above? >_<, please advise. Commented Mar 10, 2015 at 21:19
  • You can add #+NAME: diagram before the code block, and then, where you want to insert the image: call_diagram().
    – wvxvw
    Commented Mar 10, 2015 at 21:45
  • I tried, but couldn't quite get it working. I edited my question to show what I tried. Thoughts? Commented Mar 11, 2015 at 13:41
  • If you use #+CALL: name you don't need parenthesis after the name.
    – wvxvw
    Commented Mar 11, 2015 at 13:53

1 Answer 1

1

Using your code as example:

#+NAME: diagram123
#+BEGIN_SRC plantuml :file ./img/img_2015_03_11__09_32_36.png
start 
:meh;
end
#+END_SRC

Some text call_diagram123() some more text.

Exporting this to LaTeX gives this:

Some text \texttt{./img/img\_2015\_03\_11\_\_09\_32\_36.png} some more text.

#+NAME: diagram123
#+BEGIN_SRC plantuml :file ./img/img_2015_03_11__09_32_36.png
start 
:meh;
end
#+END_SRC

#+CALL: diagram123() :results file :exports results

#+RESULTS:
[[file:./img/img_2015_03_11__09_32_36.png]]

This is a way to export it to be a file link.

3
  • Thank you for your answer. I'm looking for something that will work in org-mode without exporting things..>? Commented Mar 11, 2015 at 22:27
  • Meh, this still inserts the trailing new line when results are evaluated. But in the mean time I figured out a way to deal with the trailing new line that messed with my headers in a different way. I appreciate your effort in posting the above. wvxvw << I've seen your name all over the place, you're a busy guy :-O Commented Mar 13, 2015 at 1:29
  • btw, maybe you know something in this post?: emacs.stackexchange.com/questions/9981/… Commented Mar 13, 2015 at 1:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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