Function Repository Resource:

# GraphicsBrace

Create a graphical brace object

Contributed by: Jaroslav Kysela
 ResourceFunction["GraphicsBrace"][label,leftpt,rightpt] creates a brace graphical object annotated by label that stretches from point leftpt to point rightpt. ResourceFunction["GraphicsBrace"][label,leftpt,rightpt,vertlen] creates the brace with edge lines of length vertlen. ResourceFunction["GraphicsBrace"][{label,offset},leftpt,rightpt,vertlen] creates the brace with the label offset by the distance offset from the brace cusp. ResourceFunction["GraphicsBrace"][{label,offset,relpos},leftpt,rightpt,vertlen] creates the brace with the label and cusp displaced by distance relpos from the left edge. ResourceFunction["GraphicsBrace"][{label,{offset,textoffset},relpos},leftpt,rightpt,vertlen] creates the brace with the textual label using additional offset textoffset.

## Details and Options

ResourceFunction["GraphicsBrace"] can be used in Graphics. The brace object can be used to annotate different parts of a graphical scene.
The following figure depicts the meaning of some of the most important arguments and options:
The label offset scales with the size of Graphics to preserve the relative position of the label and the brace.
The anchor points can be specified either as Point objects or as {x,y} coordinate pairs.
When the first argument is set to Nothing, None or Missing[], no label is produced.
The following options can be given:
 RotateLabel True whether to rotate the label; if so, how much RoundingRadius 0.02 rounding radius of the joints of the brace curve Direction Automatic direction in which the edges extend from the anchor points
The option RotateLabel can be set to the following values:
 whether to rotate the label or not α rotate the label through a fixed angle {False,α} rotate the label through a fixed angle {True,α} add a fixed angle to the automatically calculated rotation
The option RoundingRadius can be set to the following values:
 r set the radius of the joints {rout,rin} set the radius of the outer joints and the inner joints, i.e. the cusp, independently
The option Direction can be set to the following values:
 Automatic adjust the direction according to the anchor points α direction given by an angle {x,y} direction given by a vector

## Examples

### Basic Examples (7)

Annotate a graphical object with an underbrace:

 In[1]:=
 Out[1]=

Use multiple annotations:

 In[2]:=
 Out[3]=

By swapping the order of the two anchor points, create an overbrace:

 In[4]:=
 Out[5]=

Adjust the position and rotation of the label:

 In[6]:=
 Out[7]=

By default, the brace automatically adjusts its rotation to the annotated object:

 In[8]:=
 Out[9]=

Style the labels as well as the curves:

 In[10]:=
 Out[11]=

Use Point objects directly as anchor points:

 In[12]:=
 Out[14]=

### Scope (10)

#### Label content (2)

Use the underbrace with no label:

 In[15]:=
 Out[15]=

The label does not have to be text:

 In[16]:=
 Out[16]=

#### Label position (3)

Position the label further from the cusp:

 In[17]:=
 Out[18]=

The offset is taken in the direction of the cusp:

 In[19]:=
 Out[19]=

The textual label can be offset in the horizontal and vertical directions using an additional argument:

 In[20]:=
 Out[20]=

Any specification that is valid for the third argument of Text is also allowed. Here, an Offset is used:

 In[21]:=
 Out[21]=

Specify the relative position of the label with respect to the edges:

 In[22]:=
 Out[22]=

#### Curve dimensions (2)

Make the edges longer:

 In[23]:=
 Out[23]=

Specify the relative position of the cusp with respect to the edges:

 In[24]:=
 Out[24]=

#### Presentation (3)

Choose different colors, thicknesses, etc. for the curve:

 In[25]:=
 Out[25]=

Choose different styles for the label:

 In[26]:=
 Out[26]=

Style both the curve and the label:

 In[27]:=
 Out[27]=

### Options (8)

#### Direction (3)

By default, the curve stretches between the two anchor points:

 In[28]:=
 Out[30]=

Specify explicitly the direction of the edges:

 In[31]:=
 Out[31]=

The direction can also be specified as a vector:

 In[32]:=
 Out[32]=

#### RotateLabel (3)

The label is by default parallel to the brace:

 In[33]:=
 Out[33]=

Disable rotation:

 In[34]:=
 Out[34]=

The angle can also be given explicitly:

 In[35]:=
 Out[35]=

The combination of both approaches yields an automatically rotated label with the explicitly given rotation offset:

 In[36]:=
 Out[36]=

 In[37]:=
 Out[37]=

The radius of the cusp and outer joints can be specified independently:

 In[38]:=
 Out[38]=

### Applications (2)

Make a technical drawing with proper physical units:

 In[39]:=
 Out[39]=

Describe the regions where a given function is monotonically increasing and decreasing:

 In[40]:=
 Out[41]=
 In[42]:=
 Out[42]=

### Properties and Relations (1)

GraphicsBrace can be used in Graphics the way that an underbrace is used in text:

 In[43]:=
 Out[43]=

### Possible Issues (5)

When the first argument is to be taken as a literal, wrap it in Inset:

 In[44]:=
 Out[44]=

When the other arguments are not numeric, no evaluation of GraphicsBrace takes place:

 In[45]:=
 Out[46]=
 In[47]:=
 Out[47]=

The label may be set too close to the cusp:

 In[48]:=
 Out[49]=

Position the label further from the cusp:

 In[50]:=
 Out[50]=

When the line segments are too small with respect to the rounding radii, undesired behavior occurs:

 In[51]:=
 Out[51]=

 In[52]:=
 Out[52]=

For an overbrace, the label is upside down:

 In[53]:=
 Out[53]=

Turn off the automatic rotation of the label:

 In[54]:=
 Out[54]=

### Neat Examples (2)

Use the brace as a graphics primitive for artistic drawing:

 In[55]:=
 Out[55]=

Annotate the side lengths of a dynamically changing triangle:

 In[56]:=
 Out[60]=

Jaroslav Kysela

## Version History

• 1.0.0 – 26 May 2021