Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

What's the cell option (or other technique) to use to stretch the curly brace that one typically uses in traditional math to group several displayed equations? Like this:

Mathematica graphics

And is there any better way of getting the vertical alignments of the equations that simply inserting a 3-column table?

share|improve this question
    
You could try using Piecewise (ESC pw ESC). It doesn't look exactly the same though. –  Szabolcs Mar 11 '13 at 21:08
    
I know there is some such option -- something to do with "span" I think -- but I cannot find it now in Option Inspector. I even recall that somebody at WRI wrote to MathGroup about this several years ago. –  murray Mar 11 '13 at 21:13
3  
I found the option: SpanMaxSize. If you change its value from the default Automatic to Infinity, then the opening brace will be stretched so as to enclose all the rows of the table. –  murray Mar 11 '13 at 21:56
1  
@murray Your approach works very well when used in a Style wrapper for a FormBox containing the brace. This should be an answer. –  Jens Mar 11 '13 at 23:40
    
@Jens: I didn't actually us a Style wrapper for a FormBox (I hate programming using boxes!) Rather, I used the option for the entire cell. For my purposes that sufficed, although I can envision others where it would be too crude an approach. –  murray Mar 12 '13 at 4:18
show 1 more comment

5 Answers

up vote 13 down vote accepted

Here is one of my personal examples:

enter image description here

How I did it:

  • Ctrl 9 (inline cell); doesn't work on/as the first case/letter of a Text cell (needs at leas a space)
  • esc pw esc
  • copy paste inside the pw element the output of something like Grid[{{a}, {b}, {c}}, Alignment -> Left]
  • substitute the content a, b, c with your content

Then you can reuse it... (I have an entire book written with these structures)

Your example, with the same technique:

enter image description here

You can obviously tweak it a lot with Spacings, ItemSize, Style, etc

And you can even go to the extreme of:

  • Ctrl 9
  • esc pw esc
  • write inside the pw element Grid[{{HoldForm[x-1=t]},{HoldForm[y=1-t^2]}},Alignment->"="]
  • select the Grid[...], and choose evaluate in place (from the context menu)

enter image description here

...and editing it holds the alignment specification to the "=" sign!

And for the slightly extra extension of the brackets:

enter image description here

It is also possible to simulate an align to different characters, although the only way I found is a little messier. There are invisible characters available in Mathematica. Be careful because they are... well... invisible. This means that you can mess things if they end up in the middle of computations... I'm going to demonstrate the technique with the esc am esc (aka \[AlignmentMarker]).

