5

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.

Aim
  • 633
  • 2
    Wouldn't be better to use upright sin and smaller square brackets first? – Przemysław Scherwentke Dec 24 '21 at 05:00
  • There are almost almost 10 rows. This is the simplified version of the code. – Aim Dec 24 '21 at 05:02
  • 3
    I think @PrzemysławScherwentke was suggesting to reduce the vertical size of the square brackets (at least for the given example - can't say for your actual use case), and also to use \sin instead of sin. – Peter Grill Dec 24 '21 at 06:42

2 Answers2

4

I would focus on making the expression more compact, mainly by replacing the \frac notation with "slash" notation (aka inline fraction notation). And, since you're loading the mathtools package, you could use its cases* environment instead of a plain array environment.

Oh, and by all means, do write \sin, not sin.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for 'cases*' environment

\begin{document} \begin{equation} a(y)= \begin{cases} 0 & if $\hphantom{1\leq{}}y < 1$ \ \frac{1}{2}[ 1 + \sin(2\pi/\theta) ] & if $1 \leq y < 4$ \ 1 & if $4 \leq y < 5$ \ \frac{1}{2}[ 1 - \sin(2\pi/\theta) ] & if $6 \leq y < 7$ \ 0 & otherwise \end{cases} \end{equation} \end{document}


Addendum to address the OP's follow-up comment: To generate a truly elegan tall curly brace, you could download and install the mtpro2 package -- note that while the full package isn't free of charge, its 'lite' subset is free -- and use its \ccases macro. The elegant curly brace can be up to 10 cm (4 inches) tall. Observe that the mtpro2 math fonts are in the Times Roman family of fonts; this may or may not be to your liking.

enter image description here

\documentclass{article}
\usepackage{amsmath}      % for '\text' macro
\usepackage{newtxtext}    % Times Roman clone text font
\usepackage[lite]{mtpro2} % for '\ccases' macro

\begin{document} \begin{equation} a(y)= \ccases{ 0 & \text{ if $\phantom{1\leq{}}y < 1$} \ \frac{1}{2}[ 1 + \sin(2\pi/\theta) ] & \text{ if $1 \leq y < 4$} \ 1 & \text{ if $4 \leq y < 5$} \ \frac{1}{2}[ 1 - \sin(2\pi/\theta) ] & \text{ if $6 \leq y < 7$} \ 0 & \text{otherwise} } \end{equation} \end{document}

Sebastiano
  • 54,118
Mico
  • 506,678
3

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

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751