我有以下代码,它生成 $x^2+1$ 的图,然后用花括号标记距离。
\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}
如您所见,箭头及其标签在花括号中的定位不太好。我希望箭头能够以较小的垂直间距精确指向花括号的尖端,并且箭头另一侧的标签看起来更靠近行尾。
理想情况下,我希望实现这样的目标:
如何将箭头从花括号的尖端引出,并用足够的锚间距标记其末端?
编辑
为了回应@Zarko,以及那些怀疑我为什么要做这样的尝试的人,我想展示以下情节
正如您所看到的,如果没有接受答案提供的箭头指引,这将是一项挑战
答案1
\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}
答案2
我知道,您正在寻找一些更“奇特”的解决方案,但我宁愿重新绘制您的图像,如下所示:
\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}
附录:
在编辑问题中提供的图像我会绘制为:
(并非所有细节均已呈现)
\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}
也许你喜欢:-)