8

I want to draw just three quarters of a brace to illustrate that the brace is going on (see my example below, the brace with caption e). I want to illustrate that the section (marked by the brace with caption e) goes to infinity on the left.

\documentclass[11pt, xcolor=dvipsnames]{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}

\begin{figure}[h!]
\begin{center}
\begin{tikzpicture}[decoration=brace]%, scale=0.85]
\draw [black,ultra thick](0,0)--(10,0);
\draw [BrickRed,ultra thick, dashed](-2,0)--(0,0);
\draw [BrickRed,ultra thick, dashed](10,0)--(12,0);
\draw [black,ultra thick](10,-0.2)--(10,0.2);
\draw [black,ultra thick](0,-0.2)--(0,0.2);

\draw[MidnightBlue, thick,decorate, yshift=2ex] (0.0,0) -- node[above=0.4ex] {a} (2,0);
\draw[MidnightBlue, thick,decorate, yshift=-2ex] (3.2,0) -- node[below=0.4ex] {b} (2,0);
\draw[MidnightBlue, thick,decorate, yshift=2ex] (3.2,0) -- node[above=0.4ex] {c} (6,0);
\draw[MidnightBlue, thick,decorate, yshift=-2ex] (10,0) -- node[below=0.4ex] {d} (6,0);
\draw[MidnightBlue, thick,decorate, yshift=-2ex] (0,0) -- node[below=0.4ex] {e} (-2,0);

\end{tikzpicture}
\end{center}
\end{figure}

\end{document}

enter image description here

4
  • Please complete the MWE.
    – osjerick
    Nov 6 '15 at 13:56
  • What do you want exactly? Header? Reduced example?
    – d4rty
    Nov 6 '15 at 13:59
  • 1
    Please, read this guide to understand what I mean. If you provide a complete MWE you probably get help more effectively and quickly. ;)
    – osjerick
    Nov 6 '15 at 14:03
  • Here you are. The code will now give you exactly the result which is shown in the attached picture.
    – d4rty
    Nov 6 '15 at 14:17
9

I copied the definition of the brace decoration and modified it a bit to have an extra property which determines on which side the brace is open.

The open brace decoration has the extra key open=<side>. It defaults to none which is equivalent to the normal brace. Possible options are:

enter image description here

\documentclass{article}
\pagestyle{empty}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\newif\ifopenbraceleft
\newif\ifopenbraceright
\openbraceleftfalse
\openbracerightfalse

\pgfkeys{
  /pgf/decoration/.cd,
  open/.is choice,
  open/left/.is if = openbraceleft,
  open/right/.is if = openbraceright,
  open/both/.style = {open/left = true, open/right = true},
  open/none/.style = {open/left = false, open/right = false},
  open/.initial = none
}

\pgfdeclaredecoration{open brace}{initial}
{
  \state{initial}[width=+\pgfdecoratedremainingdistance,next state=final]
  {
    \pgfpathmoveto{\pgfpointorigin}
    \ifopenbraceright
    \pgfpathmoveto{\pgfqpoint{0pt}{.5\pgfdecorationsegmentamplitude}}
    \else
    \pgfpathcurveto
    {\pgfqpoint{.15\pgfdecorationsegmentamplitude}{.3\pgfdecorationsegmentamplitude}}
    {\pgfqpoint{.5\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}}
    {\pgfqpoint{\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}}
    \fi
    {
      \pgftransformxshift{+\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance}
      \pgfpathlineto{\pgfqpoint{-\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}}
      \pgfpathcurveto
      {\pgfqpoint{-.5\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}}
      {\pgfqpoint{-.15\pgfdecorationsegmentamplitude}{.7\pgfdecorationsegmentamplitude}}
      {\pgfqpoint{0\pgfdecorationsegmentamplitude}{1\pgfdecorationsegmentamplitude}}
      \pgfpathcurveto
      {\pgfqpoint{.15\pgfdecorationsegmentamplitude}{.7\pgfdecorationsegmentamplitude}}
      {\pgfqpoint{.5\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}}
      {\pgfqpoint{\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}}
    }
    {
      \pgftransformxshift{+\pgfdecoratedremainingdistance}
      \ifopenbraceleft
      \pgfpathlineto{\pgfqpoint{0pt}{.5\pgfdecorationsegmentamplitude}}
      \else
      \pgfpathlineto{\pgfqpoint{-\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}}
      \pgfpathcurveto
      {\pgfqpoint{-.5\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}}
      {\pgfqpoint{-.15\pgfdecorationsegmentamplitude}{.3\pgfdecorationsegmentamplitude}}
      {\pgfqpoint{0pt}{0pt}}
      \fi
    }
  }
  \state{final}
  {}
}

\begin{document}

\begin{tikzpicture}
\draw [black,ultra thick](0,0)--(10,0);
\draw [BrickRed,ultra thick, dashed](-2,0)--(0,0);
\draw [BrickRed,ultra thick, dashed](10,0)--(12,0);
\draw [black,ultra thick](10,-0.2)--(10,0.2);
\draw [black,ultra thick](0,-0.2)--(0,0.2);

\draw[MidnightBlue,thick,decorate,decoration=brace,yshift=2ex] (0.0,0) -- node[above=0.4ex] {a} (2,0);
\draw[MidnightBlue,thick,decorate,decoration=brace,yshift=-2ex] (3.2,0) -- node[below=0.4ex] {b} (2,0);
\draw[MidnightBlue,thick,decorate,decoration=brace,yshift=2ex] (3.2,0) -- node[above=0.4ex] {c} (6,0);
\draw[MidnightBlue,thick,decorate,decoration=brace,yshift=-2ex] (10,0) -- node[below=0.4ex] {d} (6,0);
\draw[MidnightBlue,thick,decorate,decoration={open brace,open=left},yshift=-2ex] (0,0) -- node[below=0.4ex] {e} (-2,0);
\end{tikzpicture}

\end{document}

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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