3

Sorry for my bad English.

I used fouriernc font for my document. But the right bracket is not beautiful.

I found a code can customize the right bracket so good but if there is a text beside, they stack up together like this. enter image description here

Please help me fix the code to avoid that problem. Thank you a lot!

\documentclass{article} % https://tex.stackexchange.com/a/327584/121799
\usepackage{tikz,amsmath,environ,fourier}
\usetikzlibrary{decorations.pathreplacing,calc}
\tikzset{
    ncbar angle/.initial=90,
    ncbar/.style={
        to path=(\tikztostart)
        -- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)
        -- ($(\tikztotarget)!($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztostart)$)
        -- (\tikztotarget)
    },
    ncbar/.default=0.5cm
}
%
\tikzset{square left brace/.style={ncbar=1ex}}
\tikzset{square right brace/.style={ncbar=-1ex}}
%
\NewEnviron{rcases}{\setbox0=\hbox{$\,\begin{matrix}\BODY\end{matrix}\,$}%
    \setbox2=\hbox{\begin{tikzpicture}
            \draw  (0,\botdim) to [square left brace] (0,\topdim);
            \copy0
    \end{tikzpicture}}
    \vcenter{\hbox{\copy2}}%
}

\def\topdim{\the\dimexpr+\ht0+.5\ht\strutbox-.5\dp\strutbox-3pt\relax} \def\botdim{\the\dimexpr-\ht0+.5\ht\strutbox-.5\dp\strutbox+3pt\relax} \begin{document} [ \left[\begin{matrix} 0 & \text{if}~x<0\ 1 & \text{if}~x\ge0 \end{matrix} \right. ] [ f(x)= \begin{rcases} 0 & \text{if}~x<0 \ 1 & \text{if}~x\ge0 \end{rcases} x+y=0 ] \end{document}

minmin
  • 151
  • 6

1 Answers1

3

Using TikZ here seems an overkill to me.

\documentclass{article}
\usepackage{amsmath,fourier}

\newenvironment{bcases}{% \vcenter\bgroup \vbox\bgroup \hrule width1ex % <-- choose your desired size \hbox\bgroup \vrule \hbox\bgroup $\mathsurround0pt\def\arraystretch{1.2}\array{@{\kern.5em}l@{\quad}l@{}}% }{% ^^^ ^^^^^^^^ \endarray$ % or whatever you like \egroup \egroup \hrule width1ex \egroup \egroup }

\begin{document}

\begin{gather} f(x)=\begin{cases} 0 & \text{if $x<0$} \ 1 & \text{if $x\ge0$} \end{cases} x+y=0 \ f(x)=\begin{bcases} 0 & \text{if $x<0$} \ 1 & \text{if $x\ge0$} \end{bcases} x+y=0 \end{gather}

\end{document}

enter image description here

(I called the environment bcases instead of rcases as the latter is provided by the mathtools package.)

campa
  • 31,130