0

I have a custom palette that I use constantly (code below). I would like it to open automatically when I first open Mathematica (13.0.1.0 for MacOS). Is this possible, and if so, how?

I did look at the answer here about init.m files, but TBH I found the discussion a bit baffling - especially since there is zero 'how to' documentation in the help, just a description of what an init.m file is (nothing on methodology). It's also slightly unnerving since one user reported that his original init.m file got wiped.

In short, I need more hand-holding than you might expect! I'd be really grateful for help.

The palette code:

styleButtons = 
   (Button[Style[#1, 14, FontFamily -> "Calibri"], 
      FrontEndTokenExecute[InputNotebook[], "Style", 
       #1], Appearance -> "Palette", 
      ImageSize -> 250] & ) /@ {"", "Item", 
     "ItemNumbered", "ItemParagraph", "", "Subitem", 
     "SubitemNumbered", "SubitemParagraph", "", 
     "DisplayFormula", "DisplayFormulaNumbered", 
     ""}; 
gapButton = Button[Style["", 14, FontFamily -> 
      "Calibri"], "", Appearance -> "Palette"]; 
align = Button[Style["Align", 14, FontFamily -> 
      "Calibri"], NotebookWrite[InputNotebook[], 
      "\[AlignmentMarker]"]; SelectionMove[InputNotebook[], All, 
      Cell]; SetOptions[NotebookSelection[
       InputNotebook[]], TextAlignment -> 
       AlignmentMarker], Appearance -> "Palette"]; 
turnOffAlignment = Button[Style["Un-Align", 14, 
     FontFamily -> "Calibri"], 
    SelectionMove[InputNotebook[], All, Cell]; 
     SetOptions[NotebookSelection[InputNotebook[]], 
      TextAlignment -> Inherited], 
    Appearance -> "Palette"]; 
copyCellRef = Button[Style["Copy Reference", 14, 
     FontFamily -> "Calibri"], 
    Module[{cell, tags, tag, createTag}, 
     cell = First[Cells[NotebookSelection[
          InputNotebook[]], CellStyle -> 
          "DisplayFormulaNumbered"], 
        MessageDialog["Select an equation cell!"]; 
         Return[]]; tags = Replace[CurrentValue[
         cell, CellTags], t:Except[_List] :> {t}]; 
      createTag := With[{newTag = CreateUUID[
           "eqnID-"]}, SetOptions[cell, 
          CellTags -> Append[Select[tags, 
             Not @* StringMatchQ["eqnID-*"]], 
            newTag]]; newTag]; 
      tag = SelectFirst[tags, StringMatchQ[
         "eqnID-*"], createTag]; 
      If[Length[Cells[InputNotebook[], 
          CellTags -> tag]] > 1, 
       MessageDialog["Multiple cells with same  tag \
found!\n     Tag of current cell will be  \
regenerated."]; tag = createTag]; With[{tag = tag}, 
       CopyToClipboard[Button[
         Row[{"(", Dynamic[CurrentValue[
             First[Cells[CellTags -> tag], $Failed], 
             {"CounterValue", 
              "DisplayFormulaNumbered"}]], ")"}], 
         Appearance -> None]]]], Appearance -> 
     "Palette"]; 
pasteCellRef = Button[Style["Paste Reference", 14, 
     FontFamily -> "Calibri"], Paste[], 
    Appearance -> "Palette"]; 
CreatePalette[Column[Join[styleButtons, 
     {align, turnOffAlignment, gapButton, 
      copyCellRef, pasteCellRef, gapButton}], 
    Spacings -> 0, Alignment -> Center], 
   Saveable -> False, WindowTitle -> 
    "Cell Styles & Cell Ref"]; 
Richard Burke-Ward
  • 2,231
  • 6
  • 12
  • When I open a palette in Wolfram Desktop 13.2 on Mac, it stays open after I restart WD. (I only checked with built-in palettes). Does it not work the same way for you? Have you installed your palette with Palettes > Install Palette...? – Victor K. Jan 31 '23 at 08:40
  • See also https://mathematica.stackexchange.com/questions/8589/programmatically-opening-a-palette-from-the-palettes-menu – Victor K. Jan 31 '23 at 08:41
  • Sorry for the delay replying. I tried Palettes > Install Palette, but it doesn't behave very well. I tried both "From file" and "From clipboard". On some occasions, I get a flashed-up error message that is too fast to see, followed by a return to the Install dialogue box. On others, nothing at all happens. And sometimes it "installs" but when I then choose the palette all that happens is that it opens a notebook containing the code for the palette... – Richard Burke-Ward Feb 01 '23 at 14:01
  • If Install Palette doesn't behave as expected, there is something fundamentally wrong with your installation (or you don't use it correctly). I suggest to try to follow http://reference.wolfram.com/language/tutorial/CreatingPalettes.html literally and/or re-install your system from scratch, if possible. – Victor K. Feb 01 '23 at 16:49

0 Answers0