4

I have created an initialization cell with options. I would like to create a template, which already contains these cells, when I open a new notebook.

Is there any opportunity to create such a template file?

Thank you for your answers in advance!

Rohit Namjoshi
  • 10,212
  • 6
  • 16
  • 67
ibroni
  • 49
  • 1
  • Maybe it can be done by doing something (say NotebookWrite[EvaluationNotebook[], Cell[...]]) inside NotebookDynamicExpression option of StyleData["Notebook"]. Do save your work before trying anything evolving NotebookDynamicExpression! Wrong code can crash the FrontEnd easily! – Silvia Apr 07 '20 at 15:23
  • You can add an InputAlias that inserts this by using NotebookRead to get the Cell expression and then you can this alias to either the Default.nb stylesheet or make your own. Then when you want this template you just have to type Esc-template-Esc or something and it will insert itself. – b3m2a1 Apr 08 '20 at 03:21
  • Thank you very much! – ibroni Apr 23 '20 at 14:54

1 Answers1

3

Sure you can do this. Indeed, I find it a great way of standardising workflows.

The image below is an example of a notebook that is automagically generated from a palette.

enter image description here

Everything in the notebook, including the image at the base (a hyperlink to my employer's website), the signature which is a mailto: hyperlink and the dynamic dropdown header is generated from the palette. It's displayed at 75% magnification to get it all onscreen, but I generate it at 100%. The stylesheet employs corporate colors and is custom.

It's essentially combination of TextCell[] within CreateDocument[]:

CreateDocument[{
            TextCell["Title", "Title", CellTags -> {"Title"}], 
            TextCell["Subtitle", "Subtitle", CellTags -> {"Subtitle"}], 
            TextCell["Abstract", "Abstract", CellTags -> {"Abstract"}],
(* more of the same *)}, (* with options ...*)]
dwa
  • 1,939
  • 14
  • 14