Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am using Mathematica 9 on Windows 8, and I regularly want to use cell styles such as Section, SubSection and so on.

If I click the + button before creating a new cell, a context menu with a number of style options is displayed:

enter image description here

Is there a way to configure this menu to contain some of the styles that I regularly use?

share|improve this question
2  
fyi, there are actually keyboard shortcuts for the styles, predefined (see Format->Style) (I am on Mac, don't know about Windows) (and I wasn't aware that the (+) is a button :) ) –  Pinguin Dirk Oct 11 '13 at 8:41
    
Thanks, @PinguinDirk, yes I read another question about this. I might go down that route instead if there is no simple answer to my question. –  Anders Gustafsson Oct 11 '13 at 8:42
    
Select Format...Style from the menubar. –  David Carraher Oct 11 '13 at 9:21
    
Thanks, @DavidCarraher, the previous commenter also indicated this option. Ideally, I would like to avoid moving the mouse back and forth in the GUI, so keyboard shortcuts are a better option; unless there is a way to customize the context menu... –  Anders Gustafsson Oct 11 '13 at 9:46
add comment

1 Answer

up vote 4 down vote accepted

Here's a possible approach, I cannot say how stable it is:

(I will focus on Section, Subsection, but actually, you could do pretty nice stuff knowing about the menu and how to manipulate it. Also, as noted in my comment above, you might want to memorize the keyboard shortcuts for these things, but I liked the idea of manipulating that menu)

First we try to figure out where the menu comes from:

SetOptions[EvaluationNotebook[], "CellInsertionPointCell" -> None]

This switches off the menu. To get the normal menu back, we use:

SetOptions[EvaluationNotebook[], 
   "CellInsertionPointCell" -> 
    FrontEndResource["FEExpressions", "CellInsertionMenu"]]

For convenience, we define for now:

 orig = FrontEndResource["FEExpressions", "CellInsertionMenu"];

Looking at the FullForm of orig, we get an idea of the menu.

First, we could e.g. try to remove the Delimiters:

SetOptions[EvaluationNotebook[], 
 "CellInsertionPointCell" -> orig /. 
  Delimiter -> Unevaluated[Sequence[]]]

or set the menu to any random cell (not very useful):

SetOptions[EvaluationNotebook[], "CellInsertionPointCell" -> Cell["foo", "Text"]]

(a possible) solution for the problem at hand

and here's what you could do, just adjusting the original menu:

SetOptions[EvaluationNotebook[],
 "CellInsertionPointCell" ->
 ReleaseHold@Insert[orig,
  Hold@Sequence @@ {Delimiter, 
  PaneBox[GridBox[{{PaneBox[
        DynamicBox[
         FEPrivate`FrontEndResource["FEBitmaps", 
          "InsertionText"]], 
        BaselinePosition -> Scaled[0.4`] -> Center, 
        ImageSize -> 14], "Section"}}, 
     GridBoxAlignment -> {"Columns" -> {{Right}}, 
       "Rows" -> {{Baseline}}}, AutoDelete -> False, 
     GridBoxItemSize -> {"Columns" -> {{All}}, "Rows" -> {{All}}},
      GridBoxSpacings -> {"Columns" -> {0, 0.6`, 2, 0}, 
       "Rows" -> {{Automatic}}}], 
    ImageMargins -> {{0, 0}, {1, 1}}] :> 
   FrontEndTokenExecute[EvaluationNotebook[], "Style", 
    "Section"],
  PaneBox[
    GridBox[{{PaneBox[
        DynamicBox[
         FEPrivate`FrontEndResource["FEBitmaps", 
          "InsertionText"]], 
        BaselinePosition -> Scaled[0.4`] -> Center, 
        ImageSize -> 14], "SubSection"}}, 
     GridBoxAlignment -> {"Columns" -> {{Right}}, 
       "Rows" -> {{Baseline}}}, AutoDelete -> False, 
     GridBoxItemSize -> {"Columns" -> {{All}}, "Rows" -> {{All}}},

     GridBoxSpacings -> {"Columns" -> {0, 0.6`, 2, 0}, 
       "Rows" -> {{Automatic}}}], 
    ImageMargins -> {{0, 0}, {1, 1}}] :> 
   FrontEndTokenExecute[EvaluationNotebook[], "Style", 
    "Subsection"]}, {1, 1, 1, 1, 2, -1}]]

Note that I used Insert, so that we can pretty well choose where we insert the menu. I didn't put too much work into the styling, I actually just copied the "Plain Text" one and adjusted. Note that you could modify the menu any way you want, Inserting, Deleteing, Appending, Prepending, ... stuff - or just rewrite it all by yourself.

The result:

enter image description here

share|improve this answer
    
My goodness! Awesome! Many, many thanks for putting all your effort into solving this issue! Will this only be valid for my current session/notebook, i.e. do I need to run this every new session, or will the change be permanent? –  Anders Gustafsson Oct 11 '13 at 9:51
    
Glad you like it- I'd say that goes into Stylesheets, but I am definitely no good when it comes to those, sorry. There are various resources on here and the internet about these things, I am sure you'll find a good way! (and as a note: don't accept too quickly, you don't want to scare away other good answers, do you? :) Thanks anyway though!) –  Pinguin Dirk Oct 11 '13 at 10:42
    
Nice work. ...... –  Mike Honeychurch Oct 12 '13 at 0:26
    
thanks @MikeHoneychurch! –  Pinguin Dirk Oct 12 '13 at 9:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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