# Org-mode export: Resize Plantuml diagram when exporting to PDF and image gets repeated

I have a simple PlantUML diagram in an org file and I want to export the entire document to pdf. The problem is that the diagram is embedded correctly, but the picture takes up an entire page. SECOND, the image gets input twice--so need to remove the extra copy. So I am trying to figure out how to resize the picture.

The code I am using looks like this.

#+NAME: classdiagram
#+BEGIN_SRC plantuml :width 5cm :height 5cm :file try.png
@startuml
Class01 <|-- Class02
@enduml
#+END_SRC


But when I create the latex and generate the PDF, the PNG file takes up the entire page. I tried to generate a JPG as well, but still no luck.

I tried a few different ways to get this to work like:

#+NAME: classdiagram
#+ATTR_LATEX:  :width 0.6
#+BEGIN_SRC plantuml :file try.png
@startuml
Class01 <|-- Class02
@enduml
#+END_SRC


However, the sticking point seems to be that the Latex that is generated looks like this:

\includegraphics[width=.45\linewidth]{try.png}
\begin{center}
\includegraphics[width=.9\linewidth]{try.png}
\end{center}


NOTE: This image gets imported twice, which also needs to be corrected.

Anyone know the right way to fix this and resize the image?

• If you use package.el please test with emacs -Q -f package-initialize whether you also get the duplicated images. If you don't use package.el please test with emacs -Q. – Tobias Jan 30 '18 at 15:21

## 1 Answer

Can't help with the double rendering, sorry. With your code sample I can't replicate it. It is probably something in your configuration.

Adding a #+RESULTS clause the image will be rendered there, instead of directly replacing the #+BEGIN_SRC block, and it will accept the #+ATTR_LATEX with sizing options:

#+BEGIN_SRC plantuml :file try.png
@startuml
Class01 <|-- Class02
@enduml
#+END_SRC

#+ATTR_LATEX: :width 5cm
#+RESULTS:
[[file:try.png]]