3

I write my own stylesheet. I use GridBox and GridBoxOption to edit the environment of EquationNumbered, in which, I set

Cell[StyleData["EquationNumbered"],
TextAlignment->Center,
FontSize->14,
GridBoxOptions->{AllowScriptLevelChange->False,
GridBoxAlignment->{
  "Columns" -> {{"\[AlignmentMarker]"}}, 
"Rows" -> {{"\[AlignmentMarker]"}}}}]

Now, when I choose the style of EquationNumbered, the multi-line formula will align to the alignmentmarker that I set.
But,when I do not set the alignmentmarker, they will aligned to the right instead of the center as usual. How can I fix this problem.
Without AlignmentMarker

AchillesJJ
  • 425
  • 2
  • 8
  • Want to know the solution too. But I suspect it's just not possible... (Or maybe there is a undocumented usage to specify the priorities of alignments?) – Silvia Nov 22 '14 at 09:15

1 Answers1

1

Extended comment.

1 You need to show the Grid/Matrix so we can see what you are trying to do.

2 If you want to align to the right you do not need to use alignment markers (hence point #1).

3 There is this example in the docs:

Grid[{{1.234, 12.34}, {123.4, 1234.}, {1234, 1.234}},Alignment -> "."]

where you would obviously replace "." with alignment marker

4 An alternative to programmatic generation of alignments is simply to create your grid/matrix and insert alignment markers Esc am Esc, then Format > Text Alignment > On Alignment Marker. e.g

Cell[TextData[Cell[BoxData[{
 FormBox[
  RowBox[{"x", "=", "\[AlignmentMarker]", "y"}], TraditionalForm], "\[IndentingNewLine]", 
 FormBox[
  RowBox[{
   RowBox[{"x", "+", "7"}], "=", "\[AlignmentMarker]", 
   RowBox[{"z", "-", "1234567"}]}], TraditionalForm]}],
 TextAlignment->AlignmentMarker,
 FormatType->"TraditionalForm"]], "Text"]

enter image description here

Mike Honeychurch
  • 37,541
  • 3
  • 85
  • 158
  • Thanks. I know everything you suggest. But my problem is that how can set the GridBoxAlignment in GridBoxOptions so that the grid elements shall align to the center when I do not set any alignmentmarker while align to the marker when I set it explicitly. Thank you. – AchillesJJ Nov 21 '14 at 06:28
  • I'm searching for answer to the same thing. @AchillesJJ – B flat Sep 26 '15 at 11:13
  • A workaround is to set the stylesheet to center and then create a shortcut to override it at the cell level using a shortcut key. This can be done with celleventactions. – B flat Apr 04 '22 at 17:43