Equations – How to Use Calligraphic Braces in Equation Environment

bracketsequations

Consider the following code:

\documentclass{article}
\usepackage{tikz}
\usepackage{array}
\usepackage{mathtools}

\begin{document}

\begin{equation}
  a(y)=\left\{
  \begin{array}{@{}ll@{}}
    0 & \text{if}\ y < 1 \\
    \frac{1}{2}\biggl[ 1 + sin\left(\frac{2 \pi}{\theta}\right) \biggr]  & \text{if}\ 1\leq y < 4 \\
    1 & \text{if}\ 4 \leq y < 5 \\
 \frac{1}{2}\biggl[ 1 - sin\left(\frac{2 \pi}{\theta}\right) \biggr]  & \text{if}\ 6 \leq y < 7 \\
    0 & \text{otherwise}
  \end{array}\right.
\end{equation}

\end{document}

The output is:

enter image description here

How to achieve the following calligraphic curly brace (The following image borrowed from here) offered by TikZ package, in equation environment:

enter image description here

A similar style was implemented for a matrix in this answer. I couldn't implement it for an equation.

Best Answer

I suspect that there is an elegant solution using the nicematrix package, but I haven't the experience of that to provide it. Here's a tikz solution that wraps the array environment in a tikz node and then decorates the left-hand edge with a brace.

\documentclass{article}
%\url{https://tex.stackexchange.com/q/627983/86}
\usepackage{tikz}
\usepackage{array}
\usepackage{mathtools}

\usetikzlibrary{tikzmark,decorations.pathreplacing,calligraphy}

\begin{document}
\begin{equation}
a(y)= \begin{tikzpicture}[baseline=(base)]
\node (array) {\(\displaystyle\begin{array}{@{}ll@{}} 0 & \text{if}\ y < 1 \\
\frac{1}{2}\biggl[ 1 + \sin\left(\frac{2 \pi}{\theta}\right) \biggr] & \text{if}\ 1\leq y < 4 \\
1 & \text{if}\ 4 \leq y < 5 \\
\frac{1}{2}\biggl[ 1 - \sin\left(\frac{2 \pi}{\theta}\right) \biggr] & \text{if}\ 6 \leq y < 7 \\
0 & \text{otherwise} \end{array}\)};
\path (array) +(0,-.5ex) coordinate (base);
\draw[decorate, decoration=calligraphic brace,ultra thick] (array.south west) -- (array.north west);
\end{tikzpicture}
\end{equation}
\end{document}

equation with calligraphic brace

Obviously, there are parameters to tweak to improve the look, such as line width and amplitude.

(Incidentally, this is exactly the use-case I was envisioning when I designed these braces.)

Here's with amplitude=3mm:

with a larger amplitude