6

Is there a way to set up key bindings for the DisplayFormula and DisplayFormulaNumberedstyles? I am using Mathematica 9 on mac OS X 10.7.5. This would be very useful as it is time consuming having to click through with the mouse each time.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Virgo
  • 375
  • 2
  • 9

2 Answers2

10

Yes, you can do that. You can for all notebooks using a given style by editing the style notebook for that style or you can do it for just one notebook. In either case you do the following:

  1. To make key bindings for styles in a stylesheet, open the relevant stylesheet notebook in Mathematica ; to make bindings restricted to an individual notebook, make that notebook the active one, and choose Format > Edit Stylesheet...
  2. Select a cell in the stylesheet of the style you want to edit. If you don't see it, choose the style from the drop-down menu at top left of stylesheet window.
  3. Open the Options Inspector.
  4. Choose Selection at the top left of Options Inspector.
  5. Search for "menucommandkey" in the search box at top right.

You can bind the selected style to Cmnd+1 through Cmnd+9 and Cmnd+Shift+2 through Cmnd+Shift+0. To assign a Cmnd+Shift shortcut, enter the appropriate shifted character; e.g., enter "@" into the Options Inspector to get Cmnd+Shift+2 (or the appropriate key depending on your keyboard language). If all the bindings are in use, you will have to give up one (override it) to make a new binding.

The following image shows how editing cmnd key assignments in a stylesheet notebook looks.

StyleCmndKey.png

Update

There were mistakes and omissions in my answer when first posted. I hope I have fixed them now.

RoberRM
  • 319
  • 1
  • 9
m_goldberg
  • 107,779
  • 16
  • 103
  • 257
  • Thanks, I followed your instructions, but when I go back to the notebook and press the key combination it has no affect. – Virgo Jul 09 '13 at 02:13
  • @physicsphile. I have made corrections and added some more detail.. – m_goldberg Jul 09 '13 at 04:01
  • 1
    Note: you are not limited to 1 - 9, as Shift is an accepted modifier, too. So, I have stylesheets where I am using close to 20 shortcuts. Also, the cell definition can be modified directly by selecting the cell and pressing Ctrl+Shift+e. Then add the option, "MenuCommandKey" -> "any valid key", to the definition. That is often faster than going through the option inspector. – rcollyer Jul 09 '13 at 13:02
  • @rcollyer. I could not get shifted keys to work on my OS X system. – m_goldberg Jul 09 '13 at 15:15
  • I've never had an issue on OSX. – rcollyer Jul 09 '13 at 15:32
  • @m_goldberg. Thanks for your help! – Virgo Jul 10 '13 at 01:25
  • @rcollyer: I tried to alter the hotkey for style code and I modified Cell[StyleData["Code"], MenuCommandKey->"Alt+Shift+8" FontColor->RGBColor[1, 0, 0], Background->RGBColor[1, 0.85, 0.85]]. That did not work! Code associated to Alt-8 is indicated as Cell[StyleData["Code"], MenuCommandKey->"8", FontColor->RGBColor[1, 0, 0], Background->RGBColor[1, 0.85, 0.85]]. After this operation, the shortcut Alt+8 was available again through Format>Style. It looks like entering MenuCommandKey->"a" associates Alt+a to the style (which is reflected as Alt+A in Format->Style (with a capital A). – Adalbert Hanßen Feb 21 '16 at 15:09
  • When I do this, the menucommandkey option is greyed out and I cannot change it. – NonalcoholicBeer Dec 05 '18 at 08:32
2

This already exists in the Articles StyleSheets, both in the JournalArticle and Preprint as well as in the Book StyleSheets both in the TextBook and Monograph. In all these the

DisplayFormula is Alt+5

and the

DisplayFormulaNumbered is Alt+6.

I like these StyleSheets more then the Default one. There is a peculiarity in them, however, which might seem uncomfortable: in all of them the newly-created cell is by default the TextCell, rather than InputCell, which is the case in the Default StyleSheet. This is, however, logic. In everything else these StyleSheets are much richer in features.

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96