1

I'm having difficulties with edge labels in a graph. The edges labels are overlapping in the nodes. I'd just like a little more separation between the edge and the label for avoid this. Here is a sample of the figure code:

\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}

I would appreciate a lot your help.enter image description here

2

You may use below=20pt (or whatever measure you want):

\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}

EDITs:

As Torbjørn T. suggested, I removed the useless left in the node position.

Moreover, I've used an array instead of aligned, in this way the equation alignment looks better for me:

enter image description here

P.S. = since your MWE is not complete I've invented the preamble. The ?? appears since there is not the corresponding label.

  • I think that in node[left, below=20pt] the left does nothing at all, so can be removed. – Torbjørn T. Oct 5 '16 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.