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

I've been typesetting in mathematica and would like to know if it is possible to use a keyboard shortcut to place a centered math cell or equation symbol aligned math cell in my document without having to use the writing assistant.

share|improve this question
It may be possible like this:… – Szabolcs Apr 24 '13 at 0:08
@Szabolcs thank you. I'll have to tinker with this, but this seems like a good place to start. – Black Milk Apr 25 '13 at 2:00
The basic steps would be: in the style editor, choose the style that you want to add as shortcut to from the dropdown. It'll insert a cell. Select the cell and press Control-Shift-E to show its structure. Add MenuCommandKey -> "8" to the end to make it possible to insert it with Alt-8 (Command-8 on Mac). Note that 8 is taken by code style cells, so you'll need to edit those too and put MenuCommandKey -> None in their definition. Ask if you need more help. I haven't played with your specific example, but I did do this for other styles. – Szabolcs Apr 25 '13 at 2:41
@Szabolcs I've tried your method with other styles and it works perfectly. However, I don't know how to pull up the style definitions for a centered math cell. Is there a way to find this? – Black Milk Apr 25 '13 at 3:20
If you choose the JournalArticle StyleSheet for your typesetting, you will have such a hot key automatically: Alt+5 for a centered equation line style and Alt+6 for a numbered equation. – Alexei Boulbitch Apr 25 '13 at 7:04

1 Answer 1

up vote 1 down vote accepted

Yes...just figured this out. Place this in an init.m file in any path called my Mathematica. This is for a center lined math cell, but you can also do the same for Marker Aligned, Equal Aligned or whatever you want. In my code below, the first column aligns to the center and next aligns in the left. You can change this however you want. Just replace "center" or "left" with the appropriate value. Hope this helps. To use the shortcut press control+c or defined it how you please below. It also lists the shortcut in the insert menu with the appropriate shortcut labeled in case you forget. Hope this helps.

FrontEndExecute[FrontEndAddMenuCommands["DuplicatePreviousOutput",{Delimiter,MenuItem["Centered Math Cell",FrontEndKernelExecute[nb=SelectedNotebook[]; SelectionMove[nb,After,Cell]; NotebookWrite[nb,


]; SelectionMove[nb,Previous,Cell]; SelectionMove[nb,Before,CellContents]; FrontEndExecute[FrontEndToken[nb,"MoveNext"]]; FrontEndExecute[FrontEndToken[nb,"MoveNext"]]; FrontEndExecute[FrontEndToken[nb,"MoveNext"]];


share|improve this answer
You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this this meta Q&A helpful – Michael E2 Sep 28 at 3:02
@MichaelE2 thank you! I did what you asked but still didn't format into the code cell appropriately. Maybe I need to delete spacing. I'll work on this. Thank you! – Michael McCain Sep 28 at 3:07
Oh wait... I got it. Write the code first then highlight. I did it in reverse. @MichaelE2 – Michael McCain Sep 28 at 3:08

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.