Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

The plantuml package for Sphinx generates the following LaTeX code:

\includegraphics{%s}

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

\includegraphics[scale=0.75]{%s}

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

share|improve this question

2 Answers 2

There are two ways.

First way: set a default value for some keys.

\usepackage{graphicx}
\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.

\usepackage{graphicx}
\let\ORIincludegraphics\includegraphics
\renewcommand{\includegraphics}[2][]{\ORIincludegraphics[scale=0.75,#1]{#2}}
share|improve this answer
    
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 '12 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 '12 at 13:36

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.

\documentclass{article}

\usepackage{graphicx}
    \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

\begin{document}\centering

\includegraphics{example-image-16x10}

\includegraphics{example-image-1x1}

\includegraphics{example-image-a4-landscape}

\includegraphics{example-grid-100x100pt}

\end{document}

Note that the images originally all have different aspect ratios.

output

share|improve this answer
    
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 '12 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 '12 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 –  David Carlisle Nov 16 '12 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 '12 at 22:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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