8
$\begingroup$

For everyday work I use a custom notebook template. Its name DefaultModified.nb However, in order to open it I need to first open a built-in default notebook, go to the Menu/Format/StyleSheet and define the style that I need.

My question: Is it possible to fix in Mma a style of the notebook that will open by default? In my case the DefaultModified.nb.

Note that I do not want to kill or change the Default.nb style. Let it be in case that something goes wrong. I only want to ask Mma to open another template by default.

$\endgroup$
6
  • $\begingroup$ You can use DefaultStyleDefinitions but I'd rename yours to Default.nb and put it in $UserBaseDirectory/... so that notebooks have a valid StyleDefinitions when sent to others. $\endgroup$
    – Kuba
    Nov 29, 2016 at 12:23
  • $\begingroup$ @Kuba How to use the DefaultStyleDefinitions? Yes, I understan that I could simply rename DefaultModified.nb into Defalt.nb. My point is, however, that I do not want to destroy the Default.nb $\endgroup$ Nov 29, 2016 at 12:34
  • 1
    $\begingroup$ You don't have to destroy it, it is in $InstallationDirectory while yours would be in $UserBaseDirectory. I haven't tried DefaultStyleDefinitions but I suppose SetOptions[$FrontEnd... should work. $\endgroup$
    – Kuba
    Nov 29, 2016 at 12:38
  • $\begingroup$ Related $\endgroup$
    – Stitch
    Nov 29, 2016 at 14:42
  • $\begingroup$ You begin the question by referring to a template. Later it appears that you want to set a default stylesheet? If you want to globally set the default stylesheet that opens with each new notebook then doing that in the options inspector is probably easiest $\endgroup$ Nov 30, 2016 at 3:53

2 Answers 2

7
$\begingroup$

According to the Documentation,

DefaultStyleDefinitions is a global option that specifies the default stylesheet for all new notebooks.

The stylesheet must be located in a directory that is listed in StyleSheetPath.

Note that this option affects not only on-screen display, but also determines the default styles used by Export.

By convention the custom user stylesheets should be located in the user profile directory:

dir = FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "StyleSheets"}];

If the directory doesn't exists one should create it:

If[! DirectoryQ[dir], CreateDirectory[dir]];

You should put your custom stylesheet "DefaultModified.nb" in this directory and then set it as the default via

CurrentValue[$FrontEnd, DefaultStyleDefinitions] = "DefaultModified.nb";

After restarting the FrontEnd all the new Notebooks will have this stylesheet by default.


It is worth to mention that according to Kuba's comment, StyleDefinitions are always set as a path relative to directories on StyleSheetPath, for example one can specify StyleDefinitions -> FrontEnd`FileName[{"Lectures"}, "styles.nb"] for a stylesheet "styles.nb" in a directory "Lectures" located wherever on StyleSheetPath. The same should be true for DefaultStyleDefinitions.

$\endgroup$
1
  • $\begingroup$ Do not use this method with 12.1, it produces curious results (in my case, unevaluatable cells). Use the method described in the article in Wolfram Support linked by ktm. $\endgroup$
    – Nicholas G
    Feb 17, 2021 at 9:25
10
$\begingroup$

Wolfram has an article discussing precisely this:

http://support.wolfram.com/kb/29974

$\endgroup$

Your Answer

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

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