I have to typeset a small paragraph inside fixed box. I don't have much control about it's content, so sometimes text overflow. I try the following two macros, but they aren't good. % AutoScaled: not what I really want, but % sometimes works % \def\AutoScaled#1#2#3#4#5{% % #1 horiz. limit % #2 unused (maybe vert. limit) % #3 horiz. scale % #4 vert. scale % #5 text \setbox800=\hbox{\color[black]{\scale[sx=#3,sy=#4]{\bf #5}}}% \newdimen\ScaleX \ScaleX=#3pt \newdimen\ScaleY \ScaleY=#4pt %% \newdimen\LimitX \LimitX=#1 % \ifdim\wd800 > \LimitX % \edef\Ratio{\withoutpt{\the\dimexpr( (2\LimitX/(\wd800 /32768))) }}% \edef\XSCALE{\withoutpt{\the\dimexpr( \Ratio\ScaleX ) }}% \edef\YSCALE{\withoutpt{\the\dimexpr( \Ratio\ScaleY ) }}% \setbox800=\hbox{\color[black]{\scale[sx=\XSCALE,sy=\YSCALE]{\bf #5}}}% \fi% \box800\relax% }%%enddef \Autoscaled %AutoSize is what I really want, but it's %WRONG!! \def\AutoSize#1#2#3{% % #1=string #2=horiz.limit #3=initial font size \newdimen\Limit \Limit=#2 \newdimen\FontSize \FontSize=#3 \doloop{% \setbox800=\hbox{#1}% \ifdim\wd800 <\Limit\exitloop \else % WARNING: eat memory , 1bp is bad step, % force ss .... it's wrong \advance\FontSize by -1bp\switchtobodyfont[ss,\the\FontSize]% %% \fi}% %\newdimen\Dimen \Dimen=0.35277778\wd800 \pointless\Dimen mm\relax% \box800\relax% } luigi