Design an algorithm capable of predicting collisions to choose alternative path using `tikzpicture`...












1















This is and addendum of a previous question: How to connect pics through a set of colorful arrows using tikzpicture environment.



I would like to be able to draw arrows that do not overlap with nodes and/or pictures without having to manually modify each and every one of the arrows that collide with them using tikz.



The MWE is taken from marmot's nice answer:



documentclass{article}
usepackage[margin=0in,footskip=0in,paperwidth=60cm,paperheight=29cm]{geometry}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{hyperref}

usepackage{tikz}
usetikzlibrary{positioning,fit,calc}
pgfdeclarelayer{behind}
pgfdeclarelayer{background}
pgfdeclarelayer{foreground}
pgfsetlayers{behind,background,main,foreground}
tikzset{
text field/.style={text height=1.5ex,align=center,rounded corners},
nonfillable title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
fillable title field/.style={text height=3.14ex,text depth=0em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
pics/fillable subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/fillable elective subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[fillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {hspace*{-0.34em}TextField[align=1,name=#1-electivesubject,width=4.5cm,charsize=8pt,height=.5cm,bordercolor={1 1 1}]{}};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable elective subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
manoooh/.style={column sep=-1.75cm,row sep=5mm},
manooohE/.style={column sep=-2.25cm,row sep=5mm,anchor=south},
electives/.style={column sep=-7.25cm,row sep=5mm},
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style={to path={let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget)}},
manoooh curve/.default=0.3
} % From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3{%
@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
makeatother

begin{document}
thispagestyle{empty} % To suppress page number
noindent
begin{tikzpicture}
fill[white,fill=orange] (0,0) rectangle (paperwidth,-2cm) node[midway,align=center,font=Huge] {bfseries Some text here\LARGE More text here};
end{tikzpicture}

ifdefinedmymatbottom
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi

%typeout{height:myheight}
%typeout{xshifts(in):LstMatXShifts}

vfill
centering
begin{Form}
begin{tikzpicture}
% step 1: add the matrices, name them mat0, mat1 etc.
begin{scope}[local bounding box=matrices]
matrix[manoooh] (mat0) at ({LstMatXShifts[0]},{LstMatYShifts[0]}) {
pic[local bounding box=A] (0) {nonfillable subject={Subject A}}; \
pic (1) {nonfillable subject={Subject B}}; \
};
matrix[manoooh] (mat1) at ({LstMatXShifts[1]},{LstMatYShifts[1]}) {

pic (2) {nonfillable subject={Subject C}}; \
pic (3) {nonfillable subject={Subject D}}; \
pic (4) {nonfillable subject={Subject E}}; \
pic (5) {nonfillable subject={Subject F}}; \
pic (6) {nonfillable subject={Subject G}}; \
pic (7) {nonfillable subject={Subject H}}; \
pic (8) {nonfillable subject={Subject I}}; \
pic[draw=red] (9) {nonfillable subject={Subject J}}; \
};
matrix[manoooh] (mat2) at ({LstMatXShifts[2]},{LstMatYShifts[2]}) {
pic[draw=red] (10) {nonfillable subject={Subject K}}; \
pic (11) {nonfillable subject={Subject L}}; \
pic (12) {nonfillable subject={Subject A}}; \
pic (13) {nonfillable subject={Subject N}}; \
pic (14) {nonfillable subject={Subject O}}; \
pic (15) {nonfillable subject={Subject P}}; \
pic (16) {nonfillable subject={Subject Q}}; \
pic (17) {nonfillable subject={Subject R}}; \
};
matrix[manoooh] (mat3) at ({LstMatXShifts[3]},{LstMatYShifts[3]}) {
pic[draw=red] (18) {nonfillable subject={Subject S}}; \
pic (19) {nonfillable subject={Subject T}}; \
pic (20) {nonfillable subject={Subject U}}; \
pic (21) {nonfillable subject={Subject V}}; \
pic (22) {nonfillable subject={Subject W}}; \
pic (23) {nonfillable subject={Subject X}}; \
pic (24) {nonfillable subject={Subject Y}}; \
pic (25) {nonfillable subject={Subject Z}}; \
};
matrix[manooohE] (matE3) at ({LstMatXShifts[3]},mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; & &
pic (L3E2) {nonfillable elective subject={Subject}}; \
& pic (L3E3) {nonfillable elective subject={Subject}}; & \
};
matrix[manoooh] (mat4) at ({LstMatXShifts[4]},{LstMatYShifts[4]}) {
& pic[draw=red] (26) {nonfillable subject={Subject AA}}; & \
pic (27) {nonfillable subject={Subject AB}}; & & pic (28) {nonfillable subject={Subject AC}}; \
& pic (29) {nonfillable subject={Subject AD}}; & \
& pic (30) {nonfillable subject={Subject AE}}; & \
& pic (31) {nonfillable subject={Subject AF}}; & \
& pic (32) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at ({LstMatXShifts[4]},mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at ({LstMatXShifts[5]},{LstMatYShifts[5]}) {
pic (33) {nonfillable subject={Subject AH}}; \
pic (34) {nonfillable subject={Subject AI}}; \
pic[draw=red] (35) {nonfillable subject={Subject AJ}}; \
pic (36) {nonfillable subject={Subject AK}}; \
};
matrix[manooohE] (matE5) at ({LstMatXShifts[5]},mymatbottom) {
pic (L5E1) {nonfillable elective subject={Subject}}; \
pic (L5E2) {nonfillable elective subject={Subject}}; \
pic (L5E3) {nonfillable elective subject={Subject}}; \
pic (L5E4) {nonfillable elective subject={Subject}}; \
pic (L5E5) {nonfillable elective subject={Subject}}; \
};
end{scope}
pgfmathsetmacro{groupwidth}{0}
pgfmathsetmacro{lastwidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
ifnodedefined{matEX}{% has inlay
node[xshift=1em,anchor=south west,font=LARGEbfseries,opacity=0] (matElX) at (matEX.north west) {Electives};
begin{pgfonlayer}{background}
path let p1=($(matX.north east)-(matX.south west)$) in
node[fit=(matEX) (matElX),inner ysep=5mm,fill=blue!30,rounded
corners=40pt,minimum width=x1-2*pgfkeysvalueof{/tikz/fit sep},
inner xsep=pgfkeysvalueof{/tikz/fit sep}](FX){};
node[xshift=1em,anchor=south west,font=LARGEbfseries]
(matElX) at ([xshift=1.3em]FX.west|-matElX.center) {Electives};
end{pgfonlayer}
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(FX.north east)-(FX.south west)$),
n1={max(abs(y1)/2+abs(y2)/2+0*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+max(x1,x2)/2+lastwidth/2+2*pgfkeysvalueof{/tikz/fit sep}+pgfkeysvalueof{/tikz/fit dist}}
fi
pgfmathsetmacro{lastwidth}{max(x1,x2)+8*pgfkeysvalueof{/tikz/fit sep}}
xdeflastwidth{lastwidth}
xdefgroupwidth{groupwidth}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatYShifts{myshift pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,myshift pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south)
(matEX) (matElX),inner ysep=8mm,inner xsep=4*pgfkeysvalueof{/tikz/fit sep},
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1={max(abs(y1)/2,mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+x1/2+lastwidth/2+pgfkeysvalueof{/tikz/fit dist}}
fi
xdefgroupwidth{groupwidth}
xdeflastwidth{x1}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmyheight{myheight}
ifnumX=0
xdefLstMatYShifts{0pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,0pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=8mm,
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}
}
}
makeatletter
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatYShifts{{LstMatYShifts}}relax}
immediatewrite@mainaux{xdefstringLstMatXShifts{{LstMatXShifts}}relax}
makeatother

newcommandtotalnodes{5} % Define the total of subjects that need arrows-1

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10,13,14}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25}",%subjects that 3 links
"{36}",%subjects that 8 links
}
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
foreach Y in mylst {
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
}
}
end{tikzpicture}
end{Form}

vfill

end{document}


MWE



We would be able to see those arrows using something like this paths:



What I want



As you can see, some yellow, lightblue and the blue arrows have undergone changes due to the collision of one (or more) pics.



It is preferable that the algorithm detects that if many colors circulate in the same path, choose another one, since it would be visually confusing to have many colors in the same passage. For example:



Example of what I want



If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.



Thanks!!










share|improve this question




















  • 1





    I do not think there will be an easy algorithm that detects if some path already travelled through the same gap. What is possible is to add some style that draws a curve through gaps that you specify,

    – marmot
    1 hour ago











  • @marmot I do not think it is feasible to specify the path, since the diagram may suffer alterations in the positions of the objects, so the paths must be modified manually. If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.

    – manooooh
    1 hour ago
















1















This is and addendum of a previous question: How to connect pics through a set of colorful arrows using tikzpicture environment.



I would like to be able to draw arrows that do not overlap with nodes and/or pictures without having to manually modify each and every one of the arrows that collide with them using tikz.



The MWE is taken from marmot's nice answer:



documentclass{article}
usepackage[margin=0in,footskip=0in,paperwidth=60cm,paperheight=29cm]{geometry}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{hyperref}

usepackage{tikz}
usetikzlibrary{positioning,fit,calc}
pgfdeclarelayer{behind}
pgfdeclarelayer{background}
pgfdeclarelayer{foreground}
pgfsetlayers{behind,background,main,foreground}
tikzset{
text field/.style={text height=1.5ex,align=center,rounded corners},
nonfillable title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
fillable title field/.style={text height=3.14ex,text depth=0em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
pics/fillable subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/fillable elective subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[fillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {hspace*{-0.34em}TextField[align=1,name=#1-electivesubject,width=4.5cm,charsize=8pt,height=.5cm,bordercolor={1 1 1}]{}};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable elective subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
manoooh/.style={column sep=-1.75cm,row sep=5mm},
manooohE/.style={column sep=-2.25cm,row sep=5mm,anchor=south},
electives/.style={column sep=-7.25cm,row sep=5mm},
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style={to path={let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget)}},
manoooh curve/.default=0.3
} % From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3{%
@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
makeatother

begin{document}
thispagestyle{empty} % To suppress page number
noindent
begin{tikzpicture}
fill[white,fill=orange] (0,0) rectangle (paperwidth,-2cm) node[midway,align=center,font=Huge] {bfseries Some text here\LARGE More text here};
end{tikzpicture}

ifdefinedmymatbottom
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi

%typeout{height:myheight}
%typeout{xshifts(in):LstMatXShifts}

vfill
centering
begin{Form}
begin{tikzpicture}
% step 1: add the matrices, name them mat0, mat1 etc.
begin{scope}[local bounding box=matrices]
matrix[manoooh] (mat0) at ({LstMatXShifts[0]},{LstMatYShifts[0]}) {
pic[local bounding box=A] (0) {nonfillable subject={Subject A}}; \
pic (1) {nonfillable subject={Subject B}}; \
};
matrix[manoooh] (mat1) at ({LstMatXShifts[1]},{LstMatYShifts[1]}) {

pic (2) {nonfillable subject={Subject C}}; \
pic (3) {nonfillable subject={Subject D}}; \
pic (4) {nonfillable subject={Subject E}}; \
pic (5) {nonfillable subject={Subject F}}; \
pic (6) {nonfillable subject={Subject G}}; \
pic (7) {nonfillable subject={Subject H}}; \
pic (8) {nonfillable subject={Subject I}}; \
pic[draw=red] (9) {nonfillable subject={Subject J}}; \
};
matrix[manoooh] (mat2) at ({LstMatXShifts[2]},{LstMatYShifts[2]}) {
pic[draw=red] (10) {nonfillable subject={Subject K}}; \
pic (11) {nonfillable subject={Subject L}}; \
pic (12) {nonfillable subject={Subject A}}; \
pic (13) {nonfillable subject={Subject N}}; \
pic (14) {nonfillable subject={Subject O}}; \
pic (15) {nonfillable subject={Subject P}}; \
pic (16) {nonfillable subject={Subject Q}}; \
pic (17) {nonfillable subject={Subject R}}; \
};
matrix[manoooh] (mat3) at ({LstMatXShifts[3]},{LstMatYShifts[3]}) {
pic[draw=red] (18) {nonfillable subject={Subject S}}; \
pic (19) {nonfillable subject={Subject T}}; \
pic (20) {nonfillable subject={Subject U}}; \
pic (21) {nonfillable subject={Subject V}}; \
pic (22) {nonfillable subject={Subject W}}; \
pic (23) {nonfillable subject={Subject X}}; \
pic (24) {nonfillable subject={Subject Y}}; \
pic (25) {nonfillable subject={Subject Z}}; \
};
matrix[manooohE] (matE3) at ({LstMatXShifts[3]},mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; & &
pic (L3E2) {nonfillable elective subject={Subject}}; \
& pic (L3E3) {nonfillable elective subject={Subject}}; & \
};
matrix[manoooh] (mat4) at ({LstMatXShifts[4]},{LstMatYShifts[4]}) {
& pic[draw=red] (26) {nonfillable subject={Subject AA}}; & \
pic (27) {nonfillable subject={Subject AB}}; & & pic (28) {nonfillable subject={Subject AC}}; \
& pic (29) {nonfillable subject={Subject AD}}; & \
& pic (30) {nonfillable subject={Subject AE}}; & \
& pic (31) {nonfillable subject={Subject AF}}; & \
& pic (32) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at ({LstMatXShifts[4]},mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at ({LstMatXShifts[5]},{LstMatYShifts[5]}) {
pic (33) {nonfillable subject={Subject AH}}; \
pic (34) {nonfillable subject={Subject AI}}; \
pic[draw=red] (35) {nonfillable subject={Subject AJ}}; \
pic (36) {nonfillable subject={Subject AK}}; \
};
matrix[manooohE] (matE5) at ({LstMatXShifts[5]},mymatbottom) {
pic (L5E1) {nonfillable elective subject={Subject}}; \
pic (L5E2) {nonfillable elective subject={Subject}}; \
pic (L5E3) {nonfillable elective subject={Subject}}; \
pic (L5E4) {nonfillable elective subject={Subject}}; \
pic (L5E5) {nonfillable elective subject={Subject}}; \
};
end{scope}
pgfmathsetmacro{groupwidth}{0}
pgfmathsetmacro{lastwidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
ifnodedefined{matEX}{% has inlay
node[xshift=1em,anchor=south west,font=LARGEbfseries,opacity=0] (matElX) at (matEX.north west) {Electives};
begin{pgfonlayer}{background}
path let p1=($(matX.north east)-(matX.south west)$) in
node[fit=(matEX) (matElX),inner ysep=5mm,fill=blue!30,rounded
corners=40pt,minimum width=x1-2*pgfkeysvalueof{/tikz/fit sep},
inner xsep=pgfkeysvalueof{/tikz/fit sep}](FX){};
node[xshift=1em,anchor=south west,font=LARGEbfseries]
(matElX) at ([xshift=1.3em]FX.west|-matElX.center) {Electives};
end{pgfonlayer}
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(FX.north east)-(FX.south west)$),
n1={max(abs(y1)/2+abs(y2)/2+0*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+max(x1,x2)/2+lastwidth/2+2*pgfkeysvalueof{/tikz/fit sep}+pgfkeysvalueof{/tikz/fit dist}}
fi
pgfmathsetmacro{lastwidth}{max(x1,x2)+8*pgfkeysvalueof{/tikz/fit sep}}
xdeflastwidth{lastwidth}
xdefgroupwidth{groupwidth}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatYShifts{myshift pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,myshift pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south)
(matEX) (matElX),inner ysep=8mm,inner xsep=4*pgfkeysvalueof{/tikz/fit sep},
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1={max(abs(y1)/2,mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+x1/2+lastwidth/2+pgfkeysvalueof{/tikz/fit dist}}
fi
xdefgroupwidth{groupwidth}
xdeflastwidth{x1}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmyheight{myheight}
ifnumX=0
xdefLstMatYShifts{0pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,0pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=8mm,
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}
}
}
makeatletter
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatYShifts{{LstMatYShifts}}relax}
immediatewrite@mainaux{xdefstringLstMatXShifts{{LstMatXShifts}}relax}
makeatother

newcommandtotalnodes{5} % Define the total of subjects that need arrows-1

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10,13,14}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25}",%subjects that 3 links
"{36}",%subjects that 8 links
}
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
foreach Y in mylst {
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
}
}
end{tikzpicture}
end{Form}

vfill

end{document}


MWE



We would be able to see those arrows using something like this paths:



What I want



As you can see, some yellow, lightblue and the blue arrows have undergone changes due to the collision of one (or more) pics.



It is preferable that the algorithm detects that if many colors circulate in the same path, choose another one, since it would be visually confusing to have many colors in the same passage. For example:



Example of what I want



If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.



Thanks!!










share|improve this question




















  • 1





    I do not think there will be an easy algorithm that detects if some path already travelled through the same gap. What is possible is to add some style that draws a curve through gaps that you specify,

    – marmot
    1 hour ago











  • @marmot I do not think it is feasible to specify the path, since the diagram may suffer alterations in the positions of the objects, so the paths must be modified manually. If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.

    – manooooh
    1 hour ago














1












1








1








This is and addendum of a previous question: How to connect pics through a set of colorful arrows using tikzpicture environment.



I would like to be able to draw arrows that do not overlap with nodes and/or pictures without having to manually modify each and every one of the arrows that collide with them using tikz.



The MWE is taken from marmot's nice answer:



documentclass{article}
usepackage[margin=0in,footskip=0in,paperwidth=60cm,paperheight=29cm]{geometry}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{hyperref}

usepackage{tikz}
usetikzlibrary{positioning,fit,calc}
pgfdeclarelayer{behind}
pgfdeclarelayer{background}
pgfdeclarelayer{foreground}
pgfsetlayers{behind,background,main,foreground}
tikzset{
text field/.style={text height=1.5ex,align=center,rounded corners},
nonfillable title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
fillable title field/.style={text height=3.14ex,text depth=0em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
pics/fillable subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/fillable elective subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[fillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {hspace*{-0.34em}TextField[align=1,name=#1-electivesubject,width=4.5cm,charsize=8pt,height=.5cm,bordercolor={1 1 1}]{}};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable elective subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
manoooh/.style={column sep=-1.75cm,row sep=5mm},
manooohE/.style={column sep=-2.25cm,row sep=5mm,anchor=south},
electives/.style={column sep=-7.25cm,row sep=5mm},
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style={to path={let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget)}},
manoooh curve/.default=0.3
} % From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3{%
@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
makeatother

begin{document}
thispagestyle{empty} % To suppress page number
noindent
begin{tikzpicture}
fill[white,fill=orange] (0,0) rectangle (paperwidth,-2cm) node[midway,align=center,font=Huge] {bfseries Some text here\LARGE More text here};
end{tikzpicture}

ifdefinedmymatbottom
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi

%typeout{height:myheight}
%typeout{xshifts(in):LstMatXShifts}

vfill
centering
begin{Form}
begin{tikzpicture}
% step 1: add the matrices, name them mat0, mat1 etc.
begin{scope}[local bounding box=matrices]
matrix[manoooh] (mat0) at ({LstMatXShifts[0]},{LstMatYShifts[0]}) {
pic[local bounding box=A] (0) {nonfillable subject={Subject A}}; \
pic (1) {nonfillable subject={Subject B}}; \
};
matrix[manoooh] (mat1) at ({LstMatXShifts[1]},{LstMatYShifts[1]}) {

pic (2) {nonfillable subject={Subject C}}; \
pic (3) {nonfillable subject={Subject D}}; \
pic (4) {nonfillable subject={Subject E}}; \
pic (5) {nonfillable subject={Subject F}}; \
pic (6) {nonfillable subject={Subject G}}; \
pic (7) {nonfillable subject={Subject H}}; \
pic (8) {nonfillable subject={Subject I}}; \
pic[draw=red] (9) {nonfillable subject={Subject J}}; \
};
matrix[manoooh] (mat2) at ({LstMatXShifts[2]},{LstMatYShifts[2]}) {
pic[draw=red] (10) {nonfillable subject={Subject K}}; \
pic (11) {nonfillable subject={Subject L}}; \
pic (12) {nonfillable subject={Subject A}}; \
pic (13) {nonfillable subject={Subject N}}; \
pic (14) {nonfillable subject={Subject O}}; \
pic (15) {nonfillable subject={Subject P}}; \
pic (16) {nonfillable subject={Subject Q}}; \
pic (17) {nonfillable subject={Subject R}}; \
};
matrix[manoooh] (mat3) at ({LstMatXShifts[3]},{LstMatYShifts[3]}) {
pic[draw=red] (18) {nonfillable subject={Subject S}}; \
pic (19) {nonfillable subject={Subject T}}; \
pic (20) {nonfillable subject={Subject U}}; \
pic (21) {nonfillable subject={Subject V}}; \
pic (22) {nonfillable subject={Subject W}}; \
pic (23) {nonfillable subject={Subject X}}; \
pic (24) {nonfillable subject={Subject Y}}; \
pic (25) {nonfillable subject={Subject Z}}; \
};
matrix[manooohE] (matE3) at ({LstMatXShifts[3]},mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; & &
pic (L3E2) {nonfillable elective subject={Subject}}; \
& pic (L3E3) {nonfillable elective subject={Subject}}; & \
};
matrix[manoooh] (mat4) at ({LstMatXShifts[4]},{LstMatYShifts[4]}) {
& pic[draw=red] (26) {nonfillable subject={Subject AA}}; & \
pic (27) {nonfillable subject={Subject AB}}; & & pic (28) {nonfillable subject={Subject AC}}; \
& pic (29) {nonfillable subject={Subject AD}}; & \
& pic (30) {nonfillable subject={Subject AE}}; & \
& pic (31) {nonfillable subject={Subject AF}}; & \
& pic (32) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at ({LstMatXShifts[4]},mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at ({LstMatXShifts[5]},{LstMatYShifts[5]}) {
pic (33) {nonfillable subject={Subject AH}}; \
pic (34) {nonfillable subject={Subject AI}}; \
pic[draw=red] (35) {nonfillable subject={Subject AJ}}; \
pic (36) {nonfillable subject={Subject AK}}; \
};
matrix[manooohE] (matE5) at ({LstMatXShifts[5]},mymatbottom) {
pic (L5E1) {nonfillable elective subject={Subject}}; \
pic (L5E2) {nonfillable elective subject={Subject}}; \
pic (L5E3) {nonfillable elective subject={Subject}}; \
pic (L5E4) {nonfillable elective subject={Subject}}; \
pic (L5E5) {nonfillable elective subject={Subject}}; \
};
end{scope}
pgfmathsetmacro{groupwidth}{0}
pgfmathsetmacro{lastwidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
ifnodedefined{matEX}{% has inlay
node[xshift=1em,anchor=south west,font=LARGEbfseries,opacity=0] (matElX) at (matEX.north west) {Electives};
begin{pgfonlayer}{background}
path let p1=($(matX.north east)-(matX.south west)$) in
node[fit=(matEX) (matElX),inner ysep=5mm,fill=blue!30,rounded
corners=40pt,minimum width=x1-2*pgfkeysvalueof{/tikz/fit sep},
inner xsep=pgfkeysvalueof{/tikz/fit sep}](FX){};
node[xshift=1em,anchor=south west,font=LARGEbfseries]
(matElX) at ([xshift=1.3em]FX.west|-matElX.center) {Electives};
end{pgfonlayer}
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(FX.north east)-(FX.south west)$),
n1={max(abs(y1)/2+abs(y2)/2+0*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+max(x1,x2)/2+lastwidth/2+2*pgfkeysvalueof{/tikz/fit sep}+pgfkeysvalueof{/tikz/fit dist}}
fi
pgfmathsetmacro{lastwidth}{max(x1,x2)+8*pgfkeysvalueof{/tikz/fit sep}}
xdeflastwidth{lastwidth}
xdefgroupwidth{groupwidth}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatYShifts{myshift pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,myshift pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south)
(matEX) (matElX),inner ysep=8mm,inner xsep=4*pgfkeysvalueof{/tikz/fit sep},
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1={max(abs(y1)/2,mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+x1/2+lastwidth/2+pgfkeysvalueof{/tikz/fit dist}}
fi
xdefgroupwidth{groupwidth}
xdeflastwidth{x1}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmyheight{myheight}
ifnumX=0
xdefLstMatYShifts{0pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,0pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=8mm,
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}
}
}
makeatletter
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatYShifts{{LstMatYShifts}}relax}
immediatewrite@mainaux{xdefstringLstMatXShifts{{LstMatXShifts}}relax}
makeatother

newcommandtotalnodes{5} % Define the total of subjects that need arrows-1

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10,13,14}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25}",%subjects that 3 links
"{36}",%subjects that 8 links
}
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
foreach Y in mylst {
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
}
}
end{tikzpicture}
end{Form}

vfill

end{document}


MWE



We would be able to see those arrows using something like this paths:



What I want



As you can see, some yellow, lightblue and the blue arrows have undergone changes due to the collision of one (or more) pics.



It is preferable that the algorithm detects that if many colors circulate in the same path, choose another one, since it would be visually confusing to have many colors in the same passage. For example:



Example of what I want



If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.



Thanks!!










share|improve this question
















This is and addendum of a previous question: How to connect pics through a set of colorful arrows using tikzpicture environment.



I would like to be able to draw arrows that do not overlap with nodes and/or pictures without having to manually modify each and every one of the arrows that collide with them using tikz.



The MWE is taken from marmot's nice answer:



documentclass{article}
usepackage[margin=0in,footskip=0in,paperwidth=60cm,paperheight=29cm]{geometry}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{hyperref}

usepackage{tikz}
usetikzlibrary{positioning,fit,calc}
pgfdeclarelayer{behind}
pgfdeclarelayer{background}
pgfdeclarelayer{foreground}
pgfsetlayers{behind,background,main,foreground}
tikzset{
text field/.style={text height=1.5ex,align=center,rounded corners},
nonfillable title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
fillable title field/.style={text height=3.14ex,text depth=0em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
pics/fillable subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/fillable elective subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[fillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {hspace*{-0.34em}TextField[align=1,name=#1-electivesubject,width=4.5cm,charsize=8pt,height=.5cm,bordercolor={1 1 1}]{}};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable elective subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
manoooh/.style={column sep=-1.75cm,row sep=5mm},
manooohE/.style={column sep=-2.25cm,row sep=5mm,anchor=south},
electives/.style={column sep=-7.25cm,row sep=5mm},
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style={to path={let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget)}},
manoooh curve/.default=0.3
} % From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3{%
@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
makeatother

begin{document}
thispagestyle{empty} % To suppress page number
noindent
begin{tikzpicture}
fill[white,fill=orange] (0,0) rectangle (paperwidth,-2cm) node[midway,align=center,font=Huge] {bfseries Some text here\LARGE More text here};
end{tikzpicture}

ifdefinedmymatbottom
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi

%typeout{height:myheight}
%typeout{xshifts(in):LstMatXShifts}

vfill
centering
begin{Form}
begin{tikzpicture}
% step 1: add the matrices, name them mat0, mat1 etc.
begin{scope}[local bounding box=matrices]
matrix[manoooh] (mat0) at ({LstMatXShifts[0]},{LstMatYShifts[0]}) {
pic[local bounding box=A] (0) {nonfillable subject={Subject A}}; \
pic (1) {nonfillable subject={Subject B}}; \
};
matrix[manoooh] (mat1) at ({LstMatXShifts[1]},{LstMatYShifts[1]}) {

pic (2) {nonfillable subject={Subject C}}; \
pic (3) {nonfillable subject={Subject D}}; \
pic (4) {nonfillable subject={Subject E}}; \
pic (5) {nonfillable subject={Subject F}}; \
pic (6) {nonfillable subject={Subject G}}; \
pic (7) {nonfillable subject={Subject H}}; \
pic (8) {nonfillable subject={Subject I}}; \
pic[draw=red] (9) {nonfillable subject={Subject J}}; \
};
matrix[manoooh] (mat2) at ({LstMatXShifts[2]},{LstMatYShifts[2]}) {
pic[draw=red] (10) {nonfillable subject={Subject K}}; \
pic (11) {nonfillable subject={Subject L}}; \
pic (12) {nonfillable subject={Subject A}}; \
pic (13) {nonfillable subject={Subject N}}; \
pic (14) {nonfillable subject={Subject O}}; \
pic (15) {nonfillable subject={Subject P}}; \
pic (16) {nonfillable subject={Subject Q}}; \
pic (17) {nonfillable subject={Subject R}}; \
};
matrix[manoooh] (mat3) at ({LstMatXShifts[3]},{LstMatYShifts[3]}) {
pic[draw=red] (18) {nonfillable subject={Subject S}}; \
pic (19) {nonfillable subject={Subject T}}; \
pic (20) {nonfillable subject={Subject U}}; \
pic (21) {nonfillable subject={Subject V}}; \
pic (22) {nonfillable subject={Subject W}}; \
pic (23) {nonfillable subject={Subject X}}; \
pic (24) {nonfillable subject={Subject Y}}; \
pic (25) {nonfillable subject={Subject Z}}; \
};
matrix[manooohE] (matE3) at ({LstMatXShifts[3]},mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; & &
pic (L3E2) {nonfillable elective subject={Subject}}; \
& pic (L3E3) {nonfillable elective subject={Subject}}; & \
};
matrix[manoooh] (mat4) at ({LstMatXShifts[4]},{LstMatYShifts[4]}) {
& pic[draw=red] (26) {nonfillable subject={Subject AA}}; & \
pic (27) {nonfillable subject={Subject AB}}; & & pic (28) {nonfillable subject={Subject AC}}; \
& pic (29) {nonfillable subject={Subject AD}}; & \
& pic (30) {nonfillable subject={Subject AE}}; & \
& pic (31) {nonfillable subject={Subject AF}}; & \
& pic (32) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at ({LstMatXShifts[4]},mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at ({LstMatXShifts[5]},{LstMatYShifts[5]}) {
pic (33) {nonfillable subject={Subject AH}}; \
pic (34) {nonfillable subject={Subject AI}}; \
pic[draw=red] (35) {nonfillable subject={Subject AJ}}; \
pic (36) {nonfillable subject={Subject AK}}; \
};
matrix[manooohE] (matE5) at ({LstMatXShifts[5]},mymatbottom) {
pic (L5E1) {nonfillable elective subject={Subject}}; \
pic (L5E2) {nonfillable elective subject={Subject}}; \
pic (L5E3) {nonfillable elective subject={Subject}}; \
pic (L5E4) {nonfillable elective subject={Subject}}; \
pic (L5E5) {nonfillable elective subject={Subject}}; \
};
end{scope}
pgfmathsetmacro{groupwidth}{0}
pgfmathsetmacro{lastwidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
ifnodedefined{matEX}{% has inlay
node[xshift=1em,anchor=south west,font=LARGEbfseries,opacity=0] (matElX) at (matEX.north west) {Electives};
begin{pgfonlayer}{background}
path let p1=($(matX.north east)-(matX.south west)$) in
node[fit=(matEX) (matElX),inner ysep=5mm,fill=blue!30,rounded
corners=40pt,minimum width=x1-2*pgfkeysvalueof{/tikz/fit sep},
inner xsep=pgfkeysvalueof{/tikz/fit sep}](FX){};
node[xshift=1em,anchor=south west,font=LARGEbfseries]
(matElX) at ([xshift=1.3em]FX.west|-matElX.center) {Electives};
end{pgfonlayer}
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(FX.north east)-(FX.south west)$),
n1={max(abs(y1)/2+abs(y2)/2+0*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+max(x1,x2)/2+lastwidth/2+2*pgfkeysvalueof{/tikz/fit sep}+pgfkeysvalueof{/tikz/fit dist}}
fi
pgfmathsetmacro{lastwidth}{max(x1,x2)+8*pgfkeysvalueof{/tikz/fit sep}}
xdeflastwidth{lastwidth}
xdefgroupwidth{groupwidth}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatYShifts{myshift pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,myshift pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south)
(matEX) (matElX),inner ysep=8mm,inner xsep=4*pgfkeysvalueof{/tikz/fit sep},
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1={max(abs(y1)/2,mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+x1/2+lastwidth/2+pgfkeysvalueof{/tikz/fit dist}}
fi
xdefgroupwidth{groupwidth}
xdeflastwidth{x1}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmyheight{myheight}
ifnumX=0
xdefLstMatYShifts{0pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,0pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=8mm,
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}
}
}
makeatletter
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatYShifts{{LstMatYShifts}}relax}
immediatewrite@mainaux{xdefstringLstMatXShifts{{LstMatXShifts}}relax}
makeatother

newcommandtotalnodes{5} % Define the total of subjects that need arrows-1

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10,13,14}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25}",%subjects that 3 links
"{36}",%subjects that 8 links
}
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
foreach Y in mylst {
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
}
}
end{tikzpicture}
end{Form}

vfill

end{document}


MWE



We would be able to see those arrows using something like this paths:



What I want



As you can see, some yellow, lightblue and the blue arrows have undergone changes due to the collision of one (or more) pics.



It is preferable that the algorithm detects that if many colors circulate in the same path, choose another one, since it would be visually confusing to have many colors in the same passage. For example:



Example of what I want



If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.



Thanks!!







tikz-pgf positioning diagrams arrows






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago







manooooh

















asked 1 hour ago









manoooohmanooooh

1,1471517




1,1471517








  • 1





    I do not think there will be an easy algorithm that detects if some path already travelled through the same gap. What is possible is to add some style that draws a curve through gaps that you specify,

    – marmot
    1 hour ago











  • @marmot I do not think it is feasible to specify the path, since the diagram may suffer alterations in the positions of the objects, so the paths must be modified manually. If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.

    – manooooh
    1 hour ago














  • 1





    I do not think there will be an easy algorithm that detects if some path already travelled through the same gap. What is possible is to add some style that draws a curve through gaps that you specify,

    – marmot
    1 hour ago











  • @marmot I do not think it is feasible to specify the path, since the diagram may suffer alterations in the positions of the objects, so the paths must be modified manually. If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.

    – manooooh
    1 hour ago








1




1





I do not think there will be an easy algorithm that detects if some path already travelled through the same gap. What is possible is to add some style that draws a curve through gaps that you specify,

– marmot
1 hour ago





I do not think there will be an easy algorithm that detects if some path already travelled through the same gap. What is possible is to add some style that draws a curve through gaps that you specify,

– marmot
1 hour ago













@marmot I do not think it is feasible to specify the path, since the diagram may suffer alterations in the positions of the objects, so the paths must be modified manually. If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.

– manooooh
1 hour ago





@marmot I do not think it is feasible to specify the path, since the diagram may suffer alterations in the positions of the objects, so the paths must be modified manually. If the detection of a lot of arrow traffic is a computational problem, leave it, it is not very important, I am satisfied with the automatic paths.

– manooooh
1 hour ago










1 Answer
1






active

oldest

votes


















3














Here is a first proposal. You only need to say



draw[-latex,blue,very thick] (4-Title.east) 
[along node/.list={12,21,29}]
to[manoooh curve] (36-Title.west);


to get



enter image description here



As you can see, the path runs north of the forms 12, 21, 29.



And as for your loop: you could specify the nodes along which the path should run in lists.



documentclass{article}
usepackage[margin=0in,footskip=0in,paperwidth=60cm,paperheight=29cm]{geometry}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{hyperref}

usepackage{tikz}
usetikzlibrary{positioning,fit,calc}
pgfdeclarelayer{behind}
pgfdeclarelayer{background}
pgfdeclarelayer{foreground}
pgfsetlayers{behind,background,main,foreground}
tikzset{
text field/.style={text height=1.5ex,align=center,rounded corners},
nonfillable title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
fillable title field/.style={text height=3.14ex,text depth=0em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
pics/fillable subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/fillable elective subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[fillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {hspace*{-0.34em}TextField[align=1,name=#1-electivesubject,width=4.5cm,charsize=8pt,height=.5cm,bordercolor={1 1 1}]{}};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable elective subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
manoooh/.style={column sep=-1.75cm,row sep=5mm},
manooohE/.style={column sep=-2.25cm,row sep=5mm,anchor=south},
electives/.style={column sep=-7.25cm,row sep=5mm},
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style={to path={let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget)}},
manoooh curve/.default=0.3,
along node/.style={insert path={
to[out=0,in=180]
([yshift=5pt]#1-Title.north west) -- ([yshift=5pt]#1-Title.north east)}}
} % From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3{%
@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
makeatother

begin{document}
thispagestyle{empty} % To suppress page number
noindent
begin{tikzpicture}
fill[white,fill=orange] (0,0) rectangle (paperwidth,-2cm) node[midway,align=center,font=Huge] {bfseries Some text here\LARGE More text here};
end{tikzpicture}

ifdefinedmymatbottom
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi

%typeout{height:myheight}
%typeout{xshifts(in):LstMatXShifts}

vfill
centering
begin{Form}
begin{tikzpicture}
% step 1: add the matrices, name them mat0, mat1 etc.
begin{scope}[local bounding box=matrices]
matrix[manoooh] (mat0) at ({LstMatXShifts[0]},{LstMatYShifts[0]}) {
pic[local bounding box=A] (0) {nonfillable subject={Subject A}}; \
pic (1) {nonfillable subject={Subject B}}; \
};
matrix[manoooh] (mat1) at ({LstMatXShifts[1]},{LstMatYShifts[1]}) {

pic (2) {nonfillable subject={Subject C}}; \
pic (3) {nonfillable subject={Subject D}}; \
pic (4) {nonfillable subject={Subject E}}; \
pic (5) {nonfillable subject={Subject F}}; \
pic (6) {nonfillable subject={Subject G}}; \
pic (7) {nonfillable subject={Subject H}}; \
pic (8) {nonfillable subject={Subject I}}; \
pic[draw=red] (9) {nonfillable subject={Subject J}}; \
};
matrix[manoooh] (mat2) at ({LstMatXShifts[2]},{LstMatYShifts[2]}) {
pic[draw=red] (10) {nonfillable subject={Subject K}}; \
pic (11) {nonfillable subject={Subject L}}; \
pic (12) {nonfillable subject={Subject A}}; \
pic (13) {nonfillable subject={Subject N}}; \
pic (14) {nonfillable subject={Subject O}}; \
pic (15) {nonfillable subject={Subject P}}; \
pic (16) {nonfillable subject={Subject Q}}; \
pic (17) {nonfillable subject={Subject R}}; \
};
matrix[manoooh] (mat3) at ({LstMatXShifts[3]},{LstMatYShifts[3]}) {
pic[draw=red] (18) {nonfillable subject={Subject S}}; \
pic (19) {nonfillable subject={Subject T}}; \
pic (20) {nonfillable subject={Subject U}}; \
pic (21) {nonfillable subject={Subject V}}; \
pic (22) {nonfillable subject={Subject W}}; \
pic (23) {nonfillable subject={Subject X}}; \
pic (24) {nonfillable subject={Subject Y}}; \
pic (25) {nonfillable subject={Subject Z}}; \
};
matrix[manooohE] (matE3) at ({LstMatXShifts[3]},mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; & &
pic (L3E2) {nonfillable elective subject={Subject}}; \
& pic (L3E3) {nonfillable elective subject={Subject}}; & \
};
matrix[manoooh] (mat4) at ({LstMatXShifts[4]},{LstMatYShifts[4]}) {
& pic[draw=red] (26) {nonfillable subject={Subject AA}}; & \
pic (27) {nonfillable subject={Subject AB}}; & & pic (28) {nonfillable subject={Subject AC}}; \
& pic (29) {nonfillable subject={Subject AD}}; & \
& pic (30) {nonfillable subject={Subject AE}}; & \
& pic (31) {nonfillable subject={Subject AF}}; & \
& pic (32) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at ({LstMatXShifts[4]},mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at ({LstMatXShifts[5]},{LstMatYShifts[5]}) {
pic (33) {nonfillable subject={Subject AH}}; \
pic (34) {nonfillable subject={Subject AI}}; \
pic[draw=red] (35) {nonfillable subject={Subject AJ}}; \
pic (36) {nonfillable subject={Subject AK}}; \
};
matrix[manooohE] (matE5) at ({LstMatXShifts[5]},mymatbottom) {
pic (L5E1) {nonfillable elective subject={Subject}}; \
pic (L5E2) {nonfillable elective subject={Subject}}; \
pic (L5E3) {nonfillable elective subject={Subject}}; \
pic (L5E4) {nonfillable elective subject={Subject}}; \
pic (L5E5) {nonfillable elective subject={Subject}}; \
};
end{scope}
pgfmathsetmacro{groupwidth}{0}
pgfmathsetmacro{lastwidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
ifnodedefined{matEX}{% has inlay
node[xshift=1em,anchor=south west,font=LARGEbfseries,opacity=0] (matElX) at (matEX.north west) {Electives};
begin{pgfonlayer}{background}
path let p1=($(matX.north east)-(matX.south west)$) in
node[fit=(matEX) (matElX),inner ysep=5mm,fill=blue!30,rounded
corners=40pt,minimum width=x1-2*pgfkeysvalueof{/tikz/fit sep},
inner xsep=pgfkeysvalueof{/tikz/fit sep}](FX){};
node[xshift=1em,anchor=south west,font=LARGEbfseries]
(matElX) at ([xshift=1.3em]FX.west|-matElX.center) {Electives};
end{pgfonlayer}
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(FX.north east)-(FX.south west)$),
n1={max(abs(y1)/2+abs(y2)/2+0*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+max(x1,x2)/2+lastwidth/2+2*pgfkeysvalueof{/tikz/fit sep}+pgfkeysvalueof{/tikz/fit dist}}
fi
pgfmathsetmacro{lastwidth}{max(x1,x2)+8*pgfkeysvalueof{/tikz/fit sep}}
xdeflastwidth{lastwidth}
xdefgroupwidth{groupwidth}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatYShifts{myshift pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,myshift pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south)
(matEX) (matElX),inner ysep=8mm,inner xsep=4*pgfkeysvalueof{/tikz/fit sep},
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1={max(abs(y1)/2,mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+x1/2+lastwidth/2+pgfkeysvalueof{/tikz/fit dist}}
fi
xdefgroupwidth{groupwidth}
xdeflastwidth{x1}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmyheight{myheight}
ifnumX=0
xdefLstMatYShifts{0pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,0pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=8mm,
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}
}
}
makeatletter
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatYShifts{{LstMatYShifts}}relax}
immediatewrite@mainaux{xdefstringLstMatXShifts{{LstMatXShifts}}relax}
makeatother

newcommandtotalnodes{5} % Define the total of subjects that need arrows-1

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
typeout{X:mylst}
foreach Y/myalong in mylst {
ifxmyalongY
%typeout{X:Y,empty}
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
else
%typeout{X:Yspace andspace myalong}
draw[-latex,mycolor,very thick] (X-Title.east)
[along node/.list/.expanded=myalong]
to[manoooh curve] (Y-Title.west);
fi
}
}
end{tikzpicture}
end{Form}

vfill

end{document}


enter image description here



The relevant information is all in



defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}


which contains after the backslash a list of nodes along which the path should run. The list can consist 0, 1 or 0 elements, where in the case of 0 elements the path won't run along any node.






share|improve this answer


























  • @manooooh I edited my answer (but it is strange that you got the error).

    – marmot
    1 hour ago











  • @manooooh No, the error says that you do not have the style along node, but it is defined in the answer, and was defined in the previous version, too.

    – marmot
    1 hour ago











  • Thanks! It looks fantastic. How can we take a single element from the list of arrows to change its path (I mean three of the yellow and one of the lightblue arrows, which overlap with the pics), but preserving the color? I will wait a second proposal of yours.

    – manooooh
    55 mins ago













  • WOW, you are awesome!! I do not understand "The list can consist of 1 or 0 elements", could you talk about that a little more specific, please? I can see that we have "{2,10/5,13/5,14/5}", where after the backslash we have 1 node (the 5), and in "{36/{12,21,29}}" we have {12,21,29}, which is also one element, right?

    – manooooh
    26 mins ago













  • For example, if we consider what's after the backslash in "{10,13,14,25/13}" we can say: 10 has no elements after the backslash, the same for 13, but 25 has one element after the backslash, right?

    – manooooh
    24 mins ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480836%2fdesign-an-algorithm-capable-of-predicting-collisions-to-choose-alternative-path%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Here is a first proposal. You only need to say



draw[-latex,blue,very thick] (4-Title.east) 
[along node/.list={12,21,29}]
to[manoooh curve] (36-Title.west);


to get



enter image description here



As you can see, the path runs north of the forms 12, 21, 29.



And as for your loop: you could specify the nodes along which the path should run in lists.



documentclass{article}
usepackage[margin=0in,footskip=0in,paperwidth=60cm,paperheight=29cm]{geometry}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{hyperref}

usepackage{tikz}
usetikzlibrary{positioning,fit,calc}
pgfdeclarelayer{behind}
pgfdeclarelayer{background}
pgfdeclarelayer{foreground}
pgfsetlayers{behind,background,main,foreground}
tikzset{
text field/.style={text height=1.5ex,align=center,rounded corners},
nonfillable title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
fillable title field/.style={text height=3.14ex,text depth=0em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
pics/fillable subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/fillable elective subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[fillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {hspace*{-0.34em}TextField[align=1,name=#1-electivesubject,width=4.5cm,charsize=8pt,height=.5cm,bordercolor={1 1 1}]{}};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable elective subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
manoooh/.style={column sep=-1.75cm,row sep=5mm},
manooohE/.style={column sep=-2.25cm,row sep=5mm,anchor=south},
electives/.style={column sep=-7.25cm,row sep=5mm},
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style={to path={let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget)}},
manoooh curve/.default=0.3,
along node/.style={insert path={
to[out=0,in=180]
([yshift=5pt]#1-Title.north west) -- ([yshift=5pt]#1-Title.north east)}}
} % From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3{%
@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
makeatother

begin{document}
thispagestyle{empty} % To suppress page number
noindent
begin{tikzpicture}
fill[white,fill=orange] (0,0) rectangle (paperwidth,-2cm) node[midway,align=center,font=Huge] {bfseries Some text here\LARGE More text here};
end{tikzpicture}

ifdefinedmymatbottom
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi

%typeout{height:myheight}
%typeout{xshifts(in):LstMatXShifts}

vfill
centering
begin{Form}
begin{tikzpicture}
% step 1: add the matrices, name them mat0, mat1 etc.
begin{scope}[local bounding box=matrices]
matrix[manoooh] (mat0) at ({LstMatXShifts[0]},{LstMatYShifts[0]}) {
pic[local bounding box=A] (0) {nonfillable subject={Subject A}}; \
pic (1) {nonfillable subject={Subject B}}; \
};
matrix[manoooh] (mat1) at ({LstMatXShifts[1]},{LstMatYShifts[1]}) {

pic (2) {nonfillable subject={Subject C}}; \
pic (3) {nonfillable subject={Subject D}}; \
pic (4) {nonfillable subject={Subject E}}; \
pic (5) {nonfillable subject={Subject F}}; \
pic (6) {nonfillable subject={Subject G}}; \
pic (7) {nonfillable subject={Subject H}}; \
pic (8) {nonfillable subject={Subject I}}; \
pic[draw=red] (9) {nonfillable subject={Subject J}}; \
};
matrix[manoooh] (mat2) at ({LstMatXShifts[2]},{LstMatYShifts[2]}) {
pic[draw=red] (10) {nonfillable subject={Subject K}}; \
pic (11) {nonfillable subject={Subject L}}; \
pic (12) {nonfillable subject={Subject A}}; \
pic (13) {nonfillable subject={Subject N}}; \
pic (14) {nonfillable subject={Subject O}}; \
pic (15) {nonfillable subject={Subject P}}; \
pic (16) {nonfillable subject={Subject Q}}; \
pic (17) {nonfillable subject={Subject R}}; \
};
matrix[manoooh] (mat3) at ({LstMatXShifts[3]},{LstMatYShifts[3]}) {
pic[draw=red] (18) {nonfillable subject={Subject S}}; \
pic (19) {nonfillable subject={Subject T}}; \
pic (20) {nonfillable subject={Subject U}}; \
pic (21) {nonfillable subject={Subject V}}; \
pic (22) {nonfillable subject={Subject W}}; \
pic (23) {nonfillable subject={Subject X}}; \
pic (24) {nonfillable subject={Subject Y}}; \
pic (25) {nonfillable subject={Subject Z}}; \
};
matrix[manooohE] (matE3) at ({LstMatXShifts[3]},mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; & &
pic (L3E2) {nonfillable elective subject={Subject}}; \
& pic (L3E3) {nonfillable elective subject={Subject}}; & \
};
matrix[manoooh] (mat4) at ({LstMatXShifts[4]},{LstMatYShifts[4]}) {
& pic[draw=red] (26) {nonfillable subject={Subject AA}}; & \
pic (27) {nonfillable subject={Subject AB}}; & & pic (28) {nonfillable subject={Subject AC}}; \
& pic (29) {nonfillable subject={Subject AD}}; & \
& pic (30) {nonfillable subject={Subject AE}}; & \
& pic (31) {nonfillable subject={Subject AF}}; & \
& pic (32) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at ({LstMatXShifts[4]},mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at ({LstMatXShifts[5]},{LstMatYShifts[5]}) {
pic (33) {nonfillable subject={Subject AH}}; \
pic (34) {nonfillable subject={Subject AI}}; \
pic[draw=red] (35) {nonfillable subject={Subject AJ}}; \
pic (36) {nonfillable subject={Subject AK}}; \
};
matrix[manooohE] (matE5) at ({LstMatXShifts[5]},mymatbottom) {
pic (L5E1) {nonfillable elective subject={Subject}}; \
pic (L5E2) {nonfillable elective subject={Subject}}; \
pic (L5E3) {nonfillable elective subject={Subject}}; \
pic (L5E4) {nonfillable elective subject={Subject}}; \
pic (L5E5) {nonfillable elective subject={Subject}}; \
};
end{scope}
pgfmathsetmacro{groupwidth}{0}
pgfmathsetmacro{lastwidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
ifnodedefined{matEX}{% has inlay
node[xshift=1em,anchor=south west,font=LARGEbfseries,opacity=0] (matElX) at (matEX.north west) {Electives};
begin{pgfonlayer}{background}
path let p1=($(matX.north east)-(matX.south west)$) in
node[fit=(matEX) (matElX),inner ysep=5mm,fill=blue!30,rounded
corners=40pt,minimum width=x1-2*pgfkeysvalueof{/tikz/fit sep},
inner xsep=pgfkeysvalueof{/tikz/fit sep}](FX){};
node[xshift=1em,anchor=south west,font=LARGEbfseries]
(matElX) at ([xshift=1.3em]FX.west|-matElX.center) {Electives};
end{pgfonlayer}
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(FX.north east)-(FX.south west)$),
n1={max(abs(y1)/2+abs(y2)/2+0*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+max(x1,x2)/2+lastwidth/2+2*pgfkeysvalueof{/tikz/fit sep}+pgfkeysvalueof{/tikz/fit dist}}
fi
pgfmathsetmacro{lastwidth}{max(x1,x2)+8*pgfkeysvalueof{/tikz/fit sep}}
xdeflastwidth{lastwidth}
xdefgroupwidth{groupwidth}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatYShifts{myshift pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,myshift pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south)
(matEX) (matElX),inner ysep=8mm,inner xsep=4*pgfkeysvalueof{/tikz/fit sep},
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1={max(abs(y1)/2,mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+x1/2+lastwidth/2+pgfkeysvalueof{/tikz/fit dist}}
fi
xdefgroupwidth{groupwidth}
xdeflastwidth{x1}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmyheight{myheight}
ifnumX=0
xdefLstMatYShifts{0pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,0pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=8mm,
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}
}
}
makeatletter
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatYShifts{{LstMatYShifts}}relax}
immediatewrite@mainaux{xdefstringLstMatXShifts{{LstMatXShifts}}relax}
makeatother

newcommandtotalnodes{5} % Define the total of subjects that need arrows-1

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
typeout{X:mylst}
foreach Y/myalong in mylst {
ifxmyalongY
%typeout{X:Y,empty}
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
else
%typeout{X:Yspace andspace myalong}
draw[-latex,mycolor,very thick] (X-Title.east)
[along node/.list/.expanded=myalong]
to[manoooh curve] (Y-Title.west);
fi
}
}
end{tikzpicture}
end{Form}

vfill

end{document}


enter image description here



The relevant information is all in



defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}


which contains after the backslash a list of nodes along which the path should run. The list can consist 0, 1 or 0 elements, where in the case of 0 elements the path won't run along any node.






share|improve this answer


























  • @manooooh I edited my answer (but it is strange that you got the error).

    – marmot
    1 hour ago











  • @manooooh No, the error says that you do not have the style along node, but it is defined in the answer, and was defined in the previous version, too.

    – marmot
    1 hour ago











  • Thanks! It looks fantastic. How can we take a single element from the list of arrows to change its path (I mean three of the yellow and one of the lightblue arrows, which overlap with the pics), but preserving the color? I will wait a second proposal of yours.

    – manooooh
    55 mins ago













  • WOW, you are awesome!! I do not understand "The list can consist of 1 or 0 elements", could you talk about that a little more specific, please? I can see that we have "{2,10/5,13/5,14/5}", where after the backslash we have 1 node (the 5), and in "{36/{12,21,29}}" we have {12,21,29}, which is also one element, right?

    – manooooh
    26 mins ago













  • For example, if we consider what's after the backslash in "{10,13,14,25/13}" we can say: 10 has no elements after the backslash, the same for 13, but 25 has one element after the backslash, right?

    – manooooh
    24 mins ago
















3














Here is a first proposal. You only need to say



draw[-latex,blue,very thick] (4-Title.east) 
[along node/.list={12,21,29}]
to[manoooh curve] (36-Title.west);


to get



enter image description here



As you can see, the path runs north of the forms 12, 21, 29.



And as for your loop: you could specify the nodes along which the path should run in lists.



documentclass{article}
usepackage[margin=0in,footskip=0in,paperwidth=60cm,paperheight=29cm]{geometry}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{hyperref}

usepackage{tikz}
usetikzlibrary{positioning,fit,calc}
pgfdeclarelayer{behind}
pgfdeclarelayer{background}
pgfdeclarelayer{foreground}
pgfsetlayers{behind,background,main,foreground}
tikzset{
text field/.style={text height=1.5ex,align=center,rounded corners},
nonfillable title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
fillable title field/.style={text height=3.14ex,text depth=0em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
pics/fillable subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/fillable elective subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[fillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {hspace*{-0.34em}TextField[align=1,name=#1-electivesubject,width=4.5cm,charsize=8pt,height=.5cm,bordercolor={1 1 1}]{}};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable elective subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
manoooh/.style={column sep=-1.75cm,row sep=5mm},
manooohE/.style={column sep=-2.25cm,row sep=5mm,anchor=south},
electives/.style={column sep=-7.25cm,row sep=5mm},
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style={to path={let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget)}},
manoooh curve/.default=0.3,
along node/.style={insert path={
to[out=0,in=180]
([yshift=5pt]#1-Title.north west) -- ([yshift=5pt]#1-Title.north east)}}
} % From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3{%
@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
makeatother

begin{document}
thispagestyle{empty} % To suppress page number
noindent
begin{tikzpicture}
fill[white,fill=orange] (0,0) rectangle (paperwidth,-2cm) node[midway,align=center,font=Huge] {bfseries Some text here\LARGE More text here};
end{tikzpicture}

ifdefinedmymatbottom
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi

%typeout{height:myheight}
%typeout{xshifts(in):LstMatXShifts}

vfill
centering
begin{Form}
begin{tikzpicture}
% step 1: add the matrices, name them mat0, mat1 etc.
begin{scope}[local bounding box=matrices]
matrix[manoooh] (mat0) at ({LstMatXShifts[0]},{LstMatYShifts[0]}) {
pic[local bounding box=A] (0) {nonfillable subject={Subject A}}; \
pic (1) {nonfillable subject={Subject B}}; \
};
matrix[manoooh] (mat1) at ({LstMatXShifts[1]},{LstMatYShifts[1]}) {

pic (2) {nonfillable subject={Subject C}}; \
pic (3) {nonfillable subject={Subject D}}; \
pic (4) {nonfillable subject={Subject E}}; \
pic (5) {nonfillable subject={Subject F}}; \
pic (6) {nonfillable subject={Subject G}}; \
pic (7) {nonfillable subject={Subject H}}; \
pic (8) {nonfillable subject={Subject I}}; \
pic[draw=red] (9) {nonfillable subject={Subject J}}; \
};
matrix[manoooh] (mat2) at ({LstMatXShifts[2]},{LstMatYShifts[2]}) {
pic[draw=red] (10) {nonfillable subject={Subject K}}; \
pic (11) {nonfillable subject={Subject L}}; \
pic (12) {nonfillable subject={Subject A}}; \
pic (13) {nonfillable subject={Subject N}}; \
pic (14) {nonfillable subject={Subject O}}; \
pic (15) {nonfillable subject={Subject P}}; \
pic (16) {nonfillable subject={Subject Q}}; \
pic (17) {nonfillable subject={Subject R}}; \
};
matrix[manoooh] (mat3) at ({LstMatXShifts[3]},{LstMatYShifts[3]}) {
pic[draw=red] (18) {nonfillable subject={Subject S}}; \
pic (19) {nonfillable subject={Subject T}}; \
pic (20) {nonfillable subject={Subject U}}; \
pic (21) {nonfillable subject={Subject V}}; \
pic (22) {nonfillable subject={Subject W}}; \
pic (23) {nonfillable subject={Subject X}}; \
pic (24) {nonfillable subject={Subject Y}}; \
pic (25) {nonfillable subject={Subject Z}}; \
};
matrix[manooohE] (matE3) at ({LstMatXShifts[3]},mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; & &
pic (L3E2) {nonfillable elective subject={Subject}}; \
& pic (L3E3) {nonfillable elective subject={Subject}}; & \
};
matrix[manoooh] (mat4) at ({LstMatXShifts[4]},{LstMatYShifts[4]}) {
& pic[draw=red] (26) {nonfillable subject={Subject AA}}; & \
pic (27) {nonfillable subject={Subject AB}}; & & pic (28) {nonfillable subject={Subject AC}}; \
& pic (29) {nonfillable subject={Subject AD}}; & \
& pic (30) {nonfillable subject={Subject AE}}; & \
& pic (31) {nonfillable subject={Subject AF}}; & \
& pic (32) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at ({LstMatXShifts[4]},mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at ({LstMatXShifts[5]},{LstMatYShifts[5]}) {
pic (33) {nonfillable subject={Subject AH}}; \
pic (34) {nonfillable subject={Subject AI}}; \
pic[draw=red] (35) {nonfillable subject={Subject AJ}}; \
pic (36) {nonfillable subject={Subject AK}}; \
};
matrix[manooohE] (matE5) at ({LstMatXShifts[5]},mymatbottom) {
pic (L5E1) {nonfillable elective subject={Subject}}; \
pic (L5E2) {nonfillable elective subject={Subject}}; \
pic (L5E3) {nonfillable elective subject={Subject}}; \
pic (L5E4) {nonfillable elective subject={Subject}}; \
pic (L5E5) {nonfillable elective subject={Subject}}; \
};
end{scope}
pgfmathsetmacro{groupwidth}{0}
pgfmathsetmacro{lastwidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
ifnodedefined{matEX}{% has inlay
node[xshift=1em,anchor=south west,font=LARGEbfseries,opacity=0] (matElX) at (matEX.north west) {Electives};
begin{pgfonlayer}{background}
path let p1=($(matX.north east)-(matX.south west)$) in
node[fit=(matEX) (matElX),inner ysep=5mm,fill=blue!30,rounded
corners=40pt,minimum width=x1-2*pgfkeysvalueof{/tikz/fit sep},
inner xsep=pgfkeysvalueof{/tikz/fit sep}](FX){};
node[xshift=1em,anchor=south west,font=LARGEbfseries]
(matElX) at ([xshift=1.3em]FX.west|-matElX.center) {Electives};
end{pgfonlayer}
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(FX.north east)-(FX.south west)$),
n1={max(abs(y1)/2+abs(y2)/2+0*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+max(x1,x2)/2+lastwidth/2+2*pgfkeysvalueof{/tikz/fit sep}+pgfkeysvalueof{/tikz/fit dist}}
fi
pgfmathsetmacro{lastwidth}{max(x1,x2)+8*pgfkeysvalueof{/tikz/fit sep}}
xdeflastwidth{lastwidth}
xdefgroupwidth{groupwidth}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatYShifts{myshift pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,myshift pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south)
(matEX) (matElX),inner ysep=8mm,inner xsep=4*pgfkeysvalueof{/tikz/fit sep},
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1={max(abs(y1)/2,mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+x1/2+lastwidth/2+pgfkeysvalueof{/tikz/fit dist}}
fi
xdefgroupwidth{groupwidth}
xdeflastwidth{x1}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmyheight{myheight}
ifnumX=0
xdefLstMatYShifts{0pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,0pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=8mm,
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}
}
}
makeatletter
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatYShifts{{LstMatYShifts}}relax}
immediatewrite@mainaux{xdefstringLstMatXShifts{{LstMatXShifts}}relax}
makeatother

newcommandtotalnodes{5} % Define the total of subjects that need arrows-1

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
typeout{X:mylst}
foreach Y/myalong in mylst {
ifxmyalongY
%typeout{X:Y,empty}
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
else
%typeout{X:Yspace andspace myalong}
draw[-latex,mycolor,very thick] (X-Title.east)
[along node/.list/.expanded=myalong]
to[manoooh curve] (Y-Title.west);
fi
}
}
end{tikzpicture}
end{Form}

vfill

end{document}


enter image description here



The relevant information is all in



defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}


which contains after the backslash a list of nodes along which the path should run. The list can consist 0, 1 or 0 elements, where in the case of 0 elements the path won't run along any node.






share|improve this answer


























  • @manooooh I edited my answer (but it is strange that you got the error).

    – marmot
    1 hour ago











  • @manooooh No, the error says that you do not have the style along node, but it is defined in the answer, and was defined in the previous version, too.

    – marmot
    1 hour ago











  • Thanks! It looks fantastic. How can we take a single element from the list of arrows to change its path (I mean three of the yellow and one of the lightblue arrows, which overlap with the pics), but preserving the color? I will wait a second proposal of yours.

    – manooooh
    55 mins ago













  • WOW, you are awesome!! I do not understand "The list can consist of 1 or 0 elements", could you talk about that a little more specific, please? I can see that we have "{2,10/5,13/5,14/5}", where after the backslash we have 1 node (the 5), and in "{36/{12,21,29}}" we have {12,21,29}, which is also one element, right?

    – manooooh
    26 mins ago













  • For example, if we consider what's after the backslash in "{10,13,14,25/13}" we can say: 10 has no elements after the backslash, the same for 13, but 25 has one element after the backslash, right?

    – manooooh
    24 mins ago














3












3








3







Here is a first proposal. You only need to say



draw[-latex,blue,very thick] (4-Title.east) 
[along node/.list={12,21,29}]
to[manoooh curve] (36-Title.west);


to get



enter image description here



As you can see, the path runs north of the forms 12, 21, 29.



And as for your loop: you could specify the nodes along which the path should run in lists.



documentclass{article}
usepackage[margin=0in,footskip=0in,paperwidth=60cm,paperheight=29cm]{geometry}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{hyperref}

usepackage{tikz}
usetikzlibrary{positioning,fit,calc}
pgfdeclarelayer{behind}
pgfdeclarelayer{background}
pgfdeclarelayer{foreground}
pgfsetlayers{behind,background,main,foreground}
tikzset{
text field/.style={text height=1.5ex,align=center,rounded corners},
nonfillable title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
fillable title field/.style={text height=3.14ex,text depth=0em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
pics/fillable subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/fillable elective subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[fillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {hspace*{-0.34em}TextField[align=1,name=#1-electivesubject,width=4.5cm,charsize=8pt,height=.5cm,bordercolor={1 1 1}]{}};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable elective subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
manoooh/.style={column sep=-1.75cm,row sep=5mm},
manooohE/.style={column sep=-2.25cm,row sep=5mm,anchor=south},
electives/.style={column sep=-7.25cm,row sep=5mm},
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style={to path={let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget)}},
manoooh curve/.default=0.3,
along node/.style={insert path={
to[out=0,in=180]
([yshift=5pt]#1-Title.north west) -- ([yshift=5pt]#1-Title.north east)}}
} % From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3{%
@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
makeatother

begin{document}
thispagestyle{empty} % To suppress page number
noindent
begin{tikzpicture}
fill[white,fill=orange] (0,0) rectangle (paperwidth,-2cm) node[midway,align=center,font=Huge] {bfseries Some text here\LARGE More text here};
end{tikzpicture}

ifdefinedmymatbottom
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi

%typeout{height:myheight}
%typeout{xshifts(in):LstMatXShifts}

vfill
centering
begin{Form}
begin{tikzpicture}
% step 1: add the matrices, name them mat0, mat1 etc.
begin{scope}[local bounding box=matrices]
matrix[manoooh] (mat0) at ({LstMatXShifts[0]},{LstMatYShifts[0]}) {
pic[local bounding box=A] (0) {nonfillable subject={Subject A}}; \
pic (1) {nonfillable subject={Subject B}}; \
};
matrix[manoooh] (mat1) at ({LstMatXShifts[1]},{LstMatYShifts[1]}) {

pic (2) {nonfillable subject={Subject C}}; \
pic (3) {nonfillable subject={Subject D}}; \
pic (4) {nonfillable subject={Subject E}}; \
pic (5) {nonfillable subject={Subject F}}; \
pic (6) {nonfillable subject={Subject G}}; \
pic (7) {nonfillable subject={Subject H}}; \
pic (8) {nonfillable subject={Subject I}}; \
pic[draw=red] (9) {nonfillable subject={Subject J}}; \
};
matrix[manoooh] (mat2) at ({LstMatXShifts[2]},{LstMatYShifts[2]}) {
pic[draw=red] (10) {nonfillable subject={Subject K}}; \
pic (11) {nonfillable subject={Subject L}}; \
pic (12) {nonfillable subject={Subject A}}; \
pic (13) {nonfillable subject={Subject N}}; \
pic (14) {nonfillable subject={Subject O}}; \
pic (15) {nonfillable subject={Subject P}}; \
pic (16) {nonfillable subject={Subject Q}}; \
pic (17) {nonfillable subject={Subject R}}; \
};
matrix[manoooh] (mat3) at ({LstMatXShifts[3]},{LstMatYShifts[3]}) {
pic[draw=red] (18) {nonfillable subject={Subject S}}; \
pic (19) {nonfillable subject={Subject T}}; \
pic (20) {nonfillable subject={Subject U}}; \
pic (21) {nonfillable subject={Subject V}}; \
pic (22) {nonfillable subject={Subject W}}; \
pic (23) {nonfillable subject={Subject X}}; \
pic (24) {nonfillable subject={Subject Y}}; \
pic (25) {nonfillable subject={Subject Z}}; \
};
matrix[manooohE] (matE3) at ({LstMatXShifts[3]},mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; & &
pic (L3E2) {nonfillable elective subject={Subject}}; \
& pic (L3E3) {nonfillable elective subject={Subject}}; & \
};
matrix[manoooh] (mat4) at ({LstMatXShifts[4]},{LstMatYShifts[4]}) {
& pic[draw=red] (26) {nonfillable subject={Subject AA}}; & \
pic (27) {nonfillable subject={Subject AB}}; & & pic (28) {nonfillable subject={Subject AC}}; \
& pic (29) {nonfillable subject={Subject AD}}; & \
& pic (30) {nonfillable subject={Subject AE}}; & \
& pic (31) {nonfillable subject={Subject AF}}; & \
& pic (32) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at ({LstMatXShifts[4]},mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at ({LstMatXShifts[5]},{LstMatYShifts[5]}) {
pic (33) {nonfillable subject={Subject AH}}; \
pic (34) {nonfillable subject={Subject AI}}; \
pic[draw=red] (35) {nonfillable subject={Subject AJ}}; \
pic (36) {nonfillable subject={Subject AK}}; \
};
matrix[manooohE] (matE5) at ({LstMatXShifts[5]},mymatbottom) {
pic (L5E1) {nonfillable elective subject={Subject}}; \
pic (L5E2) {nonfillable elective subject={Subject}}; \
pic (L5E3) {nonfillable elective subject={Subject}}; \
pic (L5E4) {nonfillable elective subject={Subject}}; \
pic (L5E5) {nonfillable elective subject={Subject}}; \
};
end{scope}
pgfmathsetmacro{groupwidth}{0}
pgfmathsetmacro{lastwidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
ifnodedefined{matEX}{% has inlay
node[xshift=1em,anchor=south west,font=LARGEbfseries,opacity=0] (matElX) at (matEX.north west) {Electives};
begin{pgfonlayer}{background}
path let p1=($(matX.north east)-(matX.south west)$) in
node[fit=(matEX) (matElX),inner ysep=5mm,fill=blue!30,rounded
corners=40pt,minimum width=x1-2*pgfkeysvalueof{/tikz/fit sep},
inner xsep=pgfkeysvalueof{/tikz/fit sep}](FX){};
node[xshift=1em,anchor=south west,font=LARGEbfseries]
(matElX) at ([xshift=1.3em]FX.west|-matElX.center) {Electives};
end{pgfonlayer}
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(FX.north east)-(FX.south west)$),
n1={max(abs(y1)/2+abs(y2)/2+0*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+max(x1,x2)/2+lastwidth/2+2*pgfkeysvalueof{/tikz/fit sep}+pgfkeysvalueof{/tikz/fit dist}}
fi
pgfmathsetmacro{lastwidth}{max(x1,x2)+8*pgfkeysvalueof{/tikz/fit sep}}
xdeflastwidth{lastwidth}
xdefgroupwidth{groupwidth}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatYShifts{myshift pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,myshift pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south)
(matEX) (matElX),inner ysep=8mm,inner xsep=4*pgfkeysvalueof{/tikz/fit sep},
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1={max(abs(y1)/2,mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+x1/2+lastwidth/2+pgfkeysvalueof{/tikz/fit dist}}
fi
xdefgroupwidth{groupwidth}
xdeflastwidth{x1}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmyheight{myheight}
ifnumX=0
xdefLstMatYShifts{0pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,0pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=8mm,
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}
}
}
makeatletter
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatYShifts{{LstMatYShifts}}relax}
immediatewrite@mainaux{xdefstringLstMatXShifts{{LstMatXShifts}}relax}
makeatother

newcommandtotalnodes{5} % Define the total of subjects that need arrows-1

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
typeout{X:mylst}
foreach Y/myalong in mylst {
ifxmyalongY
%typeout{X:Y,empty}
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
else
%typeout{X:Yspace andspace myalong}
draw[-latex,mycolor,very thick] (X-Title.east)
[along node/.list/.expanded=myalong]
to[manoooh curve] (Y-Title.west);
fi
}
}
end{tikzpicture}
end{Form}

vfill

end{document}


enter image description here



The relevant information is all in



defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}


which contains after the backslash a list of nodes along which the path should run. The list can consist 0, 1 or 0 elements, where in the case of 0 elements the path won't run along any node.






share|improve this answer















Here is a first proposal. You only need to say



draw[-latex,blue,very thick] (4-Title.east) 
[along node/.list={12,21,29}]
to[manoooh curve] (36-Title.west);


to get



enter image description here



As you can see, the path runs north of the forms 12, 21, 29.



And as for your loop: you could specify the nodes along which the path should run in lists.



documentclass{article}
usepackage[margin=0in,footskip=0in,paperwidth=60cm,paperheight=29cm]{geometry}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{hyperref}

usepackage{tikz}
usetikzlibrary{positioning,fit,calc}
pgfdeclarelayer{behind}
pgfdeclarelayer{background}
pgfdeclarelayer{foreground}
pgfsetlayers{behind,background,main,foreground}
tikzset{
text field/.style={text height=1.5ex,align=center,rounded corners},
nonfillable title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
fillable title field/.style={text height=3.14ex,text depth=0em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily},
pics/fillable subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {#1};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/fillable elective subject/.style={code={%
node[text field] (-TF)
{hspace*{-0.5em}TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0.15em}TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/hspace*{-0em}TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
node[fillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {hspace*{-0.34em}TextField[align=1,name=#1-electivesubject,width=4.5cm,charsize=8pt,height=.5cm,bordercolor={1 1 1}]{}};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
pics/nonfillable elective subject/.style={code={%
node[text field] (-TF)
{hspace{1.2em}~/~hspace{1.15em}~/~hspace{2.35em}{}};
node[nonfillable title field] (-Title)
at ([yshift=0.4em]-TF.north) {};
draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
}},
manoooh/.style={column sep=-1.75cm,row sep=5mm},
manooohE/.style={column sep=-2.25cm,row sep=5mm,anchor=south},
electives/.style={column sep=-7.25cm,row sep=5mm},
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style={to path={let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget)}},
manoooh curve/.default=0.3,
along node/.style={insert path={
to[out=0,in=180]
([yshift=5pt]#1-Title.north west) -- ([yshift=5pt]#1-Title.north east)}}
} % From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3{%
@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
makeatother

begin{document}
thispagestyle{empty} % To suppress page number
noindent
begin{tikzpicture}
fill[white,fill=orange] (0,0) rectangle (paperwidth,-2cm) node[midway,align=center,font=Huge] {bfseries Some text here\LARGE More text here};
end{tikzpicture}

ifdefinedmymatbottom
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts{{0pt,0pt,0pt,0pt,0pt,0pt,0pt}}
fi

%typeout{height:myheight}
%typeout{xshifts(in):LstMatXShifts}

vfill
centering
begin{Form}
begin{tikzpicture}
% step 1: add the matrices, name them mat0, mat1 etc.
begin{scope}[local bounding box=matrices]
matrix[manoooh] (mat0) at ({LstMatXShifts[0]},{LstMatYShifts[0]}) {
pic[local bounding box=A] (0) {nonfillable subject={Subject A}}; \
pic (1) {nonfillable subject={Subject B}}; \
};
matrix[manoooh] (mat1) at ({LstMatXShifts[1]},{LstMatYShifts[1]}) {

pic (2) {nonfillable subject={Subject C}}; \
pic (3) {nonfillable subject={Subject D}}; \
pic (4) {nonfillable subject={Subject E}}; \
pic (5) {nonfillable subject={Subject F}}; \
pic (6) {nonfillable subject={Subject G}}; \
pic (7) {nonfillable subject={Subject H}}; \
pic (8) {nonfillable subject={Subject I}}; \
pic[draw=red] (9) {nonfillable subject={Subject J}}; \
};
matrix[manoooh] (mat2) at ({LstMatXShifts[2]},{LstMatYShifts[2]}) {
pic[draw=red] (10) {nonfillable subject={Subject K}}; \
pic (11) {nonfillable subject={Subject L}}; \
pic (12) {nonfillable subject={Subject A}}; \
pic (13) {nonfillable subject={Subject N}}; \
pic (14) {nonfillable subject={Subject O}}; \
pic (15) {nonfillable subject={Subject P}}; \
pic (16) {nonfillable subject={Subject Q}}; \
pic (17) {nonfillable subject={Subject R}}; \
};
matrix[manoooh] (mat3) at ({LstMatXShifts[3]},{LstMatYShifts[3]}) {
pic[draw=red] (18) {nonfillable subject={Subject S}}; \
pic (19) {nonfillable subject={Subject T}}; \
pic (20) {nonfillable subject={Subject U}}; \
pic (21) {nonfillable subject={Subject V}}; \
pic (22) {nonfillable subject={Subject W}}; \
pic (23) {nonfillable subject={Subject X}}; \
pic (24) {nonfillable subject={Subject Y}}; \
pic (25) {nonfillable subject={Subject Z}}; \
};
matrix[manooohE] (matE3) at ({LstMatXShifts[3]},mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; & &
pic (L3E2) {nonfillable elective subject={Subject}}; \
& pic (L3E3) {nonfillable elective subject={Subject}}; & \
};
matrix[manoooh] (mat4) at ({LstMatXShifts[4]},{LstMatYShifts[4]}) {
& pic[draw=red] (26) {nonfillable subject={Subject AA}}; & \
pic (27) {nonfillable subject={Subject AB}}; & & pic (28) {nonfillable subject={Subject AC}}; \
& pic (29) {nonfillable subject={Subject AD}}; & \
& pic (30) {nonfillable subject={Subject AE}}; & \
& pic (31) {nonfillable subject={Subject AF}}; & \
& pic (32) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at ({LstMatXShifts[4]},mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at ({LstMatXShifts[5]},{LstMatYShifts[5]}) {
pic (33) {nonfillable subject={Subject AH}}; \
pic (34) {nonfillable subject={Subject AI}}; \
pic[draw=red] (35) {nonfillable subject={Subject AJ}}; \
pic (36) {nonfillable subject={Subject AK}}; \
};
matrix[manooohE] (matE5) at ({LstMatXShifts[5]},mymatbottom) {
pic (L5E1) {nonfillable elective subject={Subject}}; \
pic (L5E2) {nonfillable elective subject={Subject}}; \
pic (L5E3) {nonfillable elective subject={Subject}}; \
pic (L5E4) {nonfillable elective subject={Subject}}; \
pic (L5E5) {nonfillable elective subject={Subject}}; \
};
end{scope}
pgfmathsetmacro{groupwidth}{0}
pgfmathsetmacro{lastwidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
ifnodedefined{matEX}{% has inlay
node[xshift=1em,anchor=south west,font=LARGEbfseries,opacity=0] (matElX) at (matEX.north west) {Electives};
begin{pgfonlayer}{background}
path let p1=($(matX.north east)-(matX.south west)$) in
node[fit=(matEX) (matElX),inner ysep=5mm,fill=blue!30,rounded
corners=40pt,minimum width=x1-2*pgfkeysvalueof{/tikz/fit sep},
inner xsep=pgfkeysvalueof{/tikz/fit sep}](FX){};
node[xshift=1em,anchor=south west,font=LARGEbfseries]
(matElX) at ([xshift=1.3em]FX.west|-matElX.center) {Electives};
end{pgfonlayer}
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(FX.north east)-(FX.south west)$),
n1={max(abs(y1)/2+abs(y2)/2+0*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+max(x1,x2)/2+lastwidth/2+2*pgfkeysvalueof{/tikz/fit sep}+pgfkeysvalueof{/tikz/fit dist}}
fi
pgfmathsetmacro{lastwidth}{max(x1,x2)+8*pgfkeysvalueof{/tikz/fit sep}}
xdeflastwidth{lastwidth}
xdefgroupwidth{groupwidth}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatYShifts{myshift pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,myshift pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south)
(matEX) (matElX),inner ysep=8mm,inner xsep=4*pgfkeysvalueof{/tikz/fit sep},
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1={max(abs(y1)/2,mymatbottom)}
in
pgfextra{xdefmymatbottom{n1}
ifnumX=0
pgfmathsetmacro{groupwidth}{0}
else
pgfmathsetmacro{groupwidth}{groupwidth+x1/2+lastwidth/2+pgfkeysvalueof{/tikz/fit dist}}
fi
xdefgroupwidth{groupwidth}
xdeflastwidth{x1}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmyheight{myheight}
ifnumX=0
xdefLstMatYShifts{0pt}
xdefLstMatXShifts{0pt}
else
xdefLstMatYShifts{LstMatYShifts,0pt}
xdefLstMatXShifts{LstMatXShifts,groupwidth pt}
fi};
% the fit parameters determine the shape of the background rectangles
begin{pgfonlayer}{behind}
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=8mm,
fill=orange!30,rounded corners=50pt](FX){};
end{pgfonlayer}
}
}
makeatletter
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatYShifts{{LstMatYShifts}}relax}
immediatewrite@mainaux{xdefstringLstMatXShifts{{LstMatXShifts}}relax}
makeatother

newcommandtotalnodes{5} % Define the total of subjects that need arrows-1

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
typeout{X:mylst}
foreach Y/myalong in mylst {
ifxmyalongY
%typeout{X:Y,empty}
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
else
%typeout{X:Yspace andspace myalong}
draw[-latex,mycolor,very thick] (X-Title.east)
[along node/.list/.expanded=myalong]
to[manoooh curve] (Y-Title.west);
fi
}
}
end{tikzpicture}
end{Form}

vfill

end{document}


enter image description here



The relevant information is all in



defLstCon{%
{
"{2,...,9}",%subjects that 0 links
"{2,10/5,13/5,14/5}",%subjects that 1 links
"{11,14}",%subjects that 2 links
"{10,13,14,25/13}",%subjects that 3 links
"{36/{12,21,29}}",%subjects that 8 links
}
}


which contains after the backslash a list of nodes along which the path should run. The list can consist 0, 1 or 0 elements, where in the case of 0 elements the path won't run along any node.







share|improve this answer














share|improve this answer



share|improve this answer








edited 25 mins ago

























answered 1 hour ago









marmotmarmot

110k5137256




110k5137256













  • @manooooh I edited my answer (but it is strange that you got the error).

    – marmot
    1 hour ago











  • @manooooh No, the error says that you do not have the style along node, but it is defined in the answer, and was defined in the previous version, too.

    – marmot
    1 hour ago











  • Thanks! It looks fantastic. How can we take a single element from the list of arrows to change its path (I mean three of the yellow and one of the lightblue arrows, which overlap with the pics), but preserving the color? I will wait a second proposal of yours.

    – manooooh
    55 mins ago













  • WOW, you are awesome!! I do not understand "The list can consist of 1 or 0 elements", could you talk about that a little more specific, please? I can see that we have "{2,10/5,13/5,14/5}", where after the backslash we have 1 node (the 5), and in "{36/{12,21,29}}" we have {12,21,29}, which is also one element, right?

    – manooooh
    26 mins ago













  • For example, if we consider what's after the backslash in "{10,13,14,25/13}" we can say: 10 has no elements after the backslash, the same for 13, but 25 has one element after the backslash, right?

    – manooooh
    24 mins ago



















  • @manooooh I edited my answer (but it is strange that you got the error).

    – marmot
    1 hour ago











  • @manooooh No, the error says that you do not have the style along node, but it is defined in the answer, and was defined in the previous version, too.

    – marmot
    1 hour ago











  • Thanks! It looks fantastic. How can we take a single element from the list of arrows to change its path (I mean three of the yellow and one of the lightblue arrows, which overlap with the pics), but preserving the color? I will wait a second proposal of yours.

    – manooooh
    55 mins ago













  • WOW, you are awesome!! I do not understand "The list can consist of 1 or 0 elements", could you talk about that a little more specific, please? I can see that we have "{2,10/5,13/5,14/5}", where after the backslash we have 1 node (the 5), and in "{36/{12,21,29}}" we have {12,21,29}, which is also one element, right?

    – manooooh
    26 mins ago













  • For example, if we consider what's after the backslash in "{10,13,14,25/13}" we can say: 10 has no elements after the backslash, the same for 13, but 25 has one element after the backslash, right?

    – manooooh
    24 mins ago

















@manooooh I edited my answer (but it is strange that you got the error).

– marmot
1 hour ago





@manooooh I edited my answer (but it is strange that you got the error).

– marmot
1 hour ago













@manooooh No, the error says that you do not have the style along node, but it is defined in the answer, and was defined in the previous version, too.

– marmot
1 hour ago





@manooooh No, the error says that you do not have the style along node, but it is defined in the answer, and was defined in the previous version, too.

– marmot
1 hour ago













Thanks! It looks fantastic. How can we take a single element from the list of arrows to change its path (I mean three of the yellow and one of the lightblue arrows, which overlap with the pics), but preserving the color? I will wait a second proposal of yours.

– manooooh
55 mins ago







Thanks! It looks fantastic. How can we take a single element from the list of arrows to change its path (I mean three of the yellow and one of the lightblue arrows, which overlap with the pics), but preserving the color? I will wait a second proposal of yours.

– manooooh
55 mins ago















WOW, you are awesome!! I do not understand "The list can consist of 1 or 0 elements", could you talk about that a little more specific, please? I can see that we have "{2,10/5,13/5,14/5}", where after the backslash we have 1 node (the 5), and in "{36/{12,21,29}}" we have {12,21,29}, which is also one element, right?

– manooooh
26 mins ago







WOW, you are awesome!! I do not understand "The list can consist of 1 or 0 elements", could you talk about that a little more specific, please? I can see that we have "{2,10/5,13/5,14/5}", where after the backslash we have 1 node (the 5), and in "{36/{12,21,29}}" we have {12,21,29}, which is also one element, right?

– manooooh
26 mins ago















For example, if we consider what's after the backslash in "{10,13,14,25/13}" we can say: 10 has no elements after the backslash, the same for 13, but 25 has one element after the backslash, right?

– manooooh
24 mins ago





For example, if we consider what's after the backslash in "{10,13,14,25/13}" we can say: 10 has no elements after the backslash, the same for 13, but 25 has one element after the backslash, right?

– manooooh
24 mins ago


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480836%2fdesign-an-algorithm-capable-of-predicting-collisions-to-choose-alternative-path%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)