# How do I remove an entry from the Format > Stylesheet menu?

I was playing a bit with the stylesheets to make my own. In the process I have created and installed a few stylesheets but now I would like to remove some of them.

First, how do I remove an entry from the Format > Stylesheet menu?

Second, where are the stylesheet files kept? I have deleted the files from the $UserBaseDirectory/SystemFiles/FrontEnd/StyleSheets, reloaded Mathematica, even rebooted the computer, but my styles are still working! Apparently Mathematica keeps a copy of my files somewhere I don't know about. - You mean you want to remove the ones that come with your copy of Mathematica? If so, then check in $InstallationDirectory (the directory tree is the same) –  rm -rf Oct 15 '12 at 22:12
How did you create and install these in the first place? –  Mr.Wizard Oct 15 '12 at 22:18
No, I wanted to remove the stylesheet I created and installed. I did it by selecting Format/Edit Stylesheet, modifying the some styles and clicking the Install Stylesheet button. My new style appeared on the menu list and the corresponding nb file in the $UserBaseDirectory.... Removing the file from this directory does not remove the entry form the list and does not remove the style. For the solution see below – Marek Pfutzner Oct 16 '12 at 8:36 You may also need to restart Mathematica with a clean cache. See reference.wolfram.com/mathematica/tutorial/… (or its equivalent in the Documentation Center). – murray Jan 4 '13 at 1:32 add comment ## 1 Answer To my knowledge just removing the stylesheet file should be enough. The places where Mathematica looks for stylesheets can be extracted using CurrentValue CurrentValue["StyleSheetPath"] (* {FrontEndFileName[{$UserBaseDirectory,Autoload,_,FrontEnd,StyleSheets}],
FrontEndFileName[{$UserBaseDirectory,Applications,_,FrontEnd,StyleSheets}], FrontEndFileName[{$BaseDirectory,Autoload,_,FrontEnd,StyleSheets}],
FrontEndFileName[{$BaseDirectory,Applications,_,FrontEnd,StyleSheets}], FrontEndFileName[{$InstallationDirectory,AddOns,Autoload,_,FrontEnd,StyleSheets}],
FrontEndFileName[{$InstallationDirectory,AddOns,Applications,_,FrontEnd,StyleSheets}], FrontEndFileName[{$UserBaseDirectory,SystemFiles,FrontEnd,StyleSheets}],
FrontEndFileName[{$BaseDirectory,SystemFiles,FrontEnd,StyleSheets}], FrontEndFileName[{$InstallationDirectory,Configuration,FrontEnd,StyleSheets}],
FrontEndFileName[{$InstallationDirectory,SystemFiles,FrontEnd,StyleSheets}]} *)  The directory names with an underscore point to locations where several packages could be placed. Every package can have it's own FrontEnd directory, etc. IMO. The other paths are are fixed and you can extract all stylesheets there by using something like FileNames["*.nb", Cases[FileNameJoin @@@ CurrentValue["StyleSheetPath"], _String]]  ## How to find all stylesheets As one can see the above output of CurrentValue contains paths with a _. FrontEndFileName[{$UserBaseDirectory,Autoload,_,FrontEnd,StyleSheets}]


Here the _ stands for every possible directory. You can use a small function which transforms a single FrontEndFileName[..]into valid input forFileNames

makeFileNamesInput[FrontEndFileName[cont_]] :=
If[FreeQ[cont, Verbatim[_]],
{"*.nb", {FileNameJoin[cont]}},
cont /. {dir__, Verbatim[_], rest__} :> (FileNameJoin /@ {{"*", rest, "*.nb"}, {dir}})
]


And now you can search all possible directories for style-sheet notebooks

Flatten[FileNames[##, Infinity] & @@@
makeFileNamesInput /@ CurrentValue["StyleSheetPath"]]


## Better alternative

I don't now why I haven't used it when I wrote the answer, but there's a much faster alternative to find all stylesheets in all directories given by CurrentValue["StyleSheetPath"]. Although, ToFileName seems to be superseded by FileNameJoin, this function can transform all FrontEndFileName-directories returned by CurrentValue directly into valid path specifications. Therefore, when I haven't missed anything, you should find all stylesheets by

FileNames["*.nb", (ToFileName /@ CurrentValue["StyleSheetPath"]), Infinity]

-
Thanks! The problem is solved but I still do not understand it. I run your second command to get the list of all stylesheets and I see that my own styles are sitting in the –  Marek Pfutzner Oct 16 '12 at 8:40
sorry, my previous comment broke. I continue: I found my stylesheet files in the directory C:\ProgramData\Mathematica\SystemFiles\FrontEnd\StyleSheets. Removing these files removes the corresponding entries from the Format/StyleSheet menu - this is what I wanted! However, this ProgramData directory does not appear on the list generated by your first command!? $UserBaseDirectory,$BaseDirectory, and \$InstallationDirectory point somewhere else. –  Marek Pfutzner Oct 16 '12 at 8:54
@MarekPfutzner Can you join the chat here http://chat.stackexchange.com/rooms/6138/diskussion-between-halirutan-and-marek‌​ –  halirutan Oct 16 '12 at 9:36