0

I'm using PlantUML to generate a UML diagram inside an orgmode file. I've looked everywhere, and either I'm using the wrong terms (likely) or I'm missing something (also likely). When I view the raw tex file generated by C-c C-e l p, I get the following:

\includegraphics[width=.9\linewidth]{test.png}

What I need to know is how to change the width that is in the generated tex file. I could do it by manually changing the source image size, and then rerunning latex, but there must be a way that I'm missing to control it from within the orgmode file itself. Any ideas?

Edit: this is the relevant section of the org-mode file:

#+BEGIN_SRC plantuml :file test.png 
Bob->Alice : hello
#+END_SRC
1

You can give to an image an atrribute of :width to specify its width. For example:

#+ATTR_LATEX: :width 0.3\linewidth
[[file:test.png]]

would do the job.

But there is the additional complication here that the image file is generated by a source block. The easiest solution IME is as follows:

  • Give the source block a name.
  • Generate the results with C-c C-c -- the results block is now decorated with the name you gave to the block.
  • Add the #+ATTR_LATEX: line before the #+RESULTS: line.

The effect is that the attribute applies to the image, despite the intervening #+RESULTS: line. When you regenerate the image file, the link ends up in the right place, after the named #+RESULTS: line.

The final result looks like this:

  #+name: bob-and-alice
  #+BEGIN_SRC plantuml :file test.png 
  Bob->Alice : hello
  #+END_SRC

  #+ATTR_LATEX: :width 0.3\linewidth
  #+RESULTS: bob-and-alice
  [[file:test.png]]
| improve this answer | |
  • Excellent! Works, and it helps me understand what I was doing wrong! Thanks! – JEPrice Jul 30 at 19:13

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.