将节点中的文本排版在箭头中点右侧的两行上

将节点中的文本排版在箭头中点右侧的两行上

如何将文本“从顶点 \textit{b} 构造边”放置在向下箭头的中点?现在排版后,似乎节点的顶部排版在箭头的中点。

我还想看一个类似的图表,其中向下的箭头向左弯曲,节点位于箭头中点的左侧。我知道它涉及选项to[in=theta, out=\phi, looseness=a]

\documentclass{amsart}
\usepackage{amssymb}
\usepackage{mathtools,array}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\begin{document}

\begin{tikzpicture}[nodes={inner sep=0, font=\scriptsize}, shorten/.style={shorten >=#1,shorten <=#1}]

%A sequence of graphs is drawn, starting with the vertex with the b-label b.


%Here is the blow-up of the vertex labeled b.
\draw[fill] (-4,0) circle (1.5pt);
\node[anchor=north] (label_for_Vertex_b) at ($(-4,0) +(0,-0.25)$){\textit{b}};
\node[anchor=south] at ($(-4,0) +(0,0.25)$){$\dfrac{0}{1}$};
%
%
\draw (-4,-3) -- (-2,-3);
\draw[fill] (-4,-3) circle (1.5pt);
\draw[fill] (-2,-3) circle (1.5pt);
%
\node[anchor=north] at ($(-4,-3) +(0,-0.25)$){\textit{b}};
\node[anchor=south] (label_for_Farey_Fraction_at_Vertex_b) at ($(-4,-3) +(0,0.25)$){$\dfrac{0}{1}$};
%
\node[anchor=north] at ($(-2,-3) +(0,-0.25)$){$b - 1$};
\node[anchor=south] at ($(-2,-3) +(0,0.25)$){$\dfrac{1}{1}$};
%
%
%An arrow is drawn to the next diagram.
\draw[-latex, line width=0.8pt, shorten=7.5pt] (label_for_Vertex_b) -- (label_for_Farey_Fraction_at_Vertex_b);
\path node[anchor=west, align=center] at ($($(label_for_Vertex_b)!0.5!(label_for_Farey_Fraction_at_Vertex_b)$) +(0.1,0)$)
{Construction of edge\\
from vertex \textit{b}};


\end{tikzpicture}

\end{document}

答案1

传统方式是仅使用midway并将节点放在行后。

\documentclass{amsart}
\usepackage{amssymb}
\usepackage{mathtools,array}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\begin{document}

\begin{tikzpicture}[nodes={inner sep=0, font=\scriptsize}, shorten/.style={shorten >=#1,shorten <=#1}]

%A sequence of graphs is drawn, starting with the vertex with the b-label b.


%Here is the blow-up of the vertex labeled b.
\draw[fill] (-4,0) circle (1.5pt);
\node[anchor=north] (label_for_Vertex_b) at ($(-4,0) +(0,-0.25)$){\textit{b}};
\node[anchor=south] at ($(-4,0) +(0,0.25)$){$\dfrac{0}{1}$};
%
%
\draw (-4,-3) -- (-2,-3);
\draw[fill] (-4,-3) circle (1.5pt);
\draw[fill] (-2,-3) circle (1.5pt);
%
\node[anchor=north] at ($(-4,-3) +(0,-0.25)$){\textit{b}};
\node[anchor=south] (label_for_Farey_Fraction_at_Vertex_b) at ($(-4,-3) +(0,0.25)$){$\dfrac{0}{1}$};
%
\node[anchor=north] at ($(-2,-3) +(0,-0.25)$){$b - 1$};
\node[anchor=south] at ($(-2,-3) +(0,0.25)$){$\dfrac{1}{1}$};
%
%
%An arrow is drawn to the next diagram.
\draw[-latex, line width=0.8pt, shorten=7.5pt] (label_for_Vertex_b) -- (label_for_Farey_Fraction_at_Vertex_b)
node[midway,right=1mm, align=center]{Construction of edge\\
from vertex \textit{b}};


\end{tikzpicture}
~vs.~\begin{tikzpicture}[nodes={inner sep=0, font=\scriptsize}, shorten/.style={shorten >=#1,shorten <=#1}]

%A sequence of graphs is drawn, starting with the vertex with the b-label b.


%Here is the blow-up of the vertex labeled b.
\draw[fill] (-4,0) circle (1.5pt);
\node[anchor=north] (label_for_Vertex_b) at ($(-4,0) +(0,-0.25)$){\textit{b}};
\node[anchor=south] at ($(-4,0) +(0,0.25)$){$\dfrac{0}{1}$};
%
%
\draw (-4,-3) -- (-2,-3);
\draw[fill] (-4,-3) circle (1.5pt);
\draw[fill] (-2,-3) circle (1.5pt);
%
\node[anchor=north] at ($(-4,-3) +(0,-0.25)$){\textit{b}};
\node[anchor=south] (label_for_Farey_Fraction_at_Vertex_b) at ($(-4,-3) +(0,0.25)$){$\dfrac{0}{1}$};
%
\node[anchor=north] at ($(-2,-3) +(0,-0.25)$){$b - 1$};
\node[anchor=south] at ($(-2,-3) +(0,0.25)$){$\dfrac{1}{1}$};
%
%
%An arrow is drawn to the next diagram.
\draw[-latex, line width=0.8pt, shorten=7.5pt] (label_for_Vertex_b) -- (label_for_Farey_Fraction_at_Vertex_b);
\path node[anchor=west, align=center] at ($($(label_for_Vertex_b)!0.5!(label_for_Farey_Fraction_at_Vertex_b)$) +(0.1,0)$)
{Construction of edge\\
from vertex \textit{b}};


\end{tikzpicture}
\end{document}

在此处输入图片描述

右图是原始图,偏移很小,因为标签/节点是扩展对象,箭头连接它们的边界而不是中心。还要注意,这有点“视觉错觉”,因为节点位于整个箭头(包括其头部)的中心。如果您想让节点位于无头箭头的中心,也可以这样做。

请注意,这是适用于路径的语法--。对于一般路径,请使用

\draw[<options>] (start) to[<options>] node [midway,<options>]{<test>} (end);

由于midway是默认选项,因此您只需使用

\draw[<options>] (start) to[<options>] node [<options>]{<test>} (end);

例如,

\documentclass{amsart}
\usepackage{amssymb}
\usepackage{mathtools,array}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\begin{document}

\begin{tikzpicture}[nodes={inner sep=0, font=\scriptsize}, shorten/.style={shorten >=#1,shorten <=#1}]

%A sequence of graphs is drawn, starting with the vertex with the b-label b.


%Here is the blow-up of the vertex labeled b.
\draw[fill] (-4,0) circle (1.5pt);
\node[anchor=north] (label_for_Vertex_b) at ($(-4,0) +(0,-0.25)$){\textit{b}};
\node[anchor=south] at ($(-4,0) +(0,0.25)$){$\dfrac{0}{1}$};
%
%
\draw (-4,-3) -- (-2,-3);
\draw[fill] (-4,-3) circle (1.5pt);
\draw[fill] (-2,-3) circle (1.5pt);
%
\node[anchor=north] at ($(-4,-3) +(0,-0.25)$){\textit{b}};
\node[anchor=south] (label_for_Farey_Fraction_at_Vertex_b) at ($(-4,-3) +(0,0.25)$){$\dfrac{0}{1}$};
%
\node[anchor=north] at ($(-2,-3) +(0,-0.25)$){$b - 1$};
\node[anchor=south] at ($(-2,-3) +(0,0.25)$){$\dfrac{1}{1}$};
%
%
%An arrow is drawn to the next diagram.
\draw[-latex, line width=0.8pt, shorten=7.5pt] 
(label_for_Vertex_b) to[bend right=20] node[right=1mm, align=center]{Construction of edge\\
from vertex \textit{b}} (label_for_Farey_Fraction_at_Vertex_b)
;
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

我会用不同的方式绘制你的图像。对于边标签,我将使用quotes库;对于顶点,我将使用圆形节点;对于它们的标签,我将使用带名称的宏。对于顶点位置,我将使用由库label确定的相对坐标:positioning

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[auto,
    node distance = 22mm and 22mm,
every edge quotes/.style = {font=\footnotesize,
                            align=center},
      every label/.style = {fill=white, inner sep= 2pt,
                            font=\footnotesize},
              dot/.style = {circle, draw, fill, minimum size=3pt,
                            inner sep=0pt, outer sep=0pt,
                            node contents={}}
                    ]
\node (n1) [dot,
            label={[name=n1a]$\frac{0}{1}$},
            label={[name=n1b]below:$b$}
            ];
\node (n2) [dot, below=of n1,
            label={[name=n2a]$\frac{0}{1}$},
            label={[name=n2b]below:$b$}
            ];
\node (n3) [dot, right=of n2,
            label={[name=n3a]$\frac{1}{1}$},
            label={[name=n3b]below:$b-1$}
            ];
%
\draw[-latex, line width=0.8pt]
        (n1b) edge["Construction of edge\\
                    from vertex \textit{b}",
                    bend left] (n2a);
\draw   (n2) -- (n3);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容