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.

  • $\begingroup$ 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. $\endgroup$
    – rcollyer
    Jan 26, 2012 at 4:22
  • 5
    $\begingroup$ @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. $\endgroup$
    – Heike
    Jan 26, 2012 at 9:25
  • $\begingroup$ @Heike, I never use the writing assistant. So, thanks. But, again what type of shortcut? $\endgroup$
    – rcollyer
    Jan 26, 2012 at 11:10
  • 2
    $\begingroup$ @rcollyer neither do I but google came to the rescue. $\endgroup$
    – Heike
    Jan 26, 2012 at 11:24
  • 1
    $\begingroup$ 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. $\endgroup$
    – James Lim
    Jan 26, 2012 at 18:14

4 Answers 4


With a little help from http://web.ift.uib.no/~szhorvat/mmatricks.php

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 KeyEventTranslations.tr

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

  • 1
    $\begingroup$ 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 KeyEventTranslations.tr? $\endgroup$
    – murray
    Jan 29, 2012 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.

  • $\begingroup$ I think the nice thing about using a grid is that you can use alignment markers in more than one column. This is especially useful in textbooks. $\endgroup$
    – B flat
    Nov 19, 2016 at 6:28

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.

  • $\begingroup$ But "Equal Symbol Aligned Math Cell" is not in the menu. $\endgroup$
    – James Lim
    Jan 27, 2012 at 18:02
  • 1
    $\begingroup$ 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. $\endgroup$
    – Adam Berry
    Jan 27, 2012 at 20:36
  • $\begingroup$ 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? $\endgroup$
    – rcollyer
    Jan 27, 2012 at 20:55
  • $\begingroup$ @AdamBerry yes, you are right... $\endgroup$
    – James Lim
    Jan 28, 2012 at 1:54

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.

  • 9
    $\begingroup$ Unfortunately, this is not true. You can define shortcuts in the file: KeyEventTranslations.tr. See stackoverflow.com/a/5605423/615464 and stackoverflow.com/q/4209405/615464 $\endgroup$ Jan 27, 2012 at 18:29
  • $\begingroup$ 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 ;) ) $\endgroup$
    – Spawn1701D
    Jan 28, 2012 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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