3
$\begingroup$

I use the following code to create a new notebook for presentation slides with a docked "banner" cell:

With[{mycell = 
   Cell[BoxData[
     RowBox[{ToBoxes[
        Text[Style["Title of talk, Conference, Location, Date", 
             22, Italic, 
             FontColor -> Gray, 
             FontFamily -> "Times"]]]}]], 
    "DockedCell"]}, 
 nb = NotebookCreate[
      ScreenStyleEnvironment -> "SlideShow", 
      DockedCells -> 
        Dynamic[If[
          CurrentValue[EvaluationNotebook[], 
          ScreenStyleEnvironment] === "SlideShow", 
    {Inherited, mycell}, mycell]]]]

Then I edit and save the generated notebook as Presentation1.nb.

Then I wish to create a new (slide) notebook, Presentation2.nb, re-using much of the content of Presentation1.nb, so in the Finder I duplicate Presentation1.nb and call it Presentation2.nb and then open and edit its contents. How do I also edit the new docked cell's contents in Presentation2.nb without having to again generate a new notebook?

$\endgroup$
1
  • $\begingroup$ Will editing CurrentValue[SelectedNotebook[], DockedCells] do what you want? $\endgroup$ Apr 14 '16 at 6:33
3
$\begingroup$

You can use SetOptions directly on any Notebook like this:

myNewCell = 
  Cell@RawBoxes@
    ToBoxes@Style["Title of talk, Conference, Location, Date", 22, 
      Italic, FontColor -> Blue, FontFamily -> "Times"];

SetOptions[EvaluationNotebook[], DockedCells -> myNewCell]

Since DockedCells are not editable but may still contain dynamics, this is another approach:

myNewCell = Cell[RawBoxes@ToBoxes@Dynamic@$header];
SetOptions[EvaluationNotebook[], DockedCells -> myNewCell]

$header = Style["Change me at will", 22,
   Italic, FontColor -> Green, FontFamily -> "Times"]

And you can grab the existing one and edit it as well:

d = CurrentValue[EvaluationNotebook[], DockedCells];
FullForm@d (*Prints d so you can then edit it*)
altered=Cell[RawBoxes[StyleBox["\"Another Conference, Location, Date\"",14,Italic,FontColor\[Rule]RGBColor[1,0,1],FontFamily\[Rule]"Menlo"]]];
SetOptions[EvaluationNotebook[], DockedCells -> altered]

which now looks like

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks M. R. I happen to be traveling for over a week starting tomorrow morning very early and will try running your code when I return. $\endgroup$ Apr 14 '16 at 4:51
  • $\begingroup$ Thanks, M. R. Your code is an improvement upon my methods and very useful (hence +1), but it won't help me with the many slide presentations that I've already made. I gather that there is no way to edit a docked cell. $\endgroup$ Apr 14 '16 at 21:22
  • $\begingroup$ @DavidG.Stork I added a bit to my answer, you can edit these cells by reading, then editing, then setting them back. $\endgroup$
    – M.R.
    Apr 15 '16 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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