Mathematica provide Algebraic Manipulate palette for simplifying expression. But the palette window will always stay on top, which is quite annoying.

Is is possible to customize mathematica's right click menu to add frequently used Simplify tools? In this way we can first select expressions, then right click on it and select simplifying operation. I think this is handier than palette.

  • $\begingroup$ it doesn't answer your question at the end but shows the way: How do I programmatically add to contextual menus? $\endgroup$ – Kuba Dec 10 '15 at 7:58
  • 2
    $\begingroup$ You can make that palette non-floating using SetOptions[First@Notebooks["AlgebraicManipulation"], WindowFloating -> False]. $\endgroup$ – Karsten 7. Dec 10 '15 at 8:45
  • $\begingroup$ @Karsten7. Sorry for the late reply. Actually, when it is non-floating, it is another kind of annoying when using the palette : ) $\endgroup$ – matheorem Dec 12 '15 at 13:57
  • $\begingroup$ @Kuba Thank you, Kuba. After reading that, still can't get it. Manipulating front-end option is still too complicated for my ability right now, sigh... $\endgroup$ – matheorem Dec 12 '15 at 14:03
  • $\begingroup$ So you want something like this, but for the commands of that palette? Do you really want to have all commands? The menu will get cluttered. To you want the same behavior as the palette has? Especially the in place evaluation is a questionable feature. $\endgroup$ – Karsten 7. Dec 12 '15 at 14:21

Adding the functionality of the Algebraic Manipulate palette to the context menu ("right click menu") of Mathematica

The commands of the Algebraic Manipulation palette are converted into MenuItems, that will mainly use the FrontEnd, with

MenuItem[#[[1, 1]], FrontEndExecute[{
      FrontEnd`NotebookApply[FrontEnd`InputNotebook[], #, All], 
      FrontEndToken["Evaluate"]}]] & /@ 
  Import[FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "Palettes", 
      "Other", "AlgebraicManipulation.nb"}]][[1, 1, 1, 1, 1, All, 1, 1]] // InputForm

One can switch to Full Screen by pressing F12 and back again with F12, to make sure the output is formated in a way that is convenient for the next steps. If, for example, ones monitor is to small, one can Copy As ► Plain Text the output and add the line breaks manually later.
In both cases any ManuItem one doesn't want to have in the context menu should be removed from the outputted list.

The content of the context menu is specified in the file

FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "TextResources", 

This file can be edited with an editor (e.g. Notepad++), but a backup copy should be created first.

To open this file from within Mathematica

 FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "TextResources", 

can be used.

The context for inputs starts with "Input" -> {. To add a new menu entry after the entries related to Evaluate

Menu["&Algebraic Manipulate",


can be copied into a new line created after the Delimiter of that section.

Now one only has to replace the created empty list with the list of MenuItems constructed from the palette entries, save the ContextMenus.tr file and restart Mathematica.


  • $\begingroup$ But there seems an error in the column version, since directly copy as plain text have no commas between each MenuItem, if we pasted it directly into ContextMenus.tr, mathematica is unable to start $\endgroup$ – matheorem Dec 14 '15 at 5:23
  • $\begingroup$ @matheorem Thanks for pointing that out. I removed the column version, as it is more error-prone and presumably not really helpful. $\endgroup$ – Karsten 7. Dec 14 '15 at 6:50

Converting the Algebraic Manipulation palette into a DockedCells:

CurrentValue[EvaluationNotebook[], DockedCells] = 
  Append[MapAt[Partition[Flatten[#], 9] &, 
    Import[FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "Palettes", 
        "Other", "AlgebraicManipulation.nb"}]][[1, 1]], {1, 1, 1}], 
   ButtonBoxOptions -> {BaseStyle -> "Evaluate"}];

enter image description here

This DockedCells can be customized further. For example, if you only need two buttons Expand and Simplify, then Change Partition[Flatten[#], 9] & to {Flatten[#][[{1, 8}]]} & to select only the first and 8th button for the dock.

  • $\begingroup$ You are awesome! This implementation is really great ! I accept your answer. BTW, would you like to add a right click menu version? I know you also have experience on this kind of implementation. That will make the answer complete. : ) $\endgroup$ – matheorem Dec 13 '15 at 1:57
  • $\begingroup$ @matheorem I added a right click menu version as another answer, as I'm having some ideas on how to improve this DockedCells that I may add to this answer together with some explanations some time. $\endgroup$ – Karsten 7. Dec 13 '15 at 18:17
  • $\begingroup$ As I said before, I wish I could accept both answer. But now I decided to accept your "right click" version, since it works great and is what I exactly asking for in the question. I hope you don't mind about this. Finally, I am really looking forward to your newer version of DockCells in the future : ) $\endgroup$ – matheorem Dec 14 '15 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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