[metapost] btex..etex debugging

Stefan Witzel s.witzel at uni-muenster.de
Thu Mar 14 20:35:04 CET 2013


Dear Laurent and François,

thank you a lot, that was very helpful! I didn't directly react to
François's mail because I'm not getting the metapost digest (I guess
the university spam filter tries to be clever). But I looked it up in
the archive. Seems to be an awkward way to do page layout.

Best wishes,
Stefan

2013/3/14 Laurent Méhats <laurent.mehats at gmail.com>:
> Le 13/03/2013 08:42, Stefan Witzel a écrit :
>
>> Hi,
>>
>> this is just a remark, as I said, I'm not really interested in the
>> bbox makro in this contex. However, I just noticed that the
>> documentation mpman.pdf (as of October 26, 2010) states that:
>>
>> "If p is a picture, bbox p is equivalent to (llcorner p--lrcorner
>> p--urcorner p--ulcorner p--cycle)."
>>
>> (page 27). So this is then just false, is it?
>>
>> Best,
>> Stefan
>
>
> Hello,
>
> Actually, according to the manual, "If p is a picture, bbox p is equivalent
> to (llcorner p--lrcorner p--urcorner p--ulcorner p--cycle)", indeed, "except
> that it allows for a small amount of extra space around p as specified by
> the internal variable bboxmargin." So 'bbox p' is in fact equivalent to:
>   llcorner pct shifted (-bboxmargin, -bboxmargin)--
>   lrcorner pct shifted (+bboxmargin, -bboxmargin)--
>   urcorner pct shifted (+bboxmargin, +bboxmargin)--
>   ulcorner pct shifted (-bboxmargin, +bboxmargin)--
>   cycle
>
> Also, "Note that MetaPost computes the bounding box of a btex ... etex
> picture just the way TEX does. This is quite natural, but it has certain
> implications in view of the fact that TEX has features like \strut and \rlap
> that allow TEX users to lie about the dimensions of a box. [...] To get the
> true bounding box of such a picture, assign a positive value to the internal
> variable truecorners" Here is an example:
>
> --%<-- test.mp
> verbatimtex%&latex
> \documentclass{article}
> \begin{document}
> etex
>
> vardef auxbbox expr pct=
>   llcorner pct shifted (-bboxmargin, -bboxmargin)--
>   lrcorner pct shifted (+bboxmargin, -bboxmargin)--
>   urcorner pct shifted (+bboxmargin, +bboxmargin)--
>   ulcorner pct shifted (-bboxmargin, +bboxmargin)--
>   cycle
> enddef;
>
> picture pct;
> pct:=btex this is a \rlap{test} etex;
>
> beginfig(0)
> draw pct;
> draw bbox pct withpen pencircle scaled 2;
> draw auxbbox pct withcolor red;
> interim bboxmargin:=0; % temporary modification
> draw auxbbox pct withcolor green;
> endfig;
>
> truecorners:=1;
>
> beginfig(1)
> draw pct;
> draw bbox pct withpen pencircle scaled 2;
> draw auxbbox pct withcolor red;
> interim bboxmargin:=0; % temporary modification
> draw auxbbox pct withcolor green;
> endfig;
>
> end
> --%<-- test.mp
>
> In your example MetaPost behaves as it should; but as François Piétard
> noticed, 'gtpart.cls' lies about dimensions.
>
> Regards,
> Laurent Méhats
>
>
>> 2013/3/13 Stefan Witzel <s.witzel at uni-muenster.de>:
>>>
>>> Hi,
>>>
>>> ok, this is good to know, though bbox is such a suggestive name. But
>>> maybe I should explain my problem. Actually no bounding box is
>>> supposed to be there in the end. I just noticed that my labels are all
>>> over the place when using this new document class and tried to figure
>>> out why. As you can see in the attached image (with bbox and the
>>> actual bounding box) something goes wrong in determining the
>>> dimensions of the typeset text. But when I compile the debugging tex
>>> file (I added a vrule to see the left boundary) I get the rather
>>> reasonable looking pdf file attached.
>>> I also attached the metapost source. The document class is available
>>> at http://www.msp.warwick.ac.uk/agt/macros/gtpart.cls. I am grateful
>>> for suggestions about what might cause this problem.
>>>
>>> Best,
>>> Stefan
>>>
>>> 2013/3/13 Hans Hagen <pragma at wxs.nl>:
>>>>
>>>> On 3/12/2013 10:41 PM, Stefan Witzel wrote:
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> thanks Taco and Hans for the quick replies!
>>>>>
>>>>> 2013/3/12 Hans Hagen <pragma at wxs.nl>:
>>>>>>
>>>>>>
>>>>>> The bbox depends on the ht/dp of characters and lines and often the
>>>>>> character boundingbox is not tight (and when you use type one fonts
>>>>>> and
>>>>>> traditional tex characters this is even more true due to limitation s
>>>>>> of
>>>>>> the
>>>>>> machinery).
>>>>>
>>>>>
>>>>>
>>>>> In my case it's actually very strange: the text exceeds the bounding
>>>>> box by an apparently fixed amount to the left. For example if I do
>>>>>
>>>>> draw(btex this is a test etex)
>>>>> draw(bbox(btex this is a test etex))
>>>>>
>>>>> the "th" wil stick out of the box. But hopefully the debugging will
>>>>> bring clarification (I'll try tomorrow).
>>>>
>>>>
>>>>
>>>> ah .. youre not usinmg the boundingbox at all, but bbox which adds a
>>>> margin
>>>> of 1 pt by default (bbmargin or so)
>>>>
>>>> just look at the attached:
>>>>
>>>> page 1: boundingbox currentpicture overlaid
>>>> page 2: bbox currentpicture overlaid
>>>> page 3: both overlaid
>>>>
>>>>
>>>> -----------------------------------------------------------------
>>>>                                            Hans Hagen | PRAGMA ADE
>>>>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>>>>      tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>>>>                                               | www.pragma-pod.nl
>>>> -----------------------------------------------------------------
>>>
>>>
>>>
>>>
>>> --
>>> Dr. Stefan Witzel
>>> Mathematisches Institut der Universität Münster
>>> Einsteinstraße 62
>>> 48149 Münster
>>> http://wwwmath.uni-muenster.de/u/stefan.witzel
>>
>>
>>
>>
>



-- 
Dr. Stefan Witzel
Mathematisches Institut der Universität Münster
Einsteinstraße 62
48149 Münster
http://wwwmath.uni-muenster.de/u/stefan.witzel



More information about the metapost mailing list