Another problem with this technique is that, since there is an invisible thing in the middle of the expression, the parser complains about it. So, I entered everything as strings (there's probably a better way of avoiding it). But, entering everything as string, brakes special characters formating during evaluation in place... But everything ends up working after editing it. Here is a way of doing:

  • Ctrl 9
  • esc pw esc
  • write inside the pw element Column[{Null,Grid[{{"test\[AlignmentMarker]=b"},{"bigger test\[AlignmentMarker]>b"}},Alignment->"\[AlignmentMarker]"],Null},ItemSize->{Automatic,{0.1,{02.},0.1}}]
  • select the Column[...], and choose evaluate in place (from the context menu)

enter image description here

  • edit to your needs (including the erasing of the "'s, but, while editing, don't erase your markers!)

enter image description here

share|improve this answer
    
I selected this as the answer because it seems to "kill two birds with one stone": to extend the brace and to align things on the equal sign. It even works to align on the equal sign when you have merely a series of equalities broken across lines (with nothing preceding the = on succeeding lines). However, it will not work if you have inequalities as well as qualities on the several lines; apparently Alignment won't let you specify more than a single character on which to align in a Grid. (I would love to be proved wrong here.) –  murray Mar 12 '13 at 15:27
    
@murray I just added a way of aligning to different characters (not exactly true, but I think it gives what you want) –  P. Fonseca Mar 12 '13 at 20:26
add comment

For convenient typesetting, I would use a palette in this case:

CreatePalette[
 Column[{
   "Extensible Brackets",
   Style[
    Grid[
     Join[
      Partition[
       Map[PasteButton[
          Style[RawBoxes@
            RowBox@Insert[#, "\[SelectionPlaceholder]", 2], 
           SpanMaxSize -> Infinity]] &, 
        Most@Tuples[{{"[", "{", ""}, {"]", "}", ""}}]
        ], 4],
      Map[
       PasteButton[
         RawBoxes[#]] &, {{UnderscriptBox["\[SelectionPlaceholder]", 
          "︸"], UnderscriptBox["\[SelectionPlaceholder]", "︶"], 
         UnderscriptBox["\[SelectionPlaceholder]", "\[UnderBracket]"],
          UnderscriptBox["\[SelectionPlaceholder]", "_"]},
        {OverscriptBox["\[SelectionPlaceholder]", "︷"], 
         OverscriptBox["\[SelectionPlaceholder]", "︵"], 
         OverscriptBox["\[SelectionPlaceholder]", "\[OverBracket]"], 
         OverscriptBox["\[SelectionPlaceholder]", "_"]}}, {2}]
      ]
     , Spacings -> {0, 0}], FontSize -> 8]
   }]
 ]

palette

All of these templates show some combination of delimiters that can be extended, either vertically or horizontally. To use the vertical unbalanced delimiters, you should normally first make sure that you're in a TraditionalForm environment so that the parser doesn't try to balance the brackets. This is based on my interpretation that you want to use these braces purely in typesetting and not as a function such as Piecewise.

As for the vertical alignment, a palette can also help with that. Have a look at the plain Row and Column templates in the Basic Math Assistant palette, for example.

Usage examples

Typesetting vertically stretched delimiters would realistically happen mostly in a DisplayFormula environment. This is what you see here (numbered equations):

usage

To get these forms, just press the corresponding template button in the palette and then enter the column into the black square indicating the placeholder. Alternatively, highlight an existing column and press the button to apply the delimiters.

Likewise, you can do these things in a text cell by opening an inline cell as one always does for equations, and then proceeding as above:

text cell

share|improve this answer
    
It looks alright in DisplayFormula style. (I don't know why I didn't try that.) +1 –  Mr.Wizard Mar 12 '13 at 5:26
    
I added a picture showing that it also works in an inline cell. Hope that clarifies it. –  Jens Mar 12 '13 at 5:30
add comment

I would use a formatting function like this:

Format[bracket[obj_]] :=
  Style[DisplayForm @ RowBox[{"{", obj}], SpanMaxSize -> Infinity]

Or with MakeBoxes, which may be preferable:

MakeBoxes[bracket[obj_], fmt_] :=
  StyleBox[RowBox[{"{", obj ~ToBoxes~ fmt}], SpanMaxSize -> Infinity]

(You don't need both definitions at the same time.)

Then it will left-bracket whatever expression you give it:

Grid[Binomial ~Array~ {5, 5}] // bracket

Mathematica graphics

{"one", "two", "three"} // Column // bracket

Mathematica graphics

Plot[Sinc[x], {x, 0, 10}] // bracket

Mathematica graphics


As a separate answer to the second part of your question you can use the Alignment option.
This works with both Strings and held expressions:

Column[{"x = 1+t", "two = 1-t^2", "three = 1+t^3"}, Alignment -> "="]

Column[
 HoldForm /@ Unevaluated@{x = 1 + t, two = 1 - t^2, three = 1 + t^3}, 
 Alignment -> "="
]

Mathematica graphics

Combined with bracket:

% // bracket

Mathematica graphics

share|improve this answer
    
Nice. Is it possible, perhaps by some minor tweak or use of an alignment marker, to align the equal sign of equations of varying lengths? –  David Carraher Mar 12 '13 at 2:31
    
@David I guess I should add something about that to my answer, but I saw it as a side matter. –  Mr.Wizard Mar 12 '13 at 2:36
1  
+1 Simple, nice. –  Vitaliy Kaurov Mar 12 '13 at 5:31
    
This answer, like some others, requires what seems to be an inordinate amount of coding for what ought to be a simple, straightforward text-entry issue about very basic mathematical typesetting. (Makes one wonder how much the Mathematical front-end designers really know about mathematical typesetting.) –  murray Mar 12 '13 at 15:30
    
Also, the alignment part of this answer won't handle the situation where you have some equalities and some inequalities. Any decent mathematical typesetting ought to allow alignment on characters that vary from one line to the next! –  murray Mar 12 '13 at 17:23
show 3 more comments

There are probably easier ways to do this, but nothing comes to mind at the moment:

CellPrint@
  Cell[
   BoxData[
    FormBox[
      GridBox[
      {
       {"\[Piecewise]", 
        GridBox[
         {
          {RowBox[{"x", "\[AlignmentMarker]=", "1", "+", "t"}]},
          {RowBox[{"y", "\[AlignmentMarker]=", "1", "-", SuperscriptBox["t", "2"]}]}
          },
         GridBoxAlignment -> {"Columns" -> {{"\[AlignmentMarker]"}}},
         GridBoxSpacings -> {"Rows" -> {Offset[0.2], {Offset[0.84]}, Offset[0.2]}}]
        }
       }, 
      GridBoxSpacings -> {"Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], 
      TraditionalForm
     ]
    ], "Output"
  ]
]

Mathematica graphics

Note that the alignment marker will become invisible once you have typed it. See also ref:Structural Elements And Keyboard Characters.

share|improve this answer
add comment

I have used Grid and the Piecewise symbol as follows:

TraditionalForm@
Grid[{{"Parametric equations = ", 
    Style[TraditionalForm@"\[Piecewise]", 
    FontSize -> 36], TraditionalForm[x == 1 + t], 
    0 < t < 1}, {SpanFromAbove, 
    SpanFromAbove, TraditionalForm[y == 1 + t^2], t >= 0}}, 
    Alignment -> {{Center, Center, Left, Center}, Center}]

which gives the following result:

enter image description here

Ideally I'd improve this in the following ways:

  1. Find a way to make the bracket less bold.
  2. Find a way to make the Grid's Alignment option align on the = character. For some reason this does not behave as I would expect. have
share|improve this answer
    
That answer won't meet my needs in that it hard-codes the font size of the brace-- which means that magnifying the notebook won't work properly resize the brace. –  murray Mar 12 '13 at 17:20
    
@murray Using magnifications should change the size of everything. Could you link an image of what you're seeing? –  Mr.Wizard Mar 15 '13 at 0:57
    
As an alternative, you can try the following: instead of using FontSize -> 36 to size the brace, you can use SpanMinSize -> 2, which spans the brace to twice the font size. The resulting brace looks more appealing, but it may also not scale up in the way you wish. @murray –  zentient Mar 15 '13 at 8:07
    
@Mr.Wizard: You're correct, that changing the magnification does change the brace's size, too, even when the FontSize is hard-coded. However, if I switch from Working screen environment to Presentation screen environment, the brace does not stretch to enclose the full height of the lines. –  murray Mar 15 '13 at 13:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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