1
$\begingroup$

I would like to create a palette with three buttons:

  1. Inserts an alignment marker at the current cursor insertion point (i.e., inserts the character \[AlignmentMarker]).
  2. Performs the menu function Format -> Text Alignment -> On AlignmentMarker.
  3. Combines items 1 and 2 into one action.

There don't appear to be Front End Tokens for these functions, and from the advice I have seen on other palette-creation topics (here, for example), it's a complicated process. I am afraid I simply didn't understand the mechanics of what was suggested.

How do I do it?

$\endgroup$
1
+150
$\begingroup$

This works on DisplayFormula cells and satisfies all three requirements. Hope this helps.

    CreatePalette[{
   
   Button["Insert Alignment Marker", 
    NotebookWrite[InputNotebook[], "\[AlignmentMarker]"]],
   
   Button["Turn on Alignment",
    
    SelectionMove[InputNotebook[], All, Cell];
    SetOptions[NotebookSelection[InputNotebook[]], 
     TextAlignment -> AlignmentMarker];],
   
   Button["Turn off Alignment",
    
    SelectionMove[InputNotebook[], All, Cell]; 
    SetOptions[NotebookSelection[InputNotebook[]], 
     TextAlignment -> Inherited];],
   
   Button["Insert Alignment Marker and Turn on",
    NotebookWrite[InputNotebook[], "\[AlignmentMarker]"];
    SelectionMove[InputNotebook[], All, Cell]; 
    SetOptions[NotebookSelection[InputNotebook[]], 
     TextAlignment -> AlignmentMarker];]
   
   }];
$\endgroup$

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.