[NTG-context] fitting a picture to the available space
Thomas A. Schmitz
thomas.schmitz at uni-bonn.de
Fri Sep 12 14:37:42 CEST 2008
On Sep 12, 2008, at 9:14 AM, Wolfgang Schuster wrote:
> You should close the box before you want to get it's dimensions.
:-) That seems like a reasonable suggestion... I had been copy-pasting
and adapting my code.
>
>
> \unprotect
>
> \def\????bf{@@@@bf}
>
> \presetlocalframed[\????bf]
>
> \def\boxfigure[#1][#2]%
> {\bgroup
> \setbox\scratchbox\hbox{\externalfigure[#1]}%
> \!!dimena\wd\scratchbox
> \!!dimenb\ht\scratchbox
> \localframed
> [\????bf]
> [\c!strut=\v!no,
> \c!width=8cm,
> \c!height=6cm,
> #2]
> \bgroup
> \!!dimena\dimexpr\hsize/\!!dimena\relax
> \!!dimenb\dimexpr\vsize/\!!dimenb\relax
> \ifdim\!!dimena>\!!dimenb
> \externalfigure[mill][height=\vsize]
> \else
> \externalfigure[mill][width=\hsize]
> \fi
> \egroup
> \egroup}
>
> \protect
>
> \starttext
>
> \boxfigure[mill][width=8cm,height=2cm]
>
> \boxfigure[mill][width=2cm,height=8cm]
>
> \stoptext
>
> Wolfgang
Wow, that looks good! I could adapt this to my circumstances, and it
seems to do exactly what I want! Hans: could something like this be
added to the core? The keywords "max fit broad" for the "factor"
option are already taken, so what about "fill"? But I guess it only
makes sense if we can test and adapt to the current vbox (not
necessarily the page).
Anyway: Wolfgang, thanks a lot, this does exactly what I want!
All best
Thomas
More information about the ntg-context
mailing list