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.
-
2$\begingroup$ It may be possible like this: mathematica.stackexchange.com/questions/19135/… $\endgroup$– SzabolcsCommented Apr 24, 2013 at 0:08
-
$\begingroup$ @Szabolcs thank you. I'll have to tinker with this, but this seems like a good place to start. $\endgroup$– Black MilkCommented Apr 25, 2013 at 2:00
-
1$\begingroup$ 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. $\endgroup$– SzabolcsCommented Apr 25, 2013 at 2:41
-
$\begingroup$ @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? $\endgroup$– Black MilkCommented Apr 25, 2013 at 3:20
-
1$\begingroup$ 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. $\endgroup$– Alexei BoulbitchCommented Apr 25, 2013 at 7:04
1 Answer
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[
FrontEnd`AddMenuCommands["DuplicatePreviousOutput",
{Delimiter,
MenuItem["Centered Math Cell",
FrontEnd`KernelExecute[
nb=SelectedNotebook[];
SelectionMove[nb,After,Cell];
NotebookWrite[nb,
Cell[
TextData[
Cell[BoxData[FormBox[
GridBox[{{
GridBox[{{"\[Placeholder]"}},
GridBoxAlignment->{
"Columns"->{{"Center","Left"}}
}]
}},
GridBoxItemSize->{
"Columns"->{{Scaled[0.96]}}
}],
TraditionalForm]]]],
"Text",
CellChangeTimes->{3.652027841906773*^9}]];
SelectionMove[nb,Previous,Cell];
SelectionMove[nb,Before,CellContents];
FrontEndExecute[FrontEndToken[nb,"MoveNext"]];
FrontEndExecute[FrontEndToken[nb,"MoveNext"]];
FrontEndExecute[FrontEndToken[nb,"MoveNext"]];
],
MenuKey["c",
Modifiers->{"Control"}
],
System`MenuEvaluator->Automatic]
}]];
-
$\begingroup$ 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 $\endgroup$ Commented Sep 28, 2015 at 3:02