On Sep 11, 2008, at 7:59 PM, Thomas A. Schmitz wrote:
On Sep 11, 2008, at 6:20 PM, Thomas A. Schmitz wrote:
\starttext
\start
\setbox\scratchbox\vbox{\externalfigure[mill]}
\dimen0=\wd\scratchbox \dimen2=\ht\scratchbox
\framed[frame=on,strut=no,width=8cm,height=2cm] {\dimen1=\hsize \divide\dimen1 by \dimen0 \dimen3=\vsize \divide\dimen3 by \dimen2 \ifdim\dimen1>\dimen3 \externalfigure[mill][height=\vsize] \else \externalfigure[mill][width=\hsize] \fi}
\framed[frame=on,strut=no,width=2cm,height=8cm] {\dimen1=\hsize \divide\dimen1 by \dimen0 \dimen3=\vsize \divide\dimen3 by \dimen2 \ifdim\dimen1>\dimen3 \externalfigure[mill][height=\vsize] \else \externalfigure[mill][width=\hsize] \fi}
\stop
\stoptext
Wolfgang
Wolfgang,
as always, you're a source of wisdom and knowledge... Just I understand this correctly and can adapt it to my macro: \dimen1= \hsize: here \hsize refers to the size of the \framed inside which we're operating, right?
And another question: I get an error "! Illegal unit of measure (pt inserted)." Is it really possible to divide a dimension by another dimension? Not according to what I read here: http://www.tug.org/utilities/plain/cseq.html#divide-rp "must be a nonzero integer." See, I'm far from being a native speaker of TeX...
I now have something along these lines (ugly code ahead!): \setbox\scratchbox\vbox{\externalfigure[mill]% \dimen0=\wd\scratchbox% \def\@WD{\withoutpt{\the\dimen0}}% \def\@@WD{\integerrounding{\@WD}}% \dimen4=\textwidth \divide\dimen4 by \@@WD% \dimen2=\ht\scratchbox% \def\@HT{\withoutpt{\the\dimen2}}% \def\@@HT{\integerrounding{\@HT}}% \dimen6=\textheight \divide\dimen6 by \@@HT% \ifdim\dimen4>\dimen6% \def\Myheight{\textheight}\def\Mywidth{}% \else% \def\Mywidth{\textwidth}\def\Myheight{}% \fi and then use height=\Myheight,width=\Mywidth. Bu there's still a problem... Anyway, does it make sense in general? Thomas