1

I am trying to create a node-network using pdflatex and have something very specific in mind. Below, you can find my current minimal example as a tex file that I have a problem with (compilable with pdflatex):

\documentclass[tikz, 11pt,landscape]{article}
\usepackage[default,osfigures,scale=0.95]{opensans}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tgbonum, tikz}
\usetikzlibrary{shapes, calc, arrows.meta, fadings, decorations.pathmorphing, math}
\usepackage[a3paper]{geometry}

\begin{document}
\thispagestyle{empty}

\tikzset{normal/.style = {rectangle split, rectangle split horizontal, rectangle split parts=3, very thick, draw=black, inner sep=0cm, minimum height=0.6cm, text height=1.5ex, text depth=0.25ex}}

\begin{tikzpicture}[remember picture, overlay]
    \path[draw, color=gray, thick] ($(current page.center) + (-10,  0)$) -- ($(current page.center) + (10, 0)$);
    \path[draw, color=gray, thick] ($(current page.center) + (  0,-10)$) -- ($(current page.center) + ( 0,10)$);

    \node[normal] (66) at ($(current page.center) + ( 4.0, 2.0)$) {\nodepart[text width=6mm]{one} \nodepart{two}\rule[-0.25ex]{0pt}{1.75ex}\phantom{j}Node1\phantom{j}\nodepart[text width=6mm]{three}};
    \node[normal] (75) at ($(current page.center) + (-4.0,-0.5)$) {\nodepart[text width=6mm]{one} \nodepart{two}\rule[-0.25ex]{0pt}{1.75ex}\phantom{j}Node2\phantom{j}\nodepart[text width=6mm]{three}};

    %PROBLEM
    \draw[-{Latex[length=3mm]}, very thick] (66.west)--(75.east) node[midway,circle,inner sep=0.5mm,fill=white]{5};
\end{tikzpicture}

\end{document}

This creates a DIN A3 pdf with the following content (zoomed in to show the relevant part):

Minimal example

The only part of the tex file that causes me headaches is the line after the "%PROBLEM"-comment. It draws the connection between the two nodes with a value in the middle. I want to be able to replace this arrow with an arrow that is basically cut in half, with a gap between the two parts, as seen in the following image (I'm giving you my best paint skills here):

enter image description here

The middle should be transparent (not white, as this may overlay other things), and the number that was in the middle of the arrow before should be in the middle of the end piece. Furthermore, The arrow should be colorable (I could figure that out on my own I guess, but it's not my focus now) and I want to be able to control the length of the edge pieces as a fraction of the original distance. So for the situation below:

enter image description here

I want to be able to change the lengths of the parts from 0.3 and 0.2 to 0.4 and 0.5 by just changing two numbers, and not a bunch of calculations. This is important, since this tex file will be programmatically generated and will contain many nodes, so I can't have a lot of special cases. I thought I might approach this by drawing two arrows instead of one and calculating the relevant points. First I calculate the end point (a) and the start point (b) and draw a connection:

\def \a{($(75.east) - (current page.center) + (14.1, -10.9)$)};
\def \b{($(66.west) - (current page.center) + (14.1, -10.9)$)};
\draw[very thick] \b--\a;

For some reason I do not know, the coordinate system of these seems to be offset. Through trial and error I found out that I could negate this offset by subtracting (current page.center) - (14.1, -10,9). This produces:

enter image description here

So: Success. Then I calculate intermediary points (c) and (d) and try to draw two connections:

\def \a{($(75.east) - (current page.center) + (14.1, -10.9)$)};
\def \b{($(66.west) - (current page.center) + (14.1, -10.9)$)};
\def \c{($\a + (0.3 * (\a - \b))$)};
\def \d{($\b - (0.2 * (\a - \b))$)};

\draw[very thick] \c--\a;
\draw[very thick] \b--\d;

Which does not compile with the error:

Runaway argument?
\a + (0.3 * (\a - \b ))$)--\a ; \draw [very thick] \b --\d ; \end {ti\ETC.
! Paragraph ended before \tikz@cc@parse@factor was complete.

And I have absolutely no idea what to do about this. I did a bunch of trial and error without success: rearranging the formulas, trying different draw commands, with and without spacing, braces, parentheses and so on. I also tried to solve this with fading using something like this and making a color transparent, but that seems overly complicated and didn't succeed either. I guess my calculations are wrong? But I am simply way to much of a tex noob to understand why this is failing. I would be glad if any of you can help!

3
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
  \node at (0,0) (start) {text A};

  \node at (2,4) (stop) {text B};

  \draw[red,<-] (start) -- ($(start)!0.3!(stop)$);

  \draw[green,->] (stop) -- ($(stop)!0.2!(start)$);
\end{tikzpicture}

\end{document}

enter image description here

1

You could measure the path length and then use a dash pattern to generate the gap. The advantage of this method is that it works also for curved paths, as illustrated by the red arrow.

\documentclass[tikz, 11pt,landscape]{article}
\usepackage[default,osfigures,scale=0.95]{opensans}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tgbonum, tikz}
\usetikzlibrary{shapes.multipart,calc,arrows.meta,decorations.markings}
\usepackage[a3paper]{geometry}
\newlength{\dividePL}
\begin{document}
\thispagestyle{empty}

\tikzset{normal/.style = {rectangle split, rectangle split horizontal, rectangle split parts=3, very thick, draw=black, inner sep=0cm, minimum height=0.6cm, text height=1.5ex, text depth=0.25ex}}

\begin{tikzpicture}[remember picture, overlay,%
divide/.style={preaction={decorate,decoration={markings,mark=at position 0 with {\global\dividePL=\pgfdecoratedpathlength}}},
dash pattern=on \pgfkeysvalueof{/tikz/divider/on}\dividePL off \pgfkeysvalueof{/tikz/divider/off}\dividePL on \dividePL},
divider/.cd,on/.initial=0.2,off/.initial=0.5]
    \path[draw, color=gray, thick] ($(current page.center) + (-10,  0)$) -- ($(current page.center) + (10, 0)$);
    \path[draw, color=gray, thick] ($(current page.center) + (  0,-10)$) -- ($(current page.center) + ( 0,10)$);

    \node[normal] (66) at ($(current page.center) + ( 4.0, 2.0)$) {\nodepart[text width=6mm]{one} \nodepart{two}\rule[-0.25ex]{0pt}{1.75ex}\phantom{j}Node1\phantom{j}\nodepart[text width=6mm]{three}};
    \node[normal] (75) at ($(current page.center) + (-4.0,-0.5)$) {\nodepart[text width=6mm]{one} \nodepart{two}\rule[-0.25ex]{0pt}{1.75ex}\phantom{j}Node2\phantom{j}\nodepart[text width=6mm]{three}};

    %PROBLEM
    \draw[-{Latex[length=3mm]}, very thick,divide] (66.west)--(75.east) node[pos=0.85,circle,inner sep=0.5mm,fill=white]{5};
    \draw[-{Latex[length=3mm]}, very thick,red,divide] (66.west)to[out=180,in=0] node[pos=0.85,circle,inner sep=0.5mm,fill=white]{5} (75.east);
\end{tikzpicture}

\end{document}

enter image description here

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.