3

I'm trying to put the text on the good place and I'm "playing" with the options like above, below, left... and pos option but I can't do it. The idea is moving the labels to the new clean position like:

enter image description here

This is my code:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{positioning,calc} \usetikzlibrary{arrows,shapes}

\tikzset{ % flecha flecha/.style={->,>=stealth',black,shorten >=1pt}, % estilo circulo circulo/.style={circle,text=black,draw=cyan!40, fill=cyan!10, very thick, minimum size=9mm}, % estilo cuadrado cuadrado/.style={rectangle,text=black,draw=blue!40, fill=blue!10, very thick, minimum size=6mm, minimum width=11mm}, % estilo cuadrado pequeño cuadrado2/.style={cuadrado, minimum size=3mm, minimum width=7mm, minimum height=5mm}, % estilo elipse elipse/.style={rectangle,rounded corners=8,text=black,draw=cyan!40, fill=cyan!10, very thick, minimum size=6mm}, % cuadrado de puntos transparente transparente/.style={rectangle,fill=white,draw=none,text=black,minimum size=6mm} }

\begin{document} \begin{tikzpicture}[remember picture, overlay, shift={($(current page.west)+(5.5cm,-3cm)$)}, ->, >=stealth', shorten >=1pt, node distance=1cm, font=\scriptsize]

% G1 \node[cuadrado] (g1_1) {$(y_m)$}; \node[circulo] (g1_2) [left = 1cm of g1_1] {$y_m$}; \node[circulo] (g1_3) [right = 1cm of g1_1] {$\neg y_m$}; \node[cuadrado] (g1_4) [above left = 0.5cm of g1_2] {$y_m$}; \node[cuadrado] (g1_6) [above right = 0.5cm of g1_3] {$\neg y_m$}; \node[cuadrado] (g1_8) [above right = 0.5cm of g1_2] {$[y_m^k]$}; \node[cuadrado] (g1_9) [above left = 0.5cm of g1_3] {$[\neg y_m^k]$}; \node[cuadrado] (g1_10) [above = 0.5cm of g1_8] {$[y_m^1]$}; \node[cuadrado] (g1_11) [above = 0.5cm of g1_9] {$[\neg y_m^1]$}; \node[transparente] (g100_1) [below = 0.5cm of g1_4] {$\vdots$}; \node[transparente] (g100_2) [below = 0.5cm of g1_6] {$\vdots$}; \node[transparente] (g100_3) [below = 3.46cm of g1_2] {$\vdots$}; \node[transparente] (g100_4) [below = 3.46cm of g1_3] {$\vdots$}; \node[rectangle,text opacity=1,fill opacity=0.5,draw=none,text=black,minimum size=1mm] (g100_5) [below = -0.21cm of g1_10] {\tiny$\vdots$}; \node[rectangle,text opacity=1,fill opacity=0.5,draw=none,text=black,minimum size=1mm] (g100_6) [below = -0.21cm of g1_11] {\tiny$\vdots$};

% G2 \node[cuadrado] (g2_1) [above = 3cm of g1_1] {$(y_1)$}; \node[circulo] (g2_2) [left = 1cm of g2_1] {$y_1$}; \node[circulo] (g2_3) [right = 1cm of g2_1] {$\neg y_1$}; \node[cuadrado] (g2_4) [above left = 0.5cm of g2_2] {$y_1$}; \node[cuadrado] (g2_6) [above right = 0.5cm of g2_3] {$\neg y_1$}; \node[cuadrado] (g2_8) [above right = 0.5cm of g2_2] {$[y_1^k]$}; \node[cuadrado] (g2_9) [above left = 0.5cm of g2_3] {$[\neg y_1^k]$}; \node[cuadrado] (g2_10) [above = 0.5cm of g2_8] {$[y_1^1]$}; \node[cuadrado] (g2_11) [above = 0.5cm of g2_9] {$[\neg y_1^1]$}; \node[transparente] (g20_1) [below = 0.5cm of g2_2] {$\vdots$}; \node[transparente] (g20_2) [below = 0.5cm of g2_3] {$\vdots$}; \node[rectangle,text opacity=1,fill opacity=0.5,draw=none,text=black,minimum size=1mm] (g20_3) [below = -0.21cm of g2_10] {\tiny$\vdots$}; \node[rectangle,text opacity=1,fill opacity=0.5,draw=none,text=black,minimum size=1mm] (g20_4) [below = -0.21cm of g2_11] {\tiny$\vdots$};

% G3 \node[cuadrado] (g3_1) [above = 8cm of g1_1] {$(x_n)$}; \node[circulo] (g3_2) [left = 1cm of g3_1] {$x_n$}; \node[circulo] (g3_3) [right = 1cm of g3_1] {$\neg x_n$}; \node[cuadrado] (g3_4) [above left = 0.5cm of g3_2] {$x_n$}; \node[cuadrado] (g3_5) [below left = 0.5cm of g3_2] {$\langle x_n\rangle$}; \node[cuadrado] (g3_6) [above right = 0.5cm of g3_3] {$\neg x_n$}; \node[cuadrado] (g3_7) [below right = 0.5cm of g3_3] {$\langle \neg x_n\rangle$}; \node[cuadrado] (g3_8) [above right = 0.5cm of g3_2] {$[x_m^k]$}; \node[cuadrado] (g3_9) [above left = 0.5cm of g3_3] {$[\neg x_m^k]$}; \node[cuadrado] (g3_10) [above = 0.5cm of g3_8] {$[x_m^1]$}; \node[cuadrado] (g3_11) [above = 0.5cm of g3_9] {$[\neg x_m^1]$}; \node[rectangle,text opacity=1,fill opacity=0.5,draw=none,text=black,minimum size=1mm] (g30_1) [below = -0.21cm of g3_10] {\tiny$\vdots$}; \node[rectangle,text opacity=1,fill opacity=0.5,draw=none,text=black,minimum size=1mm] (g30_2) [below = -0.21cm of g3_11] {\tiny$\vdots$};

% G4 \node[cuadrado] (g4_1) [above = 12cm of g1_1] {$(x_1)$}; \node[circulo] (g4_2) [left = 1cm of g4_1] {$x_1$}; \node[circulo] (g4_3) [right = 1cm of g4_1] {$\neg x_1$}; \node[cuadrado] (g4_4) [above left = 0.5cm of g4_2] {$x_1$}; \node[cuadrado] (g4_5) [below left = 0.5cm of g4_2] {$\langle x_1\rangle$}; \node[cuadrado] (g4_6) [above right = 0.5cm of g4_3] {$\neg x_1$}; \node[cuadrado] (g4_7) [below right = 0.5cm of g4_3] {$\langle\neg x_1\rangle$}; \node[cuadrado] (g4_8) [above right = 0.5cm of g4_2] {$[x_1^k]$}; \node[cuadrado] (g4_9) [above left = 0.5cm of g4_3] {$[\neg x_1^k]$}; \node[cuadrado] (g4_10) [above = 0.5cm of g4_8] {$[x_1^1]$}; \node[cuadrado] (g4_11) [above = 0.5cm of g4_9] {$[\neg x_1^1]$}; \node[transparente] (g40_1) [below = 0.5cm of g4_2] {$\vdots$}; \node[transparente] (g40_2) [below = 0.5cm of g4_3] {$\vdots$}; \node[rectangle,text opacity=1,fill opacity=0.5,draw=none,text=black,minimum size=1mm] (g40_3) [below = -0.21cm of g4_10] {\tiny$\vdots$}; \node[rectangle,text opacity=1,fill opacity=0.5,draw=none,text=black,minimum size=1mm] (g40_4) [below = -0.21cm of g4_11] {\tiny$\vdots$};

% G10 \node[circulo] (g10_1) [below = 1.5cm of g1_1] {$u_0$}; \node[cuadrado] (g10_2) [below left = 0.6cm of g10_1] {$u_0$}; \node[cuadrado] (g10_3) [below right = 0.6cm of g10_1] {$u_0 _ u_0^,$}; \node[circulo] (g10_4) [below = 1.2cm of g10_1] {$u_0^,$}; \node[cuadrado] (g10_5) [below left = 0.6cm of g10_4] {$u_0^,$};

% G5 \node[elipse, align=center] (g5_1) [right = 1.5cm of g4_7] {$C_1$ \ $\thinspace x_1 \vee\neg x_n\vee y_1$}; \node[transparente] (g50_1) [right = 1cm of g5_1] {$\dotsb$}; \node[circulo] (g5_2) [right = 2.4cm of g5_1] {$c_i$}; \node[transparente] (g50_2) [right = 0.8cm of g5_2] {$\dotsb$}; \node[circulo] (g5_3) [right = 2.2cm of g5_2] {$c_k$}; \node[transparente] (g5_4) [above left = 0.7cm of g5_2] {$\dotsb$}; \node[transparente] (g5_5) [above = 0.7cm of g5_2] {$\dotsb$}; \node[transparente] (g5_6) [above right = 0.7cm of g5_2] {$\dotsb$}; \node[transparente] (g5_7) [above left = 0.7cm of g5_3] {$\dotsb$}; \node[transparente] (g5_8) [above = 0.7cm of g5_3] {$\dotsb$}; \node[transparente] (g5_9) [above right = 0.7cm of g5_3] {$\dotsb$}; \node[cuadrado2] (g5_10) [below = 0.4cm of g5_1] {$[c_1]$}; \node[cuadrado2] (g5_11) [below right = 0.5cm of g5_1] {$[c_1]$}; \node[cuadrado2] (g5_12) [below left = 0.5cm of g5_2] {$[c_i]$}; \node[cuadrado2] (g5_13) [below right = 0.5cm of g5_2] {$[c_i]$}; \node[cuadrado2] (g5_14) [below left = 0.5cm of g5_3] {$[c_k]$}; \node[cuadrado2] (g5_15) [below right = 0.5cm of g5_3] {$[c_k]$};

% G6 \node[circulo] (g6_1) [below = 3cm of g5_2] {$all$}; \node[cuadrado] (g6_2) [below left = 1cm of g6_1] {$u_0 _ all$}; \node[cuadrado] (g6_3) [below right = 1cm of g6_1] {$all _ all^,$}; \node[circulo] (g6_4) [below = 1cm of g6_3] {$all^,$}; \node[cuadrado] (g6_5) [below = 1cm of g6_4] {$all^,$}; \node[cuadrado] (g6_6) [right = 1cm of g6_1] {$all$};

% G7 \node[circulo] (g7_1) [below = 14cm of g5_12] {$col_i$}; \node[cuadrado2] (g7_2) [above right = 0.3cm of g7_1] {$col_i$}; \node[transparente] (g70_1) [below = 1cm of g7_1] {$\dotsb$}; \node[cuadrado2] (g7_6) [left = 0.1cm of g70_1] {$[\neg x_1^k]$}; \node[transparente] (g70_2) [left = 0.03cm of g7_6] {$\dotsb$}; \node[cuadrado2] (g7_5) [left = 0.1cm of g70_2] {$[\neg x_1^1]$}; \node[cuadrado2] (g7_4) [left = 0.3cm of g7_5] {$[x_1^k]$}; \node[transparente] (g70_3) [left = 0cm of g7_4] {$\dotsb$}; \node[cuadrado2] (g7_3) [left = 0cm of g70_3] {$[x_1^1]$}; % -------------------------- \node[cuadrado2] (g7_7) [right = 0.1cm of g70_1] {$[y_m^1]$}; \node[transparente] (g70_4) [right = 0.07cm of g7_7] {$\dotsb$}; \node[cuadrado2] (g7_8) [right = 0.7cm of g7_7] {$[y_m^k]$}; \node[cuadrado2] (g7_9) [right = 0.1cm of g7_8] {$[\neg y_m^1]$}; \node[transparente] (g70_5) [right = 0.07cm of g7_9] {$\dotsb$}; \node[cuadrado2] (g7_10) [right = 0.7cm of g7_9] {$[\neg y_m^k]$};

% G8 \node[circulo] (g8_1) [below = 13cm of g5_1] {$col_1$}; \node[cuadrado2] (g8_2) [above right = 0.5cm of g8_1] {$col_1$}; \node[cuadrado2] (g8_3) [above left = 0.5cm of g8_1] {$ ? $}; \node[cuadrado2] (g8_4) [below left = 0.9cm of g8_1] {$ ? $}; \node[cuadrado2] (g8_5) [below right = 0.9cm of g8_1] {$ ? $}; \node[transparente] (g80_1) [above = 0.5cm of g8_1] {$\dotsb$}; \node[transparente] (g80_2) [below = 0.5cm of g8_1] {$\dotsb$};

% G9 \node[circulo] (g9_1) [below = 13cm of g5_3] {$col_n{}+{}_m$}; \node[cuadrado2] (g9_2) [above right = 0.6cm of g9_1] {$col_n{}+{}_m$}; \node[cuadrado2] (g9_3) [above left = 0.6cm of g9_1] {$ ? $}; \node[cuadrado2] (g9_4) [below left = 0.4cm of g9_1] {$ ? $}; \node[cuadrado2] (g9_5) [below right = 0.4cm of g9_1] {$ ? $}; \node[transparente] (g90_1) [above = 0.6cm of g9_1] {$\dotsb$}; \node[transparente] (g90_2) [below = 0.5cm of g9_1] {$\dotsb$};

\path
% G1 (g1_2) edge [below] node {k} (g1_1) edge [left, pos=0.3] node {n} (g1_4) edge [left, pos=0.5] node {1} (g1_8) edge [bend left, left, pos=0.5] node {1} (g1_10) (g1_3) edge [below] node {k} (g1_1) edge [right, pos=0.3] node {n} (g1_6) edge [right, pos=0.5] node {1} (g1_9) edge [bend right, right, pos=0.5] node {1} (g1_11) % G2 (g2_2) edge [below] node {k} (g2_1) edge [left, pos=0.3] node {n} (g2_4) edge [left, pos=0.5] node {1} (g2_8) edge [bend left, left, pos=0.5] node {1} (g2_10) (g2_3) edge [below] node {k} (g2_1) edge [right, pos=0.3] node {n} (g2_6) edge [right, pos=0.5] node {1} (g2_9) edge [bend right, right, pos=0.5] node {1} (g2_11) % G3 (g3_2) edge [below] node {k+1} (g3_1) edge [left, pos=0.3] node {n-1} (g3_4) edge [left, pos=0.2] node {1} (g3_5) edge [left, pos=0.5] node {1} (g3_8) edge [bend left, left, pos=0.5] node {1} (g3_10) (g3_3) edge [below] node {k+1} (g3_1) edge [right, pos=0.3] node {n-1} (g3_6) edge [right, pos=0.2] node {1} (g3_7) edge [right, pos=0.5] node {1} (g3_9) edge [bend right, right, pos=0.5] node {1} (g3_11) % G4 (g4_2) edge [below] node {k+1} (g4_1) edge [left, pos=0.3] node {n-1} (g4_4) edge [left, pos=0.2] node {1} (g4_5) edge [left, pos=0.5] node {1} (g4_8) edge [bend left, left, pos=0.5] node {1} (g4_10) (g4_3) edge [below] node {k+1} (g4_1) edge [right, pos=0.3] node {n-1} (g4_6) edge [right, pos=0.2] node {1} (g4_7) edge [right, pos=0.5] node {1} (g4_9) edge [bend right, right, pos=0.5] node {1} (g4_11) % G10 (g10_1) edge [above left, pos=0.5] node {k+1} (g10_2) edge [below left, pos=0.5] node {n} (g10_3) (g10_4) edge [above left, pos=0.4] node {n+2} (g10_3) edge [below right, pos=0.5] node {k} (g10_5) % G5 (g5_1)
edge [left, pos=0.5] node {M-1} (g5_10) edge [above right, pos=0.7] node {M-1} (g5_11) (g5_2)
edge [right, pos=0.8] node {2n-2} (g5_4) edge [right, pos=0.6] node {2n-2} (g5_5) edge [right, pos=0.4] node {2n-2} (g5_6) edge [above left, pos=0.7] node {M-1} (g5_12) edge [above right, pos=0.7] node {M-1} (g5_13) (g5_3)
edge [right, pos=0.8] node {2n-2} (g5_7) edge [right, pos=0.6] node {2n-2} (g5_8) edge [right, pos=0.4] node {2n-2} (g5_9) edge [above left, pos=0.7] node {M-1} (g5_14) edge [above right, pos=0.7] node {M-1} (g5_15) % G6 (g6_1)
edge [above left, pos=0.6] node {1} (g6_2) edge [above right, pos=0.6] node {k+3} (g6_3) edge [above, pos=0.5] node {n} (g6_6) edge [right, pos=0.5] node {1} (g5_11) edge [right, pos=0.5] node {1} (g5_13) edge [below right, pos=0.5] node {1} (g5_15) (g6_4)
edge [right, pos=0.3] node {3M} (g6_3) edge [right, pos=0.3] node {M} (g6_5) % G7
(g7_1) edge [below right, pos=0.5] node {n} (g7_2) edge [above, pos=0.85] node {1} (g7_3) edge [above, pos=0.85] node {1} (g7_4) edge [above, pos=0.85] node {1} (g7_5) edge [left, pos=0.7] node {1} (g7_6) edge [right, pos=0.7] node {1} (g7_7) edge [above, pos=0.85] node {1} (g7_8) edge [above, pos=0.85] node {1} (g7_9) edge [above, pos=0.85] node {1} (g7_10)

% G8 (g8_1) edge [below right, pos=0.5] node {n} (g8_2) edge [below right, pos=0.5] node {} (g8_3) edge [below right, pos=0.5] node {} (g8_4) edge [below right, pos=0.5] node {} (g8_5) edge [below right, pos=0.5] node {} (g80_1) edge [below right, pos=0.5] node {} (g80_2)

% G9 (g9_1) edge [below right, pos=0.5] node {n} (g9_2) edge [below right, pos=0.5] node {} (g9_3) edge [below right, pos=0.5] node {} (g9_4) edge [below right, pos=0.5] node {} (g9_5) edge [below right, pos=0.5] node {} (g90_1) edge [below right, pos=0.5] node {} (g90_2) ;

\draw[flecha] (g10_1) --++ (5.6, 2.5) |- node[above right, pos=0.2] {0.5} (g6_2); \draw[flecha] (g10_1) --++ (4.3, 2.2) -- (4.3, 10.5) -- node[above, pos=0.3] {2M-2} (g4_7); \draw[flecha] (g10_1) --++ (4.2, 3) -- (4.2, 6.5) -- node[above, pos=0.3] {2M-2} (g3_7); \draw[flecha] (g5_1) --++ (0, 3.8) --++ (-7.2, 0) -- node[above, pos=0.8] {2M-2} (g4_10); \draw[flecha] (g10_1) -- ++ (-4.3, 2.2) -- (-4.3, 10.5) -- (g4_5); \draw[flecha] (g10_1) -- ++ (-4.2, 3) -- (-4.2, 6.5) -- (g3_5); \draw[flecha] (g10_4) -- ++ (3, -0.4) -- (4.8, 0) |- (g4_7); \draw[flecha] (g10_4) -- ++ (3, 0.4) -- (4.7, 0) |- (g3_7); \draw[flecha] (g10_4) -- ++ (-3, -0.4) -- (-4.8, 0) |- (g4_5); \draw[flecha] (g10_4) -- ++ (-3, 0.4) -- (-4.7, 0) |- (g3_5); \draw[flecha] (g5_1) -- ++ (-1.3, -0.85) -- (g3_11); \draw[flecha] (g5_1) -- ++ (-1.25, -1) -- ++ (0, -4.2) -- ++ (-5.92, 0) -- (g2_10); \draw[flecha] (g7_1) -- ++ (-0.2, 9) -- ++ (-2.71, 0) -- (g5_10); \draw[flecha] (g7_1) -- ++ (0.2, 9.4) -- ++ (-2.71, 0) --++ (0, 2) -- (g5_12); \draw[flecha] (g7_1) -- ++ (0.35, 5) --++ (4.5, 0) --++ (0, 6.5) -- (g5_14);

\end{tikzpicture} \end{document}

Those three arrows are on the line 280, 281 and 282 in the code.

luki
  • 1,796
Joncarre
  • 315
  • The "elipse node" C1 (from where the three arrows start) is on the line 101. Not sure if that's important to solve the problem. – Joncarre Mar 31 '21 at 11:10
  • 1
    did you try near start, near end, midway – js bibra Mar 31 '21 at 14:14
  • 1
    have a look here -- https://tex.stackexchange.com/a/552191/197451 – js bibra Mar 31 '21 at 14:16
  • 1
    to get an answer strip your code to show only the problem nodes – js bibra Mar 31 '21 at 14:31
  • I think I know the problem but not how to solve it. When I have an arrow that moves through several coordinates, when I want to move the label, it only moves taking as reference the last section of the arrow. For example, in this arrow, I can't get the label to be positioned at the beginning of the arrow (because the beginning is not the "last part" of the arrow): \draw[flecha] (g7_1) -- ++ (-0.2, 9) -- ++ (-2.71, 0) -- node[below right, pos=0.9] {1} (g5_10); – Joncarre Apr 01 '21 at 09:14
  • 1
    so move the node command to the other section of the code -- \draw[flecha] (g7_1) -- ++ (-0.2, 9) node[below right, pos=0.9] {1} -- ++ (-2.71, 0) -- (g5_10); – js bibra Apr 01 '21 at 09:20
  • Oh... that was easy. I tried it but I must have made a mistake with the syntax. Thanks! – Joncarre Apr 01 '21 at 09:25
  • 1
    let us know if it works – js bibra Apr 01 '21 at 09:26
  • Working! Thanks so much! – Joncarre Apr 01 '21 at 09:58

1 Answers1

1

In response to the query by OP

I think I know the problem but not how to solve it. When I have an arrow that moves through several coordinates, when I want to move the label, it only moves taking as reference the last section of the arrow. For example, in this arrow, I can't get the label to be positioned at the beginning of the arrow (because the beginning is not the "last part" of the arrow):

  \draw[flecha] (g7_1) -- ++ (-0.2, 9) -- ++ (-2.71, 0) -- node[below right, pos=0.9] {1} (g5_10);

The solution proposed is—

so move the node command to the other section of the code --

 \draw[flecha] (g7_1) -- ++ (-0.2, 9) node[below right, pos=0.9] {1} -- ++ (-2.71, 0) -- (g5_10);
js bibra
  • 21,280
  • @Joncarre I have added the solution as an answer— request to accept and upvote the answer if it meets the requirements – js bibra Apr 01 '21 at 10:41