Is it possible to typeset systems of equations in Mathematica, and if so, how can I do it using a big left bracket as one could in LaTeX with \left\{ ... \.?

I know this is possible using the Piecewise, but is there a special command for this?


3 Answers 3


You can implement your own environment like Piecewise

Equations /: MakeBoxes[Equations[eqs_], TraditionalForm] := 
     RowBox[{"\[Piecewise]", GridBox[{MakeBoxes[#, TraditionalForm]} & /@ {##} & @@ eqs]}]

TeXForm[expr] is equivalent to TeXForm[TraditinalForm[expr]] so I define custom formatting for TraditinalForm of my function Equations

eqs = {2 x + 3 y == 6, 4 x + 9 y == 15}

Equations[eqs] // TraditionalForm

enter image description here

Equations[eqs] // TeXForm
   2 x+3 y=6 \\
   4 x+9 y=15

$\begin{cases} 2 x+3 y=6 \\ 4 x+9 y=15 \end{cases}$

Equations also works with another definition of the system of equations

eqs = 2 x + 3 y == 6 && 4 x + 9 y == 15

Equations[eqs] // TeXForm

$\begin{cases} 2 x+3 y=6 \\ 4 x+9 y=15 \end{cases}$

Update: you can easily modify Equations to produce aligned equations

Equations /: 
 MakeBoxes[Equations[eqs_, Alignment -> True], TraditionalForm] := RowBox[{"\[Piecewise]", 
   MakeBoxes[#, TraditionalForm] &@ Grid[{#1, "=", #2} & @@@ {##} & @@ eqs, 
     Alignment -> {{Right, Center, Left}}]}]

eqs = {2 x == 6, 4 x + 9 y == 15, z == 5}

Equations[eqs, Alignment -> True] // TraditionalForm

enter image description here

  • $\begingroup$ Thank you for your good answer! Though, I have never encountered the symbol /: before, could you point me to what it means? Thanks! $\endgroup$
    – Gabriel
    Commented Oct 10, 2013 at 21:02
  • $\begingroup$ @Gabriel /: with := is TagSetDelayed. See also What the @#%^&*?! do all those funny signs mean? $\endgroup$
    – ybeltukov
    Commented Oct 10, 2013 at 21:05
  • $\begingroup$ Why not use the built-in align-to-character option? DisplayForm@RowBox[{StyleBox["{", SpanMaxSize -> Infinity], Column[eqs, Alignment -> "\[Equal]"]}] $\endgroup$ Commented Feb 2, 2015 at 10:28
  • $\begingroup$ @IstvánZachar Nice point, but it doesn't work in TranditionalForm as well as TeXForm. $\endgroup$
    – ybeltukov
    Commented Feb 2, 2015 at 12:17
  • $\begingroup$ True, I've just realized that myself. +1 for your more robust solution! $\endgroup$ Commented Feb 2, 2015 at 13:01

I interpreted the question as requiring this to be done in text cells for typesetting rather than for input/output. The way to do this in a text cell is to start with the parenthesis on the left then add some grid boxes via Insert > Table/Matrix

enter image description here

From here you want to change the SpanMaxSize option via either the option inspector or add the option directly to the cell: SpanMaxSize->Infinity

enter image description here

enter image description here

Alternatively you could use \[Piecewise] instead of "{"

Next add some equations:

enter image description here

The problem now is that the equations are not aligned. I'm assuming here that you would want them aligned on the "=" sign. So place the cursor next to the "=" in each equation and type Esc am Esc or alternatively \[AlignmentMarker]. So you now have alignment markers in all equations. The final step is to tell your grid to align at the alignment marker. In most usages of \[AlignmentMarker] can you do this easily via the menu Format > TextAlignment > On AlignmentMarker. However in this case I could only get this to align via setting GridBoxOptions for the cell in the option inspector and setting GridBoxAlignment to align at the \[AlignmentMarker].

enter image description here

If I was doing this regularly I would create a specific style (which could include equation numbering) in my stylesheet with the appropriate GridBoxOptions set as well as SpanMaxSize->Infinity.

 GridBoxOptions->{GridBoxAlignment->{"Columns" -> {{"\[AlignmentMarker]"}}, "Rows" -> {{"\[AlignmentMarker]"}}}}]
  • $\begingroup$ There really should be a built-in much easier way to create such aligned, multi-line displays! $\endgroup$
    – murray
    Commented Oct 11, 2013 at 16:09
  • $\begingroup$ @murray this is actually very easy if you are not using gridboxes. $\endgroup$ Commented Oct 12, 2013 at 0:11
  • $\begingroup$ Compare the ease of creating multi-line alignment in TeX by just inserting & within the alignment environment, on the one hand, with the verbosity required in Mathematica to type \[AlignmentMarker] or even its keyboard shortcut equivalent, on the other hand. $\endgroup$
    – murray
    Commented Oct 12, 2013 at 14:13
  • $\begingroup$ And contrast the ease in TeX of creating a multi-line spanning brace, by typing \left\{ and \right., on the one hand, with the above-mentioned methods for doing the same thing in Mathematica. $\endgroup$
    – murray
    Commented Oct 12, 2013 at 14:17
  • $\begingroup$ @murray a matter of personal preference. I don't find typing Esc am Esc to be a big deal. Also this method keeps the equation "together" whereas the accepted answer splits the equation into 3 columns with "=" the centre column. $\endgroup$ Commented Oct 12, 2013 at 21:58

It depends upon the place you want it in. The answers above assumed by default that you need them in an output cell. I utilize Mathematica (among other purposes) to write documents and heavily use such cell as DisplayFormula and DisplayFormulaNumbered. In these cases you may employ instruments collected in the Writing Assistant.

As soon as your cursor is in the DisplayFormula or DisplayFormulaNumbered cell go to Menu/Palette/Wtiting Assistant/Typesetting And chose the button entitled "Piecewise defined function" on this tab. This will insert into your cell the left curly bracket embracing 2x2 slots to fill in. If you need to have three of them, mark one of the slots and press the button entitled "Column" in the same tab. You will see the title of the button, if you place the cursor over the button, and the tab name after you collapse the tab.

There is one drawback in this approach: the symbols have a somewhat smaller appearance. If this is not acceptable you might increase their size manually. Mark the corresponding formula, go to Menu/Format/Size and play with the sizes.

The alternative approach has been discussed here some time ago. Unfortunately I do not recall who proposed for this purpose a solution: the brackets that automatically stretch. Below find a slightly modified version of the palette proposed in that discussion:

            RowBox@Insert[#, "\[SelectionPlaceholder]", 2], 
           FontSize -> 14, SpanMaxSize -> Infinity]] &, 
        Most@Tuples[{{"[", "{", "(", ""}, {"]", "}", ")", ""}}]], 4]],
      Spacings -> {0, 0}]]}], WindowTitle -> "Brackets"]

After evaluating this code a palette will appear. By pressing the corresponding button in the palette one creates a slot with the left (ot right, or both) curly bracket (or another bracket). Place cursor into the slot and go to Menu/Palette/Wtiting Assistant/Typesetting and choose the button "Column" few times until you get a required structure.

  • $\begingroup$ The only advantage I see in using that palette over the "standard" method proposed by @Mike Honeychurch is that it automatically takes care of the SpanMaxSize specification. But it still doesn't help with aligning on equal signs, or anything else, in the successive rows. $\endgroup$
    – murray
    Commented Oct 11, 2013 at 16:21
  • $\begingroup$ @murray This palette is not the all-problems-solution, but a good-to-know one. I find it helpful. $\endgroup$ Commented Oct 14, 2013 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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