Skip to main content

graphics - Text[] with offset not positioned correctly in M11.1 and M11.2


Bug introduced in 11.1 and persisting through 11.3





When the first argument of Text is a Graphics, and the third argument (offset) is used, positioning is incorrect in M11.1 and M11.2. Mathematica 11.0 behaves correctly.


Example:


inset = Graphics[{Circle[{0, 0}, 2]}, Frame -> True, 
FrameTicks -> None, ImagePadding -> 1, PlotRangePadding -> None,
ImageSize -> 90]

Inset


figure = Graphics[
{Text[inset, Scaled[{0.5, 0.5}], {1, 1}]},
PlotRange -> {{0, 1}, {0, 1}},

Frame -> True,
GridLines -> {Range[0, 1, .1], Range[0, 1, .1]},
ImageSize -> 360
]

Incorrect positioning


(This is wrong)


With the {1,1} offset, the upper right corner of the inset should line up with the middle of the plot range in the enclosing figure.


In Mathematica 11.0 we get the expected output:


Correct positioning



In M11.1 and 11.2 we also get a correct positioning if the inset is a general notebook expression instead of a Graphics. We can, for example, wrap it in Framed to achieve this.


figure = Graphics[
{Text[Framed[inset], Scaled[{0.5, 0.5}], {1, 1}]},
PlotRange -> {{0, 1}, {0, 1}},
Frame -> True,
GridLines -> {Range[0, 1, .1], Range[0, 1, .1]},
ImageSize -> 360
]

Correct positioning with Framed



Is there a workaround for this bug?




This bug is of concern to me because MaTeX-generated expressions are supposed to be a drop-in replacement for text. It is supposed to work when written directly within Text. But MaTeX outputs Graphics, so it is affected by this bug. In some situations, the user can't even control if some expression they input will be used inside of a Text or an Inset.




Comments