I am using Sphinx and the plantuml package to include UML diagrams.

The plantuml package for Sphinx generates the following LaTeX code:


Anyways - the diagrams are to big, so what I want is


Can I - without patching the plantum package - set a default scale for \includegraphics in my LaTeX preamble?


2 Answers 2


There are two ways.

First way: set a default value for some keys.

\setkeys{Gin}{width=.75\csname Gin@nat@width\endcsname,keepaspectratio}

(the natural width is stored in \Gin@nat@width)

Second way: add scale=0.75 to the passed options.

  • First way seems to set the size right, but now one graphic is placed at the end of one page and running over the page border. Second way seems to cause an endless loop: pdflatex is not returning ...
    – Alex
    Nov 17, 2012 at 13:32
  • @Alex Sorry, but without an example of TeX code that shows the bad behaviors it's difficult to help.
    – egreg
    Nov 17, 2012 at 13:36
  • 1
    @Alex You can set a limit on the first, using a \minof macro. \def\minof#1#2{\ifdim#1<#2#1\else#2\fi}. Then \setkeys{Gin}{width={\minof{.75\csname Gin@nat@width\endcsname}{\linewidth}},keepaspectratio} will not let big diagrams go wider than \linewidth. Jun 4, 2023 at 4:32

There is a way to define standard options for \includegraphics, but unfortunately, it doesn't seem to work for scale. It works for width though, which might be an option, too? See section 4.6 of grfguide: Global setting of keys.


    \setkeys{Gin}{width=.75\textwidth, height=1cm}
    % in your case, you'd obviously only specify the width
    % I just used height as well for demonstration purposes.

\usepackage{mwe}% just for the example images







Note that the images originally all have different aspect ratios.


  • Thank you but I think I need scale because I want to have the elements of the UML graphs all to have the same size. And as the UML drawings can be big and small, stretching them to a fixed would change the element's size.
    – Alex
    Nov 16, 2012 at 21:16
  • @Alex I was afraid the situation would be like that. I think I'll still leave the answer up, as it might be helpful for other people with a similar problem. I also pinged David Carlisle, author of grfguide, on chat; he might be able to help.
    – doncherry
    Nov 16, 2012 at 21:27
  • 1
    hmm scale coding looks a bit odd (who did that:-) but you can go \setkeys{Gin}{width=.75\natwidth,keepaspectratio} which comes to the same thing Nov 16, 2012 at 22:34
  • 1
    @DavidCarlisle This gives me ! Undefined control sequence. \Gin@@ewidth ->.75\natwidth and ! Illegal unit of measure (pt inserted). (each of them twice per image).
    – doncherry
    Nov 16, 2012 at 22:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .