# Rasterize: Work around ImageFormattingWidth being broken

## Bug introduced in 11.1 or earilier and persisting through 11.3

Confirmed: CASE:4041910

### Update

The behavior described below only occurs inside the Documentation notebook or for cells with certain styles (e.g. "Output") - I therefore assume the issue is somewhere in the stylesheets, I'll try to investigate a bit more...

### Original question

ImageFormattingWidth seems to be completely broken:

Using the examples from the documentation,

(* Line wrap at 500 printer's points: *)
Rasterize[Expand[(a + b)^20], ImageFormattingWidth -> 500, ImageSize -> 450]


(* Do not line wrap: *)
Rasterize[Expand[(a + b)^20], ImageFormattingWidth -> Infinity, ImageSize -> 450]


As you can see, the setting has no effect at all. This seems to be caused by the fact that PageWidth (which is internally used to handle ImageFormattingWidth) does not affect output cells:

SetOptions[EvaluationNotebook[], PageWidth -> 300]
a^5 + 5 a^4 b + 10 a^3 b^2 + 10 a^2 b^3 + 5 a b^4 + b^5


How can I still get the intended effect of ImageFormattingWidth? The solutions from this question don't work, and playing around with explicitly wrapping the expression to Rasterize in a Notebook seems to make it impossible to specify the size of the resulting image:

With[
{exp = Expand[(a + b)^20]},
Rasterize[
Notebook[
{Cell[BoxData@ToBoxes@exp]},
WindowSize -> 250,
Magnification -> 1
],
RasterSize -> 100
]
]
ImageDimensions@%


(* {198, 188} *)

• Please do not use the bugs tag until other users have confirmed your observations. – J. M. will be back soon Apr 8 '18 at 12:38
• @J.M.needshelp. I had already confirmed the problem on multiple computers and with multiple people, so I assumed it was appropriate to put the tag there... I'll try to remember to wait for the site community in the future though :) – Lukas Lang Apr 8 '18 at 13:29
• @J.M.needshelp. I have received a reply from Wolfram support, and they confirmed that it is not working as documented - I hope it is ok to put the bugs tag back in this case – Lukas Lang Apr 15 '18 at 11:58