I want to dimension a PlotLabel so that its width matches the desired ImageSize size, i.e. the label is not cut off and is not narrower than necessary.
The PlotLabel usually is a Column that can be sized with ItemSize -> {w, h}. The problem is to determine w appropriately. w = Automatic|Full|All do not work and w cannot be given in graphics coordinates.
w must be specified in ems (but with respect to which font and which font size?). So you would have to know how wide the actual graphic will be, e.g. in points, and then convert that to w. Since I don't know how this could be done, w is explicitly assigned in the following demo code.
Block[{size, w, pl},
Do[
{size, w} = sizew;
pl = Style[Column[{
Row[{"size: ", size, ", w: ", w}],
Style[StringRepeat["I am a pretty long label. ", 5], Plain, 11]
}, Center, ItemSize -> {w, Automatic}]
, Blue, Bold, 12];
Print[
Graphics[{FaceForm[GrayLevel[0.75]],
Rectangle[{-1, -1/10}, {1, 1/10}]}, PlotLabel -> pl,
ImageSize -> size]];
, {sizew, {{300, Automatic}, {300, Full}, {300, All}, {Small,
12}, {Small, 20}, {Small, 30}, {Medium, 40}}}];
];
