# Curly brace arrow and labeling

I have the following code which generates a plot of $x^2+1$ and then marks a distance by a curly brace on it.

\documentclass{article}
\usepackage{tikz}
\usepgflibrary{arrows}
\usetikzlibrary{arrows.meta,automata, decorations.pathreplacing}
\usepackage{verbatim}
\begin{document}
\begin{tikzpicture}[domain=0:1.8, xscale = 6, yscale = 1.5]

\draw[->]  (-0.2,0)  --  (2,0)  node[right]  {$x$};
\draw[->]  (0,-1.2)  --  (0,4)  node[above]  {$f(x)$};

\draw[color=blue]      plot  (\x,{\x^2+1})        node[right]  {};
\node(1) at (0.5,0) [circle,draw, fill, scale = 0.5 pt]{};
\node(2) at (0.5,0.5^2+1) [circle,draw, fill, scale = 0.5pt]{};
\node(3) at (1.5,0) [circle,draw, fill, scale = 0.5pt]{};
\node(4) at (1.5,1.5^2+1) [circle,draw, fill, scale = 0.5pt]{};
\node(5) at (1.0, 0) [circle,draw, fill, scale = 0.5pt]{};
\node(6) at (1.0, 1.0^2+1) [circle,draw, fill, scale = 0.5pt]{};

\node[below of = 1](leftlabel){$x-dx$};
\node[below of = 5](middlelabel){$x$};
\node[below of = 3](rightlabel){$x+dx$};

\draw [decorate,decoration={brace,amplitude=10pt,mirror}, yshift = -0.2cm]
(1.0,1^2+1) -- (1.5,1^2+1) node (curly_bracket)[black,midway, yshift =- 0.3 cm]
{};
\node[below right of =  curly_bracket, xshift = 1 cm, yshift = -0.1 cm](test){};
\draw[<-] (curly_bracket) -- (test) node[at end,label=below right:{$dx$}]{};

\draw[dashed] (1.0,1^2+1)--(1.5,1^2+1) node[below =0.3cm, right = 0.7 cm](7){} node[midway](8){};

\end{tikzpicture}
\end{document}

The above results in the following plot:

As you can see the positioning of the arrow and its label to the curly brace are not very good. I would like for the arrow to point to exactly the tip of the brace with a small vertical spacing, and for the label to the opposite side of the arrow to appear a lot closer to the end of the line.

Ideally I am looking to achieve something like this:

How do I bring the arrow from the tip of the curly brace, and label its end with adequate anchor spacing?

EDIT

To respond to @Zarko, and to those skeptical of why I would be embarking on such an endeavor, I would like to show the following plot

As you can see this would be challenging to do without the arrow leaders provided by the accepted answer

• why not simply put label dx below curly brace? Jun 28 '18 at 7:52
• The actual drawing is a lot more cluttered. I have several curly braces at various locations and I need to be able to control where/how the labelling occurs. Also in this LWE dx is used, but in the actual case there are long expressions substituted for dx. Finally, this is a kind of annotation that I am quite fond of and use frequently by hand. Therefore I would like to be able to transfer it to tex if possible. Jun 28 '18 at 8:01
• the way, as you like to wrote labels to braces, to my opinion, will confuse readers. i will not do this. see my answer below. Jun 28 '18 at 8:48

\documentclass{article}
\usepackage{tikz}
\usepgflibrary{arrows}
\usetikzlibrary{arrows.meta,automata, decorations.pathreplacing}
\usepackage{verbatim}
\begin{document}
\begin{tikzpicture}[domain=0:1.8, xscale = 6, yscale = 1.5]

\draw[->]  (-0.2,0)  --  (2,0)  node[right]  {$x$};
\draw[->]  (0,-1.2)  --  (0,4)  node[above]  {$f(x)$};

\draw[color=blue]      plot  (\x,{\x^2+1})        node[right]  {};
\node(1) at (0.5,0) [circle,draw, fill, scale = 0.5 pt]{};
\node(2) at (0.5,0.5^2+1) [circle,draw, fill, scale = 0.5pt]{};
\node(3) at (1.5,0) [circle,draw, fill, scale = 0.5pt]{};
\node(4) at (1.5,1.5^2+1) [circle,draw, fill, scale = 0.5pt]{};
\node(5) at (1.0, 0) [circle,draw, fill, scale = 0.5pt]{};
\node(6) at (1.0, 1.0^2+1) [circle,draw, fill, scale = 0.5pt]{};

\node[below of = 1](leftlabel){$x-dx$};
\node[below of = 5](middlelabel){$x$};
\node[below of = 3](rightlabel){$x+dx$};

