*From*: "Rob McDonald" <rob a mcdonald gmail com>*To*: "discussions about usage and development of dia" <dia-list gnome org>*Subject*: Re: Metapost - text alignment*Date*: Fri, 26 Jan 2007 19:37:17 -0800

On 1/26/07, Rob McDonald <rob a mcdonald gmail com> wrote:

From the documentation, I do not understand the scope of the bounding box information (when it exists, and how it can be accessed), I will try to find some time to play with it soon. Right now, I don't even have LaTeX up and running on my laptop. Rob

The following MetaPost program 'does the right thing'. And should provide a guide for positioning _any_ LaTeX text as one would hope. Turns out it was pretty simple, once you wrap your head around MetaPost. (I got some help from Usenet). We can throw two simple macros into the MetaPost boilerplate, and everything should be easy. Rob beginfig(1); verbatimtex \documentclass{minimal} \begin{document} etex x = 1.0cm; y = -1.0cm; %% Left justified text positioned with label. %% Note that the space between the lines is not what you would want. label.rt(btex {\usefont{OT1}{cmr}{m}{n} aaaaaaa} etex scaled 1.0,(3.0000x,4.650000y)); label.rt(btex {\usefont{OT1}{cmr}{m}{n} aa} etex scaled 1.0,(3.0000x,5.000000y)); label.rt(btex {\usefont{OT1}{cmr}{m}{n} aaab} etex scaled 1.0,(3.0000x,5.350000y)); label.rt(btex {\usefont{OT1}{cmr}{m}{n} aaaaa} etex scaled 1.0,(3.0000x,5.700000y)); label.rt(btex {\usefont{OT1}{cmr}{m}{n} aaay} etex scaled 1.0,(3.0000x,6.050000y)); label.rt(btex {\usefont{OT1}{cmr}{m}{n} aaaaaaa} etex scaled 1.0,(3.0000x,6.400000y)); %% Left justified text positioned with draw. draw btex {\usefont{OT1}{cmr}{m}{n} aaaaaaa} etex scaled 1.0 shifted (4.50000x,4.650000y); draw btex {\usefont{OT1}{cmr}{m}{n} aa} etex scaled 1.0 shifted (4.50000x,5.000000y); draw btex {\usefont{OT1}{cmr}{m}{n} aaab} etex scaled 1.0 shifted (4.50000x,5.350000y); draw btex {\usefont{OT1}{cmr}{m}{n} aaaaa} etex scaled 1.0 shifted (4.50000x,5.700000y); draw btex {\usefont{OT1}{cmr}{m}{n} aaay} etex scaled 1.0 shifted (4.50000x,6.050000y); draw btex {\usefont{OT1}{cmr}{m}{n} aaaaaaa} etex scaled 1.0 shifted (4.50000x,6.400000y); % Define macro for horizontal centering. vardef hcentered primary P = P shifted -(xpart center P, 0) enddef; %% Horizontally centered text positioned with draw draw hcentered btex {\usefont{OT1}{cmr}{m}{n} aaaaaaa} etex scaled 1.0 shifted (7.00000x,4.650000y); draw hcentered btex {\usefont{OT1}{cmr}{m}{n} aa} etex scaled 1.0 shifted (7.00000x,5.000000y); draw hcentered btex {\usefont{OT1}{cmr}{m}{n} aaab} etex scaled 1.0 shifted (7.00000x,5.350000y); draw hcentered btex {\usefont{OT1}{cmr}{m}{n} aaaaa} etex scaled 1.0 shifted (7.00000x,5.700000y); draw hcentered btex {\usefont{OT1}{cmr}{m}{n} aaay} etex scaled 1.0 shifted (7.00000x,6.050000y); draw hcentered btex {\usefont{OT1}{cmr}{m}{n} aaaaaaa} etex scaled 1.0 shifted (7.00000x,6.400000y); % Define macro for right justification. vardef rjust primary P = P shifted -(xpart (lrcorner P - llcorner P), 0) enddef; draw rjust btex {\usefont{OT1}{cmr}{m}{n} aaaaaaa} etex scaled 1.0 shifted (9.50000x,4.650000y); draw rjust btex {\usefont{OT1}{cmr}{m}{n} aa} etex scaled 1.0 shifted (9.50000x,5.000000y); draw rjust btex {\usefont{OT1}{cmr}{m}{n} aaab} etex scaled 1.0 shifted (9.50000x,5.350000y); draw rjust btex {\usefont{OT1}{cmr}{m}{n} aaaaa} etex scaled 1.0 shifted (9.50000x,5.700000y); draw rjust btex {\usefont{OT1}{cmr}{m}{n} aaay} etex scaled 1.0 shifted (9.50000x,6.050000y); draw rjust btex {\usefont{OT1}{cmr}{m}{n} aaaaaaa} etex scaled 1.0 shifted (9.50000x,6.400000y); endfig; end;

**Follow-Ups**:**RE: Metapost - text alignment***From:*Young, Robert

**References**:**Metapost - text alignment***From:*Young, Robert

**Re: Metapost - text alignment***From:*Lars Clausen

**Re: Metapost - text alignment***From:*Rob McDonald

**Re: Metapost - text alignment***From:*Lars Clausen

**Re: Metapost - text alignment***From:*Rob McDonald

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