Re: Metapost - text alignment

On 1/27/07, Rob McDonald <rob a mcdonald gmail com> wrote:
On 1/27/07, Lars Clausen <lars raeder dk> wrote:
> On Fri, 2007-01-26 at 07:51 -0800, Rob McDonald wrote:
> > In MetaPost, LaTeX renders the text, and I don't think MP ever 'knows'
> > or 'controls' the text width.  The text width is a fallout from the
> > font size and the string.
> Can't we tell the LaTeX part to scale it to a certain width?

I'll see what I can do.  I think I can come up with another MetaPost
macro to scale any object to a desired width.  However, I don't think
that is a great idea.

Here is the MetaPost to handle what you're after.  I still don't think
it is the right thing to do in 99% of all situations.

% Define macro to scale to a desired width.
primarydef P scaledw W =
 P scaled (W/(xpart (lrcorner P - llcorner P)))

draw btex {\usefont{OT1}{cmr}{m}{n} $c^2=a^2+b^2$} etex scaled 1.0
shifted (11.00000x,4.650000y);
draw btex {\usefont{OT1}{cmr}{m}{n} Mary had a little lamb.} etex
scaled 1.0 shifted (11.00000x,5.000000y);

draw btex {\usefont{OT1}{cmr}{m}{n} $c^2=a^2+b^2$} etex scaledw 4.0cm
shifted (11.00000x,7.650000y);
draw btex {\usefont{OT1}{cmr}{m}{n} Mary had a little lamb.} etex
scaledw 4.0cm shifted (11.00000x,8.000000y);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]