Here's a way to do it. First we'll use this as our DockedCell
expression:
newDockedCell =
Cell[
BoxData@ToBoxes@
Pane[
Import["https://i.imgur.com/LUIaEdC.png"],
ImageSize ->
{
FEPrivate`Part[
FrontEnd`AbsoluteCurrentValue[FrontEnd`EvaluationNotebook[],
WindowSize],
1],
Automatic
},
ImageSizeAction -> "ShrinkToFit",
Alignment -> Center
]
];
Then just add these style edits to the stylesheet however you like. This is my preferred short-hand (using custom package-level functions), but the easiest thing is just to do it manually as you have done:
StyleSheetEdit[
"Notebook",
DockedCells ->
newDockedCell,
"MakeCell" -> True
]
StyleSheetEdit[
"DockedCell",
{
CellFrameMargins -> 0,
Background -> White
},
"MakeCell" -> True
]
The key here is this:
FEPrivate`Part[
FrontEnd`AbsoluteCurrentValue[FrontEnd`EvaluationNotebook[],
WindowSize],
1]
That will be computed by the front-end directly and give the notebook width.
By setting these:
ImageSizeAction -> "ShrinkToFit",
Alignment -> Center
The Pane
will force the content to be centered and take on that size and shrink if constrained.
You can see from these that it works:
Getting this into the stylesheet:
This can be a little annoying to add to the stylesheet, so here's an effective way to do this:
- Go to the stylesheet
- Find the style
CellObject
for"Notebook". This can be most easily gotten via
PreviousCell. This can be most easily gotten viaorPreviousCell
NextCell` orNextCell
. - Run this:
SetOptions[thatCell, DockedCells->newDockedCell]
- Select that cell and toggle Show Expression on and off
It should work after that