Hi guys, I'm pulling my hair out. I'm trying to set up an automatism to fit pictures to the available space on a slide. I need to consider three parameters: 1. If the user supplies a value for width= or height= , use this value (captured in a macro); 2. respect the maxwidth and maxheight which must not exceed the frame; 3. if the picture is smaller than the available space, blow it up so that it reaches the maxwidth or maxheight (but doesn't exceed either). factor=max or =fit does not work because it allows pictures to exceed one of the maximum values. About a year ago Giuseppe Bilotta wrote a message which I append; it describes my problem. Is there a generic solution for this problem? If there is, I'll gladly take it; if there isn't, I thought I had a solution but may need help with expanding and conditionals, then I'll be back with more questions. Anyway, good night all, and thanks. Thomas
Subject: Re: [NTG-context] factor=fit images don't fit Sunday, July 22, 2007 Hans Hagen wrote:
the fit assumes operating on a page not in a box;
Ah, didn't know that. I couldn't even tell from the sources, since it uses enclosing box dimensions and not page or paper sizes. I suspect the logic is broken at the page level too though, let me explain why.
Currently, if I understand the code correctly, factor=fit expands the figure to have its major direction fit, while factor=max expands the figure to have its minor direction fit.
Instead, the behavior I would expect from fit (resp. max) is for the *expansion ratio* to be the minimum (resp. maximum) of the expansion ratios in the two directions (not the sizes in those directions, but the ratio between the sizes of the figure and the container). The difference is noticeable when the container and contained have different aspect ratios.
Consider for example a 20x30mm figure in a 50x150mm page (strange numbers, just used to show what I mean): with the current code, using 'fit' would consider the largest dimension (30) and thus calculate a factor of 150/30 = 5, but this gives us an image which is 100x150mm, i.e. an image that doesn't fit! Whereas, if we computed the ratios 50/20 = 2.5 and 150/30 = 5, we would know that the ratio to be picked was 2.5 in 'fit' and 5 in 'max'.
Or I misintepreting the meaning of 'fit' and 'max'?
an alternative is:
\framed[width=5cm,height4cm]
{\externalfigure[mill.png][maxwidth=4cm,maxheight=5cm,width=10cm]}
i.e. setting the maximum values
I hadn't thought about using width and maxwidth (and maxheight) at the same time, thanks. Of course, I'd rather have 'fit' and 'max' usable in boxes :)