6
$\begingroup$

I previously asked how to make a cell containing left-, center-, and right-justified elements, answered here. How does one create a slideshow notebook with such a banner locked in place, such that when the user changes the window size these justifications are retained? Moreover, the banner must appear at the top of every slide.

Here's a minimal example attempt at what I seek... though the created notebook does not have the desired docked cell:

leftImage = ExampleData[{"TestImage", "House"}];
rightImage = ExampleData[{"TestImage", "Girl"}];

myBanner = Grid[{{
     Pane[ImageResize[leftImage, 100], Full, Alignment -> Left],
     Pane[Text[Style["Center text", Italic]], Full, 
      Alignment -> Center],
     Pane[ImageResize[rightImage, 100], Full, Alignment -> Right]}}, 
   Background -> GrayLevel[.92]];

nb = NotebookCreate[ScreenStyleEnvironment -> "SlideShow", 
  DockedCells -> 
   Dynamic[If[
     CurrentValue[EvaluationNotebook[], ScreenStyleEnvironment] === 
      "SlideShow", {Inherited, myBanner}, myBanner]]]
$\endgroup$
6
  • 1
    $\begingroup$ The option setting for DockedCells should be a Cell object, so something like DockedCells->Cell @ BoxData @ ToBoxes @ myBanner should work. $\endgroup$
    – Carl Woll
    Apr 3, 2023 at 19:10
  • $\begingroup$ Almost... almost... Your version creates a one-slide document but does not allow the creation of multiple slides, each with the same desired docked header. Test your version to see the problem. $\endgroup$ Apr 3, 2023 at 19:17
  • $\begingroup$ does this give what you need: With[{dc = Cell@ToBoxes@myBanner}, nb = NotebookCreate[ScreenStyleEnvironment -> "SlideShow", DockedCells -> Dynamic[If[ CurrentValue[EvaluationNotebook[], ScreenStyleEnvironment] === "SlideShow", {Inherited, dc}, dc]]]]? $\endgroup$
    – kglr
    Apr 5, 2023 at 20:06
  • $\begingroup$ @kglr: Oh... you are so close. Your code indeed gives what I seek, but it has one small glitch: It does not preserve full function of the slide selection pull-down menu at the top left of the toolbar. I create three slides (say), and that toolbar pulldown lists only slide 1. If you fix that, and post your code as an answer, then I'll accept it... and the world will be a better place! $\endgroup$ Apr 5, 2023 at 20:25
  • 1
    $\begingroup$ @kglr: My mistake... one need merely click and hold to get the full pulldown list. So if you want a quick 100 reputation points, post your code and I'll accept it! $\endgroup$ Apr 5, 2023 at 22:41

1 Answer 1

2
+100
$\begingroup$

Basen on comments above the following gives the desired result:

With[{dc = Cell @ ToBoxes @ myBanner},  
  nb = NotebookCreate[ScreenStyleEnvironment -> "SlideShow",    
  DockedCells ->  
   Dynamic[If[
     CurrentValue[EvaluationNotebook[], ScreenStyleEnvironment] === "SlideShow",
     {Inherited, dc}, dc]]]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.