![边标签间距](https://linux22.com/image/342077/%E8%BE%B9%E6%A0%87%E7%AD%BE%E9%97%B4%E8%B7%9D.png)
我在处理图中的边标签时遇到了困难。边标签在节点中重叠。我只想在边和标签之间留出更多距离以避免这种情况。以下是图形代码的示例:
\begin{figure}[H] \centering
\begin{tikzpicture}[->, >=stealth', shorten >=1pt, auto, node distance=3cm,thick, main node/.style={circle, draw, font=\sffamily\Large}]
\node[main node] (1) {\textbf{A}};
\node[main node] (2) [right of=1] {B};
\path[every node/.style={font=\sffamily\small}, label distance=9pt]
(1) edge [right] node[left, below] {$\begin{aligned}
\alpha_{A1} &+ \sum_{i',m',o'}\gamma_{i'\rightarrow A\ \ o'\rightarrow1} &=& \gamma_{A\rightarrow B\ \ 1\rightarrow 2} &+& \beta_{A1}\\
1&+0 &=& 1 &+&0
\end{aligned}$} (2);
\end{tikzpicture}
\caption{Situação \ref{it:eq:setup_flow2} quando o produto A está entre dois itens.}
\label{fig:eq:setup_flow2}
\end{figure}
答案1
您可以使用below=20pt
(或您想要的任何措施):
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{float}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\begin{figure}[H] \centering
\begin{tikzpicture}[->, >=stealth', shorten >=1pt, auto, node distance=3cm,thick, main node/.style={circle, draw, font=\sffamily\Large}]
\node[main node] (1) {\textbf{A}};
\node[main node] (2) [right of=1] {B};
\path[every node/.style={font=\sffamily\small}, label distance=9pt]
(1) edge [right] node[below=20pt] {\(
\setlength{\extrarowheight}{1pt} % this is optional, you may remove or increase it
\begin{array}{*{7}c}
\alpha_{A1} & + & \displaystyle\sum_{i',m',o'}\gamma_{i'\rightarrow A\ \ o'\rightarrow1} & = & \gamma_{A\rightarrow B\ \ 1\rightarrow 2} & + & \beta_{A1}\\
1 & + & 0 & = & 1 & + & 0
\end{array}
\)} (2);
\end{tikzpicture}
\caption{Situação \ref{it:eq:setup_flow2} quando o produto A está entre dois itens.}
\label{fig:eq:setup_flow2}
\end{figure}
\end{document}
编辑:
left
按照 Torbjørn T. 的建议,我删除了节点位置上无用的部分。
此外,我使用了array
而不是aligned
,这样方程对齐对我来说看起来更好:
PS = 由于您的 MWE 不完整,我发明了序言。出现 ?? 是因为没有相应的标签。