Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I create a new shortcut for creating a "Equal Symbol Aligned Math Cell" in Mathematica 8?

Update I meant a keyboard shortcut. An "Equal Symbol Aligned Math Cell" is exactly what @Heike mentioned. I noticed that for some stylesheets there are keyboard shortcuts e.g. Cmd+7 for text, and I was wondering how to edit the stylesheets to add my own shortcuts, in particular for the math cells.

share|improve this question

migrated from Jan 26 '12 at 14:38

This question came from our site for professional and enthusiast programmers.

A couple of questions. What do you mean by shortcut? What is an "Equal Symbol Aligned Math Cell"? A picture would be preferable, a link, though, is acceptable. Lastly, while this alters the programming environment, it isn't directly on topic for SO. A better place is Mathematica. – rcollyer Jan 26 '12 at 4:22
@rcollyer In the "Writing assistant" palette there is an "Equal Symbol Aligned Math Cell" entry in the "Math Cells" drop down menu. I'm assuming that the OP wants a shortcut to that. – Heike Jan 26 '12 at 9:25
@Heike, I never use the writing assistant. So, thanks. But, again what type of shortcut? – rcollyer Jan 26 '12 at 11:10
@rcollyer neither do I but google came to the rescue. – Heike Jan 26 '12 at 11:24
I meant a keyboard shortcut. An "Equal Symbol Aligned Math Cell" is exactly what @Heike mentioned. I noticed that for some stylesheets there are keyboard shortcuts e.g. Cmd+7 for text, and I was wondering how to edit the stylesheets to add my own shortcuts, in particular for the math cells. – Jim Lim Jan 26 '12 at 18:14

I suppose the keyboard shortcuts, or acceleration keys in general, are hardcoded into the Mathematica application so defining new ones might be impossible for now. You can review them by searching for "KeyboardShortcutListing" at Mathematica's help system. Of course you can always programmatically create cells of the type you want.

share|improve this answer
Unfortunately, this is not true. You can define shortcuts in the file: See and – Sjoerd C. de Vries Jan 27 '12 at 18:29
This is anything but unfortunately! Thank you very much for the correction! (Actually my statement is half-true: the solution for defining new ones is a hack and not a thing you can do programmatically from inside the Mathematica like with the tokens, that's what I meant with saying hardcoded, anyway your remark is more than valid - we should thing outside the box once in a while ;) ) – Spawn1701D Jan 28 '12 at 16:39

This information is set in the style definitions for the cell types in the stylesheet that you are using.

Look up MenuCommandKey in your help, this is the option that you use. To see how this is set in the example, select the MyTitle cell, and then use the menu item Cell > Show Expression.

Then to get this to work, you need a stylesheet where you change the definition for the desired cell type to include this option. You can edit the stylesheet for a particular notebook from the format menu.

Stylesheet notebooks can be saved, and then if you use the File > install menu item you can make a stylesheet available across all notebooks.

share|improve this answer
But "Equal Symbol Aligned Math Cell" is not in the menu. – Jim Lim Jan 27 '12 at 18:02
After a little more checking its because that isn't actually a type of cell. Its just a text cell with a specific box structure and placeholder added into it. Therefore, the above will work to reassign the keys to other styles, but not to make this work, and I don't know if you can add a key shortcut to insert expressions in this way. – Adam Berry Jan 27 '12 at 20:36
The different StyleSheets that come with mma have different cell types available, e.g. JournalArticle. So, either the cell types have to already exist, or they can be created. Do you know which it is? – rcollyer Jan 27 '12 at 20:55
@AdamBerry yes, you are right... – Jim Lim Jan 28 '12 at 1:54

With a little help from

I came up with (having no idea why I could not use F3, on Windows, but F4 works) :

Item[KeyEvent["F4"], FrontEndExecute[FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
    GridBoxAlignment->{"Columns" -> {{"="}}}]}},
    GridBoxItemSize->{"Columns" -> {{Scaled[0.96]}}}], TraditionalForm]]]], "Text"], After]; 
    FrontEnd`NotebookFind[FrontEnd`InputNotebook[], "\[Placeholder]", Previous,CellContents]]]

which I inserted at the end of

Maybe it is a good idea to make a backup-copy of your, and remember: the copy should not end with .tr

share|improve this answer
What would the corresponding entry in an init.m be so that such a new key event would automatically be added at startup and yet you would not have to modify – murray Jan 29 '12 at 1:21

This isn't an answer to the original question, but rather explains why I don't use the “Equal Symbol Aligned Math Cell”. Note that I used to use the writing palette to create aligned math, but now I use the solution presented below. And I have some really large notebooks full of typeset maths/physics using this solution.

The Writing Assistant palette contains the button to create an “Equal Symbol Aligned Math Cell” which is actually a GridBox embedded inside of a "Text" cell. Specifically, it creates

         GridBoxAlignment -> {"Columns" -> {{"="}}}]}}, 
      GridBoxItemSize -> {"Columns" -> {{Scaled[0.96]}}}], 
     TraditionalForm]]]], "Text"]

I find this a little hacky and (as mentioned in the comments to the question) a bit unstable.

Luckily, Mathematica has a simpler alignment system built-in. Just insert a DisplayFormula cell and set the cell alignment from Left to AlignmentMarker using the Format ► Text Alignment ► On AlignmentMarker. Then you can set the formula to align where ever you want, using \[AlignmentMarker\], which can be entered using ⁝am⁝

  RowBox[{"a", "\[AlignmentMarker]", "=", "b"}], "\[IndentingNewLine]", 
  RowBox[{RowBox[{"c", "+", "d"}], "\[AlignmentMarker]", "=", "e"}]}], 
 "DisplayFormula", TextAlignment->AlignmentMarker]

which in TraditionalForm looks like:

Example alignment

Then, if you want, you can make a new cell style that uses this option (or modify an existing style) and assign that style a MenuCommandKey as described in here or in Adam's answer to this question.

share|improve this answer

Your Answer


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.