2
$\begingroup$

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!

$\endgroup$
4
  • $\begingroup$ 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! $\endgroup$
    – Silvia
    Apr 7 '20 at 15:23
  • $\begingroup$ 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. $\endgroup$
    – b3m2a1
    Apr 8 '20 at 3:21
  • $\begingroup$ related: Create new notebook at fixed size $\endgroup$
    – Kuba
    Apr 8 '20 at 7:58
  • $\begingroup$ Thank you very much! $\endgroup$
    – ibroni
    Apr 23 '20 at 14:54
2
$\begingroup$

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 ...*)]
$\endgroup$
1
  • $\begingroup$ Thank you very much! $\endgroup$
    – ibroni
    Apr 23 '20 at 14:54

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.