8

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.

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96
  • 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. – Kuba Nov 29 '16 at 12:23
  • @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 – Alexei Boulbitch Nov 29 '16 at 12:34
  • 1
    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. – Kuba Nov 29 '16 at 12:38
  • 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 – Mike Honeychurch Nov 30 '16 at 03:53
  • @ Mike Honeychurch Yes, that' s what I also expected. However, when I go to OptionInspector/GlobalOptions/FileLocations/DefaultNotebook, or DefaultStyleDefinitions the corresponding items are not accessible. – Alexei Boulbitch Nov 30 '16 at 08:07

2 Answers2

10

Wolfram has an article discussing precisely this:

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

ktm
  • 4,242
  • 20
  • 28
7

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.

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
  • 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. – Nicholas G Feb 17 '21 at 09:25