\draw [decorate,decoration={brace,amplitude=10pt,mirror}, yshift = -0.2cm]
(1.0,1^2+1) -- (1.5,1^2+1) node (curly_bracket)[black,midway, yshift =- 0.3 cm]
{};
\node[below right of =  curly_bracket, xshift = 1 cm, yshift = -0.1
cm](test){$dx$};
\draw[latex-] (curly_bracket) to[out=-90,in=90,looseness=1.8] (test);

\draw[dashed] (1.0,1^2+1)--(1.5,1^2+1) node[below =0.3cm, right = 0.7 cm](7){} node[midway](8){};
\end{tikzpicture}
\end{document}

i know, that you looking for something more "exotic" solution, however i would rather redraw your image like the following:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
decorations.pathreplacing}
\usepackage{verbatim}

\begin{document}
\begin{tikzpicture}[
xscale = 6,
yscale = 1.5,
> = Straight Barb,
domain = 0:1.8,
dot/.style = {circle,draw, fill, scale = 0.5 pt,
node contents={}},
B/.style = {decorate, decoration={brace,amplitude=5pt,raise=5pt,mirror}}
]
\draw[->]  (-0.1,0)  --  (2,0) node[right]  {$x$};
\draw[->]  (0,-0.2)  --  (0,5)  node[above]  {$f(x)$};

\draw[color=blue, very thick]    plot  (\x,{\x^2+1});

\foreach \x/\xlbl [count=\i] in {0.5/$x-dx$, 1/$x\vphantom{d}$, 1.5/$x+dx$}
{
\node (n\i) at (\x,0) [dot, label=below:\xlbl];
\node (m\i) at (\x,\x^2+1) [dot];
}
\draw[dashed] (m2) -| (m3);
\draw[B]      (m2) --  node[below=11pt] {$dx$} (m2 -| m3);
\draw[B]      (m2 -| m3) --  node[right=11pt] {$dy$} (m3);
\end{tikzpicture}
\end{document}

provided image in edit question i would draw as:

(not all details are present)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
decorations.pathreplacing}
\usepackage{verbatim}

\begin{document}
\begin{tikzpicture}[
xscale = 6,
yscale = 1.5,
> = Straight Barb,
domain = 0:1.8,
dot/.style = {circle,draw, fill, scale = 0.5 pt,
node contents={}},
B/.style = {decorate, decoration={brace,amplitude=3pt,raise=3pt, mirror,
aspect=#1}},  % <---
B/.default = 0.5          % <---
]
\draw[->]  (-0.1,0)  --  (2,0) node[right]  {$x$};
\draw[->]  (0,-0.2)  --  (0,5)  node[above]  {$f(x)$};

\draw[color=blue, very thick]    plot  (\x,{\x^2+1});

\foreach \x/\xlbl [count=\i] in {0.5/$x-dx$, 1/$x\vphantom{d}$, 1.5/$x+dx$}
{
\node (n\i) at (\x,0) [dot, label=below:\xlbl];
\node (m\i) at (\x,\x^2+1) [dot];
}
\draw[dashed]   (m1) -| (m2)
(m1) |- (m3)
(m2) -| (m3);
\begin{scope}[every node/.append style={fill=white,inner sep=2pt, font=\footnotesize}]
\draw[B]      (m1 |- m3) --  node[left=7pt] {$f(x+dx)-f(x-dx)$} (m1);
\draw[B]      (m3) --  node[above=7pt] {$2dx$} (m3 -| m1);
\draw[B]      (m1) --  node[below=7pt] {$x-x(x-dx)=dx$} (m1 -| m2);
\draw[B=0.3] (m1 -| m2) -- node[pos=0.3,right=7pt] {$f(x)-f(x-dx)$} (m2);
\draw[B]      (m2) --  node[below=7pt] {$x-x(x+dx)=dx$} (m2 -| m3);
\draw[B]      (m2 -| m3) --  node[right=7pt] {$f(x+dx)-f(x)$} (m3);
\end{scope}
\end{tikzpicture}
\end{document}

maybe you liked :-)

• As I mentioned in the comment, I'm aware this can be done. However I have other reasons for choosing to offset the curly brace labeling. Thanks for your help anyway. Jun 28 '18 at 9:36
• instead saying "thank you" you can up-vote" answer :-). at least it has more concise code as your mwe ... Jun 28 '18 at 10:11
• Ok I voted it up for the effort. Please note it does not answer my question though. It makes the case for an answer to a different question which is not applicable in this case. Jun 28 '18 at 10:21
• at least my answer provide (far) more concise code as have your mwe. i disagree with your intention of drawing braces labels and agree that my answer not support what you like to obtain :-) Jun 28 '18 at 10:36
• I just edited my initial question to show the end result. Maybe this can explain a bit more why I need that way of labeling with curly brackets. Jun 28 '18 at 12:28