Skip to main content
added 1 character in body
Source Link
b3m2a1
  • 47.1k
  • 3
  • 95
  • 245

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:

small

medium

large

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 via orPreviousCellNextCell` or NextCell.
  • Run this:

SetOptions[thatCell, DockedCells->newDockedCell]
  • Select that cell and toggle Show Expression on and off

It should work after that

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:

small

medium

large

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 PreviousCellorNextCell`.
  • Run this:

SetOptions[thatCell, DockedCells->newDockedCell]
  • Select that cell and toggle Show Expression on and off

It should work after that

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:

small

medium

large

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 or NextCell.
  • Run this:

SetOptions[thatCell, DockedCells->newDockedCell]
  • Select that cell and toggle Show Expression on and off

It should work after that

added 72 characters in body
Source Link
b3m2a1
  • 47.1k
  • 3
  • 95
  • 245

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:

small

medium

large

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 CellCellObject for `"Notebook""Notebook". This can be most easily gotten via PreviousCellorNextCell`.
  • Run this:

SetOptions[thatCell, DockedCells->newDockedCell]
  • Select that cell and toggle Show Expression on and off

It should work after that

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:

small

medium

large

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 Cell for `"Notebook"
  • Run this:

SetOptions[thatCell, DockedCells->newDockedCell]
  • Select that cell and toggle Show Expression on and off

It should work after that

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:

small

medium

large

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 PreviousCellorNextCell`.
  • Run this:

SetOptions[thatCell, DockedCells->newDockedCell]
  • Select that cell and toggle Show Expression on and off

It should work after that

added 375 characters in body
Source Link
b3m2a1
  • 47.1k
  • 3
  • 95
  • 245

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:

small

medium

large

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 Cell for `"Notebook"
  • Run this:

SetOptions[thatCell, DockedCells->newDockedCell]
  • Select that cell and toggle Show Expression on and off

It should work after that

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:

small

medium

large

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:

small

medium

large

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 Cell for `"Notebook"
  • Run this:

SetOptions[thatCell, DockedCells->newDockedCell]
  • Select that cell and toggle Show Expression on and off

It should work after that

Source Link
b3m2a1
  • 47.1k
  • 3
  • 95
  • 245
Loading