在 TikZ 图中插入键

在 TikZ 图中插入键

在下图中,我想插入一个键来解释顶点所使用的符号。

In each step of the expanding simple graphs,
the vertices are labeled with a fraction and
an \textit{a}-label. The fraction is a Farey
Fraction; it is typeset above each vertex.

这是一个相当长的描述。我想把它放在靠近图表右上角的地方,并且我希望它被框起来。

这是代码。

\documentclass[10pt]{amsart}
\usepackage{amssymb}
\usepackage{mathtools,array}

\usepackage{tikz}
\usetikzlibrary{calc,intersections,arrows.meta,bending}


\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}



\begin{document}



\centerline{\Large{\textbf{\textit{a}-Labels and Mediants for a Simple Graph}}} \vskip0.3in


\noindent \hspace*{\fill}
\begin{tikzpicture}[nodes={inner sep=0, font=\scriptsize,
execute at begin node={\setlength\abovedisplayskip{0.75ex}%
\setlength\belowdisplayskip{0.5ex}%
\setlength\abovedisplayshortskip{0.75ex}%
\setlength\belowdisplayshortskip{0.5ex}}},
shorten/.style={shorten >=#1,shorten <=#1},
pics/fpic/.style={code={#1}}, x=1.5cm, y=1.5cm]

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

\matrix[row sep=4.5em]{%<--- This defines the difference between pictures.
%Here is the blow-up of the vertex labeled b.
\pic{fpic={%
\draw[fill] (-4,0) circle (1.5pt);
\node[anchor=north] (label_for_Vertex_b) at ($(-4,0) +(0,-0.25)$){\textit{a}};
\node[anchor=south] at ($(-4,0) +(0,0.25)$){$\dfrac{0}{1}$};
}};\\
%
%
\pic{fpic={%
\draw (-4,0) -- (-2,0) coordinate(lcompare);
\draw[fill] (-4,0) circle (1.5pt);
\draw[fill] (-2,0) circle (1.5pt);
%
\node[anchor=north] (bcompare) at ($(-4,0) +(0,-0.25)$){\textit{a}};
\node[anchor=south] (label_for_Farey_Fraction_at_Vertex_b) at ($(-4,0) +(0,0.25)$){$\dfrac{0}{1}$};
%
\node[anchor=north] (label_for_Vertex_b-1) at ($(-2,0) +(0,-0.25)$){$a+1$};
\node[anchor=south] at ($(-2,0) +(0,0.25)$){$\dfrac{1}{1}$};
}}; \\
%
%
\pic{fpic={%
%Here is the blow-up of the vertex labeled b-1.
\draw (-4,0) -- (-2,0) -- (0,0);
\draw[fill] (-4,0) circle (1.5pt);
\draw[fill] (-2,0) circle (1.5pt);
\draw[fill] (0,0) circle (1.5pt);
%
\node[anchor=north] at ($(-4,0) +(0,-0.25)$){\textit{a}};
\node[anchor=south] at ($(-4,0) +(0,0.25)$){$\dfrac{0}{1}$};
%
\node[anchor=north] at ($(-2,0) +(0,-0.25)$){$a+1$};
\node[anchor=south] (label_for_Farey_Fraction_at_Vertex_b-1) at ($(-2,0) +(0,0.25)$){$\dfrac{1}{1}$};
%
\node[anchor=north] (label_for_Vertex_b-2) at ($(0,0) +(0,-0.25)$){$a+2$};
\node[anchor=south] at ($(0,0) +(0,0.25)$){$\dfrac{2}{1}$};
}}; \\
%
%
\pic{fpic={
%Here is the blow-up of the vertex labeled b-n.
\draw (-4,0) -- (-2,0) -- (0,0) (2,0) -- (5,0);
\draw[fill] (-4,0) circle (1.5pt);
\draw[fill] (-2,0) circle (1.5pt);
\draw[fill] (0,0) circle (1.5pt);
\node (first_ellipses) at (1,0){$\ldots$};
\coordinate (tail_for_bent_arrow_below_first_ellipses) at ($(first_ellipses) +(0,-0.25)$);
\draw[fill] (2,0) circle (1.5pt);
\draw[fill] (5,0) circle (1.5pt);
%
\node[anchor=north] at ($(-4,0) +(0,-0.25)$){\textit{a}};
\node[anchor=south] at ($(-4,0) +(0,0.25)$){$\dfrac{0}{1}$};
%
\node[anchor=north] at ($(-2,0) +(0,-0.25)$){$a+1$};
\node[anchor=south] at ($(-2,0) +(0,0.25)$){$\dfrac{1}{1}$};
%
\node[anchor=north] at ($(0,0) +(0,-0.25)$){$a+2$};
\node[anchor=south] at ($(0,0) +(0,0.25)$){$\dfrac{2}{1}$};
%
\node[anchor=south] (label_for_phantom_Farey_Fraction_at_ellipses) at ($(1,0) +(0,0.25)$){\hphantom{$\dfrac{1}{1}$}};
\coordinate (point_just_above_node_containing_phantom_Farey_Fraction) at ($(label_for_phantom_Farey_Fraction_at_ellipses.north) +(0,0.1)$);
%
\node[anchor=north] at ($(2,0) +(0,-0.25)$){$a+n$};
\node[anchor=south] at ($(2,0) +(0,0.25)$){$\dfrac{n}{1}$};
%
\node[anchor=north] at ($(5,0) +(0,-0.25)$){$a+(n+1)$};
\node[anchor=south] at ($(5,0) +(0,0.25)$){$\dfrac{n+1}{1}$};
%
%
}}; \\
\pic{fpic={
%Here is the vertex placed at the broken edge.
\draw (-4,0) -- (-2,0) -- (0,0) (2,0) -- (5,0);
\draw[fill] (-4,0) circle (1.5pt);
\draw[fill] (-2,0) circle (1.5pt);
\draw[fill] (0,0) circle (1.5pt);
\node (second_ellipses) at (1,0){$\ldots$};
\coordinate (head_for_bent_arrow_above_second_ellipses) at ($(second_ellipses) +(0,0.75)$);
\draw[fill] (2,0) circle (1.5pt);
\draw[fill] ({(2+5)/2},0) circle (1.5pt);
\draw[fill] (5,0) circle (1.5pt);
%
\node[anchor=north] at ($(-4,0) +(0,-0.25)$){\textit{a}};
\node[anchor=south] at ($(-4,0) +(0,0.25)$){$\dfrac{0}{1}$};
%
\node[anchor=north] at ($(-2,0) +(0,-0.25)$){$a+1$};
\node[anchor=south] at ($(-2,0) +(0,0.25)$){$\dfrac{1}{1}$};
%
\node[anchor=north] at ($(0,0) +(0,-0.25)$){$a+2$};
\node[anchor=south] at ($(0,0) +(0,0.25)$){$\dfrac{2}{1}$};
%
\node[anchor=north] at ($(2,0) +(0,-0.25)$){\textit{$a+n$}};
\node[anchor=south] at ($(2,0) +(0,0.25)$){$\dfrac{n}{1}$};
%
\node[anchor=north] at ($(5,0) +(0,-0.25)$){$a+(n+1)$};
\node[anchor=south] at ($(5,0) +(0,0.25)$){$\dfrac{n+1}{1}$};
%
%A "pin" is drawn between the midpoint of the edge between the last two vertices and its label.
\draw[draw=gray, line width=0.8pt, shorten <=1mm, shorten >=1mm] ({(2+5)/2},0) -- ({(2+5)/2},-1);
\node[anchor=north] at ({(2+5)/2},-1){$2a+(2n+1)$};
\node[anchor=south] (f2n) at ($({(2+5)/2},0) +(0,0.25)$){$\dfrac{2n+1}{2}$};
}};\\
};
%
%
%
%
%Arrows are drawn between the diagrams.
\draw[-latex, line width=0.8pt, shorten=7.5pt] (label_for_Vertex_b) to[bend right=30] node[midway, right=1.5mm, align=center]
{Blow-up of\\vertex \textit{b}} (label_for_Farey_Fraction_at_Vertex_b);
%
\draw[-latex, line width=0.8pt, shorten=7.5pt] (label_for_Vertex_b-1) to[bend right=30] node[midway, right=1.5mm, align=center]
{Blow-up of\\vertex $b - 1$} (label_for_Farey_Fraction_at_Vertex_b-1);
%
\draw[-latex, line width=0.8pt, shorten=7.5pt] (label_for_Vertex_b-2) to[bend right=30] node[pos=1/3, right=1.5mm, align=center]
{Blow-up of more\\\hphantom{\ }vertices} (point_just_above_node_containing_phantom_Farey_Fraction);
%
%\draw[-latex, line width=0.8pt, shorten <=30pt, shorten >=7.5pt](label_for_Edge.south) -- (f2n.north);
\draw[-latex, line width=0.8pt, shorten <=7.5pt, shorten >=7.5pt] (tail_for_bent_arrow_below_first_ellipses) to[bend right=30]
(head_for_bent_arrow_above_second_ellipses);

\end{tikzpicture}
\hspace{\fill}


\end{document}

答案1

之前\end{tikzpicture}插入以下内容:

\node[draw, text width=0.25\linewidth,inner sep=2mm,align=left,
      below left] at (current bounding box.north east)
    {In each step of the expanding simple graphs,
the vertices are labeled with a fraction and
an \textit{a}-label. The fraction is a Farey
Fraction; it is typeset above each vertex.
};

在此处输入图片描述

附录: 就主题而言,关于表示顶点爆炸的弯曲箭头,我宁愿将它们绘制为直箭头。还有你的图像代码(效果很好),我宁愿基于你问题的答案绘制弯曲箭头的一致性。您可能喜欢这个解决方案(这与您的方法完全不同,但根据我的观点更简洁):

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{chains,           % new
                positioning,      % new
                quotes}           % new
\makeatletter
\tikzset{% for discontinuing of chain
  off chain/.code={\def\tikz@lib@on@chain{}}%
}
\makeatother

\begin{document}
    \begin{tikzpicture}[auto,
           node distance = 22mm and 21mm,    % new
             start chain = going right,     % new
every edge quotes/.style = {auto=right, font=\footnotesize,
                            align=center},  % new
every edge/.append style = {draw=gray, -latex, line width=1.6pt, shorten >=2pt, shorten <=2pt},
      every label/.style = {inner sep= 2pt,font=\footnotesize},
         dot/.style args = {#1/#2/#3/#4}{circle, draw, fill, minimum size=3pt,
                            inner sep=0pt, outer sep=0pt, anchor=center,
                            label={[name=#1]$#2$},
                            label={[name=#3]below:$#4$},
                            node contents={},
                            on chain}, %
                    ]
%%%% 1. row (is on the top of image), node name is n11
\node (n11) [dot=n11a/\frac{0}{1}/n11b/a];
%%%% 2. row, nodes names are n21, n22
\node (n21) [dot=n21a/\frac{0}{1}/n21b/a,
            below=of n11];
\node (n22) [dot=n22a/\frac{1}{1}/n22b/a+1];
\draw[-latex, line width=0.8pt]
        (n11b) edge["blow up\\ of vertex $b$" '] (n21a);
\draw   (n21) -- (n22);
%%%% 3. row, nodes names are n31, n32, ...
\node (n31) [dot=n31a/\frac{0}{1}/n31b/a,
            below=of n21];
\node (n32) [dot=n32a/\frac{1}{1}/n32b/a+1];
\node (n33) [dot=n33a/\frac{2}{1}/n33b/a+2];
\draw   (n22b) edge["blow up\\  of vertex $b$" '] (n32a);
\draw   (n31) -- (n33);
%%%% 4. row, nodes names are n41, n42, ...
\node (n41) [dot=n41a/\frac{0}{1}/n41b/a,
            below=of n31];
\node (n42) [dot=n42a/\frac{1}{1}/n42b/a+1];
\node (n43) [dot=n43a/\frac{2}{1}/n43b/a+2];
\node (n44) [dot=n45a/\frac{n}{1}/n45b/a+n];
\node (n45) [dot=n46a/\frac{n+1}{1}/n46b/a+(n+1)];
\path   (n43) -- node (n46) {$\dots$} (n44);
\draw   (n33b) edge["Blow up of\\ more vertices" '] (n46);
\draw[thick]    (n41) -- (n43)   (n44) -- node (aux) {} (n45);
%%%% 5. row, nodes names are n51, n52, ...
\node (n51) [dot=n51a/\frac{0}{1}/n41b/a,
            below=of n41 |- aux];
\node (n52) [dot=n52a/\frac{1}{1}/n52b/a+1];
\node (n53) [dot=n53a/\frac{2}{1}/n53b/a+22];
\node (n54) [dot=n54a/\frac{n}{1}/n54b/a+n];
\node (n55) [dot=n55a/\frac{n+1}{1}/n55b/a+(n+1)];
%
\path   (n53) -- node [anchor=center] (n56) {$\dots$} (n54);
\draw   (n46) edge    (n56);
\draw[thick]    (n51) --  (n53)
                (n54) --  (n55) node (n57) [pos=0.5, off chain,
                                      dot=n56a/\frac{2n+1}{2}/n56b/ ];
\draw[semithick]
        (n57) -- ++ (0,-9mm) node[below,font=\footnotesize] {$2^{2}a-(2n+1)$};
%%%% legend at top right edge
\node[text width=0.44\linewidth,inner sep=2mm,align=left,
      below left = 3mm and 0mm of current bounding box.north east]
    {In each step of the expanding simple graphs,
     the vertices are labeled with a fraction and
     an \textit{a}-label. The fraction is a Farey
     Fraction; it is typeset above each vertex.
        };
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容