How to determine nodes to reduce their length using `tikzpicture` environmentChecking whether or not a node...

Weird lines in Microsoft Word

Why is this tree refusing to shed its dead leaves?

Do native speakers use "ultima" and "proxima" frequently in spoken English?

PTIJ: Which Dr. Seuss books should one obtain?

Can "few" be used as a subject? If so, what is the rule?

Pre-Employment Background Check With Consent For Future Checks

Difficulty understanding group delay concept

Is VPN a layer 3 concept?

Why doesn't the chatan sign the ketubah?

What will the french man say?

When should a starting writer get his own webpage?

pipe commands inside find -exec?

What is the tangent at a sharp point on a curve?

Why does Surtur say that Thor is Asgard's doom?

Why is indicated airspeed rather than ground speed used during the takeoff roll?

Does convergence of polynomials imply that of its coefficients?

Norwegian Refugee travel document

Unfrosted light bulb

If I cast the Enlarge/Reduce spell on an arrow, what weapon could it count as?

How to find the largest number(s) in a list of elements?

Why are there no stars visible in cislunar space?

Help with identifying unique aircraft over NE Pennsylvania

The English Debate

Do I need to convey a moral for each of my blog post?



How to determine nodes to reduce their length using `tikzpicture` environment


Checking whether or not a node has been previously definedHow to draw a diagram of custom subject correlativitiesHow to insert elective subjects section within a diagramHow to modify nodes in TikZ to automatically add a line on their top?How to reduce the space between nodes?How to reduce the render of tikzpictureTikZ/ERD: node (=Entity) label on the insideHow to reduce length of and edge between two nodes without affecting a custom line marker?How to reduce the fill in many nodes for tikzTikZ: Using current length inside scope environmentHow to move tikzpicture with named nodes?How to create an ER diagram using tikzpicture environmentHow to draw this rectangle using tikzpicture environment













0















This is and addendum of a previous question: How to insert elective subjects section within a diagram.



What I want



I would like to reduce the length of those nodes that only have a single column of a matrix environment of the Tikz package but keeping the same space between nodes. If possible, also do it automatically (it is not necessary at all, just know what the necessary commands are):



What I want



What I have done



MWE:



All the following source code belongs to marmot in the incredible accepted answer of the attached question. I only modified the nodes and things like that.



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

usepackage{tikz}
usetikzlibrary{positioning,backgrounds,fit,calc}
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=3cm, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
} % 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}

ifdefinedmymatdist
%typeout{gotspacemymatdist}
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatdist{150pt}
fi
ifdefinedmymatbottom
%typeout{gotspacemymatbottom}
else
typeout{Pleasespace recompilespace yourspace file!}
defmymatbottom{-150pt}
fi
ifdefinedmyheight
else
defmyheight{0}
typeout{Pleasespace recompilespace yourspace file!}
fi
ifdefinedLstMatShifts
else
defLstMatShifts{{0pt,0pt,0pt,0pt,0pt}}
fi
%typeout{height:myheight}
%typeout{shifts(in):LstMatShifts}

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 (0*mymatdist,{LstMatShifts[0]}) {
& pic[local bounding box=A] (A) {nonfillable subject={Subject A}}; & \
& pic (B) {nonfillable subject={Subject B}}; & \
};
matrix[manoooh] (mat1) at (1*mymatdist,{LstMatShifts[1]}) {
& pic (C) {nonfillable subject={Subject C}}; & \
& pic (D) {nonfillable subject={Subject D}}; & \
& pic (E) {nonfillable subject={Subject E}}; & \
& pic (F) {nonfillable subject={Subject F}}; & \
& pic (G) {nonfillable subject={Subject G}}; & \
& pic (H) {nonfillable subject={Subject H}}; & \
& pic (I) {nonfillable subject={Subject I}}; & \
& pic[draw=red] (J) {nonfillable subject={Subject J}}; & \
};
matrix[manoooh] (mat2) at (2*mymatdist,{LstMatShifts[2]}) {
& pic[draw=red] (K) {nonfillable subject={Subject K}}; & \
& pic (L) {nonfillable subject={Subject L}}; & \
& pic (M) {nonfillable subject={Subject A}}; & \
& pic (N) {nonfillable subject={Subject N}}; & \
& pic (O) {nonfillable subject={Subject O}}; & \
& pic (P) {nonfillable subject={Subject P}}; & \
& pic (Q) {nonfillable subject={Subject Q}}; & \
& pic (R) {nonfillable subject={Subject R}}; & \
};
matrix[manoooh] (mat3) at (3*mymatdist,{LstMatShifts[3]}) {
& pic[draw=red] (S) {nonfillable subject={Subject S}}; & \
& pic (T) {nonfillable subject={Subject T}}; & \
& pic (U) {nonfillable subject={Subject U}}; & \
& pic (V) {nonfillable subject={Subject V}}; & \
& pic (W) {nonfillable subject={Subject W}}; & \
& pic (X) {nonfillable subject={Subject X}}; & \
& pic (Y) {nonfillable subject={Subject Y}}; & \
& pic (Z) {nonfillable subject={Subject Z}}; & \
};
matrix[manooohE,column sep=8pt] (matE3) at (3*mymatdist,mymatbottom) {
pic (L3E1) {nonfillable elective subject={Subject}}; &
pic (L3E2) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat4) at (4*mymatdist,{LstMatShifts[4]}) {
& pic[draw=red] (AA) {nonfillable subject={Subject AA}}; & \
pic (AB) {nonfillable subject={Subject AB}}; & & pic (AC) {nonfillable subject={Subject AC}}; \
& pic (AD) {nonfillable subject={Subject AD}}; & \
& pic (AE) {nonfillable subject={Subject AE}}; & \
& pic (AF) {nonfillable subject={Subject AF}}; & \
& pic (AG) {nonfillable subject={Subject AG}}; & \
};
matrix[manooohE] (matE4) at (4*mymatdist,mymatbottom) {
pic (L4E1) {nonfillable elective subject={Subject}}; \
};
matrix[manoooh] (mat5) at (5*mymatdist,{LstMatShifts[5]}) {
& pic (AH) {nonfillable subject={Subject AH}}; & \
& pic (AI) {nonfillable subject={Subject AI}}; & \
& pic[draw=red] (AJ) {nonfillable subject={Subject AJ}}; & \
& pic (AK) {nonfillable subject={Subject AK}}; & \
};
matrix[manooohE] (matE5) at (5*mymatdist,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{mywidth}{0}
foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
{
ifnodedefined{matEX}{% has inlay
path let p1=($(matX.north east)-(matX.south west)$),
p2=($(matEX.north east)-(matEX.south west)$)
in
pgfextra{pgfmathsetmacro{mywidth}{max(x1,mywidth)}
pgfmathsetmacro{myheight}{max(y1+y2+%
pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
myheight)}
xdefmywidth{mywidth}xdefmyheight{myheight}
pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
ifnumX=0
xdefLstMatShifts{myshift pt}
else
xdefLstMatShifts{LstMatShifts,myshift pt}
fi};}{% no inlay
path
let p1=($(matX.north east)-(matX.south west)$) in
pgfextra{pgfmathsetmacro{mywidth}{max(x1,mywidth)}
pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
xdefmywidth{mywidth}xdefmyheight{myheight}};
ifnumX=0
xdefLstMatShifts{0pt}
else
xdefLstMatShifts{LstMatShifts,0pt}
fi
}
node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
at (matX |-matrices.north) (LX) {Level $X$};
begin{scope}[on background layer]
% the fit parameters determine the shape of the background rectangles
node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=5mm,
minimum width=mymatdist-pgfkeysvalueof{/tikz/fit dist}/2,
fill=orange!30,rounded corners=50pt](FX){};
end{scope}}
%typeout{height1:myheight} %
%
pgfmathsetmacro{mydist}{mywidth+2*pgfkeysvalueof{/tikz/fit
sep}+pgfkeysvalueof{/tikz/fit dist}}
xdefmydist{mydist}
defmymatbottom{0pt}
foreach X in {0,...,5} %
{ifnodedefined{matEX}{path let p1=($(matX.north)-(matX.south)$),
p2=($(matEX.north)-(matEX.south)$),
n1={max(abs(y1)/2+abs(y2)+2*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
in pgfextra{xdefmymatbottom{n1}}
node[anchor=south east,xshift=-3cm,font=LARGEbfseries] (ElX)
at (matEX.north){Electives};
begin{scope}[on background layer]
node[fit=(matEX) (ElX)] (FEX){};
fill[blue!30,rounded corners=30pt] (X*mymatdist-
mymatdist/2+pgfkeysvalueof{/tikz/fit dist}/4+10pt,0|-FEX.north)
rectangle (X*mymatdist+
mymatdist/2-pgfkeysvalueof{/tikz/fit dist}/4-10pt,0|-FEX.south);
end{scope}}{}}
%typeout{shifts(end):LstMatShifts}
makeatletter
immediatewrite@mainaux{xdefstringmymatdist{mydist pt}relax}
immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
immediatewrite@mainaux{xdefstringLstMatShifts{{LstMatShifts}}relax}
makeatother

% now add the arrows
foreach X in {C,D,E,F,G,H,I,J} {
draw[very thick,blue,-latex] (A-Title) to[out=0,in=180] (X-Title);
draw[very thick,red,-latex] (B-Title) to[out=0,in=180] (X-Title);
}
foreach X in {L,O} {
draw[very thick,orange,-latex] (C-Title) to[out=0,in=180] (X-Title);
}
foreach X in {K,N,O,Z} {
draw[very thick,green,-latex] (D-Title) to[out=0,in=180] (X-Title);
}
end{tikzpicture}
end{Form}

vfill

end{document}


What I have done



Thanks!!










share|improve this question



























    0















    This is and addendum of a previous question: How to insert elective subjects section within a diagram.



    What I want



    I would like to reduce the length of those nodes that only have a single column of a matrix environment of the Tikz package but keeping the same space between nodes. If possible, also do it automatically (it is not necessary at all, just know what the necessary commands are):



    What I want



    What I have done



    MWE:



    All the following source code belongs to marmot in the incredible accepted answer of the attached question. I only modified the nodes and things like that.



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

    usepackage{tikz}
    usetikzlibrary{positioning,backgrounds,fit,calc}
    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=3cm, % change node distance (big rectangle shape)
    inlay top sep/.initial=24pt,
    matrix top sep/.initial=24pt,
    } % 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}

    ifdefinedmymatdist
    %typeout{gotspacemymatdist}
    else
    typeout{Pleasespace recompilespace yourspace file!}
    defmymatdist{150pt}
    fi
    ifdefinedmymatbottom
    %typeout{gotspacemymatbottom}
    else
    typeout{Pleasespace recompilespace yourspace file!}
    defmymatbottom{-150pt}
    fi
    ifdefinedmyheight
    else
    defmyheight{0}
    typeout{Pleasespace recompilespace yourspace file!}
    fi
    ifdefinedLstMatShifts
    else
    defLstMatShifts{{0pt,0pt,0pt,0pt,0pt}}
    fi
    %typeout{height:myheight}
    %typeout{shifts(in):LstMatShifts}

    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 (0*mymatdist,{LstMatShifts[0]}) {
    & pic[local bounding box=A] (A) {nonfillable subject={Subject A}}; & \
    & pic (B) {nonfillable subject={Subject B}}; & \
    };
    matrix[manoooh] (mat1) at (1*mymatdist,{LstMatShifts[1]}) {
    & pic (C) {nonfillable subject={Subject C}}; & \
    & pic (D) {nonfillable subject={Subject D}}; & \
    & pic (E) {nonfillable subject={Subject E}}; & \
    & pic (F) {nonfillable subject={Subject F}}; & \
    & pic (G) {nonfillable subject={Subject G}}; & \
    & pic (H) {nonfillable subject={Subject H}}; & \
    & pic (I) {nonfillable subject={Subject I}}; & \
    & pic[draw=red] (J) {nonfillable subject={Subject J}}; & \
    };
    matrix[manoooh] (mat2) at (2*mymatdist,{LstMatShifts[2]}) {
    & pic[draw=red] (K) {nonfillable subject={Subject K}}; & \
    & pic (L) {nonfillable subject={Subject L}}; & \
    & pic (M) {nonfillable subject={Subject A}}; & \
    & pic (N) {nonfillable subject={Subject N}}; & \
    & pic (O) {nonfillable subject={Subject O}}; & \
    & pic (P) {nonfillable subject={Subject P}}; & \
    & pic (Q) {nonfillable subject={Subject Q}}; & \
    & pic (R) {nonfillable subject={Subject R}}; & \
    };
    matrix[manoooh] (mat3) at (3*mymatdist,{LstMatShifts[3]}) {
    & pic[draw=red] (S) {nonfillable subject={Subject S}}; & \
    & pic (T) {nonfillable subject={Subject T}}; & \
    & pic (U) {nonfillable subject={Subject U}}; & \
    & pic (V) {nonfillable subject={Subject V}}; & \
    & pic (W) {nonfillable subject={Subject W}}; & \
    & pic (X) {nonfillable subject={Subject X}}; & \
    & pic (Y) {nonfillable subject={Subject Y}}; & \
    & pic (Z) {nonfillable subject={Subject Z}}; & \
    };
    matrix[manooohE,column sep=8pt] (matE3) at (3*mymatdist,mymatbottom) {
    pic (L3E1) {nonfillable elective subject={Subject}}; &
    pic (L3E2) {nonfillable elective subject={Subject}}; \
    };
    matrix[manoooh] (mat4) at (4*mymatdist,{LstMatShifts[4]}) {
    & pic[draw=red] (AA) {nonfillable subject={Subject AA}}; & \
    pic (AB) {nonfillable subject={Subject AB}}; & & pic (AC) {nonfillable subject={Subject AC}}; \
    & pic (AD) {nonfillable subject={Subject AD}}; & \
    & pic (AE) {nonfillable subject={Subject AE}}; & \
    & pic (AF) {nonfillable subject={Subject AF}}; & \
    & pic (AG) {nonfillable subject={Subject AG}}; & \
    };
    matrix[manooohE] (matE4) at (4*mymatdist,mymatbottom) {
    pic (L4E1) {nonfillable elective subject={Subject}}; \
    };
    matrix[manoooh] (mat5) at (5*mymatdist,{LstMatShifts[5]}) {
    & pic (AH) {nonfillable subject={Subject AH}}; & \
    & pic (AI) {nonfillable subject={Subject AI}}; & \
    & pic[draw=red] (AJ) {nonfillable subject={Subject AJ}}; & \
    & pic (AK) {nonfillable subject={Subject AK}}; & \
    };
    matrix[manooohE] (matE5) at (5*mymatdist,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{mywidth}{0}
    foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
    {
    ifnodedefined{matEX}{% has inlay
    path let p1=($(matX.north east)-(matX.south west)$),
    p2=($(matEX.north east)-(matEX.south west)$)
    in
    pgfextra{pgfmathsetmacro{mywidth}{max(x1,mywidth)}
    pgfmathsetmacro{myheight}{max(y1+y2+%
    pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
    myheight)}
    xdefmywidth{mywidth}xdefmyheight{myheight}
    pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
    ifnumX=0
    xdefLstMatShifts{myshift pt}
    else
    xdefLstMatShifts{LstMatShifts,myshift pt}
    fi};}{% no inlay
    path
    let p1=($(matX.north east)-(matX.south west)$) in
    pgfextra{pgfmathsetmacro{mywidth}{max(x1,mywidth)}
    pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
    xdefmywidth{mywidth}xdefmyheight{myheight}};
    ifnumX=0
    xdefLstMatShifts{0pt}
    else
    xdefLstMatShifts{LstMatShifts,0pt}
    fi
    }
    node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
    at (matX |-matrices.north) (LX) {Level $X$};
    begin{scope}[on background layer]
    % the fit parameters determine the shape of the background rectangles
    node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=5mm,
    minimum width=mymatdist-pgfkeysvalueof{/tikz/fit dist}/2,
    fill=orange!30,rounded corners=50pt](FX){};
    end{scope}}
    %typeout{height1:myheight} %
    %
    pgfmathsetmacro{mydist}{mywidth+2*pgfkeysvalueof{/tikz/fit
    sep}+pgfkeysvalueof{/tikz/fit dist}}
    xdefmydist{mydist}
    defmymatbottom{0pt}
    foreach X in {0,...,5} %
    {ifnodedefined{matEX}{path let p1=($(matX.north)-(matX.south)$),
    p2=($(matEX.north)-(matEX.south)$),
    n1={max(abs(y1)/2+abs(y2)+2*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
    in pgfextra{xdefmymatbottom{n1}}
    node[anchor=south east,xshift=-3cm,font=LARGEbfseries] (ElX)
    at (matEX.north){Electives};
    begin{scope}[on background layer]
    node[fit=(matEX) (ElX)] (FEX){};
    fill[blue!30,rounded corners=30pt] (X*mymatdist-
    mymatdist/2+pgfkeysvalueof{/tikz/fit dist}/4+10pt,0|-FEX.north)
    rectangle (X*mymatdist+
    mymatdist/2-pgfkeysvalueof{/tikz/fit dist}/4-10pt,0|-FEX.south);
    end{scope}}{}}
    %typeout{shifts(end):LstMatShifts}
    makeatletter
    immediatewrite@mainaux{xdefstringmymatdist{mydist pt}relax}
    immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
    immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
    immediatewrite@mainaux{xdefstringLstMatShifts{{LstMatShifts}}relax}
    makeatother

    % now add the arrows
    foreach X in {C,D,E,F,G,H,I,J} {
    draw[very thick,blue,-latex] (A-Title) to[out=0,in=180] (X-Title);
    draw[very thick,red,-latex] (B-Title) to[out=0,in=180] (X-Title);
    }
    foreach X in {L,O} {
    draw[very thick,orange,-latex] (C-Title) to[out=0,in=180] (X-Title);
    }
    foreach X in {K,N,O,Z} {
    draw[very thick,green,-latex] (D-Title) to[out=0,in=180] (X-Title);
    }
    end{tikzpicture}
    end{Form}

    vfill

    end{document}


    What I have done



    Thanks!!










    share|improve this question

























      0












      0








      0








      This is and addendum of a previous question: How to insert elective subjects section within a diagram.



      What I want



      I would like to reduce the length of those nodes that only have a single column of a matrix environment of the Tikz package but keeping the same space between nodes. If possible, also do it automatically (it is not necessary at all, just know what the necessary commands are):



      What I want



      What I have done



      MWE:



      All the following source code belongs to marmot in the incredible accepted answer of the attached question. I only modified the nodes and things like that.



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

      usepackage{tikz}
      usetikzlibrary{positioning,backgrounds,fit,calc}
      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=3cm, % change node distance (big rectangle shape)
      inlay top sep/.initial=24pt,
      matrix top sep/.initial=24pt,
      } % 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}

      ifdefinedmymatdist
      %typeout{gotspacemymatdist}
      else
      typeout{Pleasespace recompilespace yourspace file!}
      defmymatdist{150pt}
      fi
      ifdefinedmymatbottom
      %typeout{gotspacemymatbottom}
      else
      typeout{Pleasespace recompilespace yourspace file!}
      defmymatbottom{-150pt}
      fi
      ifdefinedmyheight
      else
      defmyheight{0}
      typeout{Pleasespace recompilespace yourspace file!}
      fi
      ifdefinedLstMatShifts
      else
      defLstMatShifts{{0pt,0pt,0pt,0pt,0pt}}
      fi
      %typeout{height:myheight}
      %typeout{shifts(in):LstMatShifts}

      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 (0*mymatdist,{LstMatShifts[0]}) {
      & pic[local bounding box=A] (A) {nonfillable subject={Subject A}}; & \
      & pic (B) {nonfillable subject={Subject B}}; & \
      };
      matrix[manoooh] (mat1) at (1*mymatdist,{LstMatShifts[1]}) {
      & pic (C) {nonfillable subject={Subject C}}; & \
      & pic (D) {nonfillable subject={Subject D}}; & \
      & pic (E) {nonfillable subject={Subject E}}; & \
      & pic (F) {nonfillable subject={Subject F}}; & \
      & pic (G) {nonfillable subject={Subject G}}; & \
      & pic (H) {nonfillable subject={Subject H}}; & \
      & pic (I) {nonfillable subject={Subject I}}; & \
      & pic[draw=red] (J) {nonfillable subject={Subject J}}; & \
      };
      matrix[manoooh] (mat2) at (2*mymatdist,{LstMatShifts[2]}) {
      & pic[draw=red] (K) {nonfillable subject={Subject K}}; & \
      & pic (L) {nonfillable subject={Subject L}}; & \
      & pic (M) {nonfillable subject={Subject A}}; & \
      & pic (N) {nonfillable subject={Subject N}}; & \
      & pic (O) {nonfillable subject={Subject O}}; & \
      & pic (P) {nonfillable subject={Subject P}}; & \
      & pic (Q) {nonfillable subject={Subject Q}}; & \
      & pic (R) {nonfillable subject={Subject R}}; & \
      };
      matrix[manoooh] (mat3) at (3*mymatdist,{LstMatShifts[3]}) {
      & pic[draw=red] (S) {nonfillable subject={Subject S}}; & \
      & pic (T) {nonfillable subject={Subject T}}; & \
      & pic (U) {nonfillable subject={Subject U}}; & \
      & pic (V) {nonfillable subject={Subject V}}; & \
      & pic (W) {nonfillable subject={Subject W}}; & \
      & pic (X) {nonfillable subject={Subject X}}; & \
      & pic (Y) {nonfillable subject={Subject Y}}; & \
      & pic (Z) {nonfillable subject={Subject Z}}; & \
      };
      matrix[manooohE,column sep=8pt] (matE3) at (3*mymatdist,mymatbottom) {
      pic (L3E1) {nonfillable elective subject={Subject}}; &
      pic (L3E2) {nonfillable elective subject={Subject}}; \
      };
      matrix[manoooh] (mat4) at (4*mymatdist,{LstMatShifts[4]}) {
      & pic[draw=red] (AA) {nonfillable subject={Subject AA}}; & \
      pic (AB) {nonfillable subject={Subject AB}}; & & pic (AC) {nonfillable subject={Subject AC}}; \
      & pic (AD) {nonfillable subject={Subject AD}}; & \
      & pic (AE) {nonfillable subject={Subject AE}}; & \
      & pic (AF) {nonfillable subject={Subject AF}}; & \
      & pic (AG) {nonfillable subject={Subject AG}}; & \
      };
      matrix[manooohE] (matE4) at (4*mymatdist,mymatbottom) {
      pic (L4E1) {nonfillable elective subject={Subject}}; \
      };
      matrix[manoooh] (mat5) at (5*mymatdist,{LstMatShifts[5]}) {
      & pic (AH) {nonfillable subject={Subject AH}}; & \
      & pic (AI) {nonfillable subject={Subject AI}}; & \
      & pic[draw=red] (AJ) {nonfillable subject={Subject AJ}}; & \
      & pic (AK) {nonfillable subject={Subject AK}}; & \
      };
      matrix[manooohE] (matE5) at (5*mymatdist,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{mywidth}{0}
      foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
      {
      ifnodedefined{matEX}{% has inlay
      path let p1=($(matX.north east)-(matX.south west)$),
      p2=($(matEX.north east)-(matEX.south west)$)
      in
      pgfextra{pgfmathsetmacro{mywidth}{max(x1,mywidth)}
      pgfmathsetmacro{myheight}{max(y1+y2+%
      pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
      myheight)}
      xdefmywidth{mywidth}xdefmyheight{myheight}
      pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
      ifnumX=0
      xdefLstMatShifts{myshift pt}
      else
      xdefLstMatShifts{LstMatShifts,myshift pt}
      fi};}{% no inlay
      path
      let p1=($(matX.north east)-(matX.south west)$) in
      pgfextra{pgfmathsetmacro{mywidth}{max(x1,mywidth)}
      pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
      xdefmywidth{mywidth}xdefmyheight{myheight}};
      ifnumX=0
      xdefLstMatShifts{0pt}
      else
      xdefLstMatShifts{LstMatShifts,0pt}
      fi
      }
      node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
      at (matX |-matrices.north) (LX) {Level $X$};
      begin{scope}[on background layer]
      % the fit parameters determine the shape of the background rectangles
      node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=5mm,
      minimum width=mymatdist-pgfkeysvalueof{/tikz/fit dist}/2,
      fill=orange!30,rounded corners=50pt](FX){};
      end{scope}}
      %typeout{height1:myheight} %
      %
      pgfmathsetmacro{mydist}{mywidth+2*pgfkeysvalueof{/tikz/fit
      sep}+pgfkeysvalueof{/tikz/fit dist}}
      xdefmydist{mydist}
      defmymatbottom{0pt}
      foreach X in {0,...,5} %
      {ifnodedefined{matEX}{path let p1=($(matX.north)-(matX.south)$),
      p2=($(matEX.north)-(matEX.south)$),
      n1={max(abs(y1)/2+abs(y2)+2*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
      in pgfextra{xdefmymatbottom{n1}}
      node[anchor=south east,xshift=-3cm,font=LARGEbfseries] (ElX)
      at (matEX.north){Electives};
      begin{scope}[on background layer]
      node[fit=(matEX) (ElX)] (FEX){};
      fill[blue!30,rounded corners=30pt] (X*mymatdist-
      mymatdist/2+pgfkeysvalueof{/tikz/fit dist}/4+10pt,0|-FEX.north)
      rectangle (X*mymatdist+
      mymatdist/2-pgfkeysvalueof{/tikz/fit dist}/4-10pt,0|-FEX.south);
      end{scope}}{}}
      %typeout{shifts(end):LstMatShifts}
      makeatletter
      immediatewrite@mainaux{xdefstringmymatdist{mydist pt}relax}
      immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
      immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
      immediatewrite@mainaux{xdefstringLstMatShifts{{LstMatShifts}}relax}
      makeatother

      % now add the arrows
      foreach X in {C,D,E,F,G,H,I,J} {
      draw[very thick,blue,-latex] (A-Title) to[out=0,in=180] (X-Title);
      draw[very thick,red,-latex] (B-Title) to[out=0,in=180] (X-Title);
      }
      foreach X in {L,O} {
      draw[very thick,orange,-latex] (C-Title) to[out=0,in=180] (X-Title);
      }
      foreach X in {K,N,O,Z} {
      draw[very thick,green,-latex] (D-Title) to[out=0,in=180] (X-Title);
      }
      end{tikzpicture}
      end{Form}

      vfill

      end{document}


      What I have done



      Thanks!!










      share|improve this question














      This is and addendum of a previous question: How to insert elective subjects section within a diagram.



      What I want



      I would like to reduce the length of those nodes that only have a single column of a matrix environment of the Tikz package but keeping the same space between nodes. If possible, also do it automatically (it is not necessary at all, just know what the necessary commands are):



      What I want



      What I have done



      MWE:



      All the following source code belongs to marmot in the incredible accepted answer of the attached question. I only modified the nodes and things like that.



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

      usepackage{tikz}
      usetikzlibrary{positioning,backgrounds,fit,calc}
      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=3cm, % change node distance (big rectangle shape)
      inlay top sep/.initial=24pt,
      matrix top sep/.initial=24pt,
      } % 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}

      ifdefinedmymatdist
      %typeout{gotspacemymatdist}
      else
      typeout{Pleasespace recompilespace yourspace file!}
      defmymatdist{150pt}
      fi
      ifdefinedmymatbottom
      %typeout{gotspacemymatbottom}
      else
      typeout{Pleasespace recompilespace yourspace file!}
      defmymatbottom{-150pt}
      fi
      ifdefinedmyheight
      else
      defmyheight{0}
      typeout{Pleasespace recompilespace yourspace file!}
      fi
      ifdefinedLstMatShifts
      else
      defLstMatShifts{{0pt,0pt,0pt,0pt,0pt}}
      fi
      %typeout{height:myheight}
      %typeout{shifts(in):LstMatShifts}

      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 (0*mymatdist,{LstMatShifts[0]}) {
      & pic[local bounding box=A] (A) {nonfillable subject={Subject A}}; & \
      & pic (B) {nonfillable subject={Subject B}}; & \
      };
      matrix[manoooh] (mat1) at (1*mymatdist,{LstMatShifts[1]}) {
      & pic (C) {nonfillable subject={Subject C}}; & \
      & pic (D) {nonfillable subject={Subject D}}; & \
      & pic (E) {nonfillable subject={Subject E}}; & \
      & pic (F) {nonfillable subject={Subject F}}; & \
      & pic (G) {nonfillable subject={Subject G}}; & \
      & pic (H) {nonfillable subject={Subject H}}; & \
      & pic (I) {nonfillable subject={Subject I}}; & \
      & pic[draw=red] (J) {nonfillable subject={Subject J}}; & \
      };
      matrix[manoooh] (mat2) at (2*mymatdist,{LstMatShifts[2]}) {
      & pic[draw=red] (K) {nonfillable subject={Subject K}}; & \
      & pic (L) {nonfillable subject={Subject L}}; & \
      & pic (M) {nonfillable subject={Subject A}}; & \
      & pic (N) {nonfillable subject={Subject N}}; & \
      & pic (O) {nonfillable subject={Subject O}}; & \
      & pic (P) {nonfillable subject={Subject P}}; & \
      & pic (Q) {nonfillable subject={Subject Q}}; & \
      & pic (R) {nonfillable subject={Subject R}}; & \
      };
      matrix[manoooh] (mat3) at (3*mymatdist,{LstMatShifts[3]}) {
      & pic[draw=red] (S) {nonfillable subject={Subject S}}; & \
      & pic (T) {nonfillable subject={Subject T}}; & \
      & pic (U) {nonfillable subject={Subject U}}; & \
      & pic (V) {nonfillable subject={Subject V}}; & \
      & pic (W) {nonfillable subject={Subject W}}; & \
      & pic (X) {nonfillable subject={Subject X}}; & \
      & pic (Y) {nonfillable subject={Subject Y}}; & \
      & pic (Z) {nonfillable subject={Subject Z}}; & \
      };
      matrix[manooohE,column sep=8pt] (matE3) at (3*mymatdist,mymatbottom) {
      pic (L3E1) {nonfillable elective subject={Subject}}; &
      pic (L3E2) {nonfillable elective subject={Subject}}; \
      };
      matrix[manoooh] (mat4) at (4*mymatdist,{LstMatShifts[4]}) {
      & pic[draw=red] (AA) {nonfillable subject={Subject AA}}; & \
      pic (AB) {nonfillable subject={Subject AB}}; & & pic (AC) {nonfillable subject={Subject AC}}; \
      & pic (AD) {nonfillable subject={Subject AD}}; & \
      & pic (AE) {nonfillable subject={Subject AE}}; & \
      & pic (AF) {nonfillable subject={Subject AF}}; & \
      & pic (AG) {nonfillable subject={Subject AG}}; & \
      };
      matrix[manooohE] (matE4) at (4*mymatdist,mymatbottom) {
      pic (L4E1) {nonfillable elective subject={Subject}}; \
      };
      matrix[manoooh] (mat5) at (5*mymatdist,{LstMatShifts[5]}) {
      & pic (AH) {nonfillable subject={Subject AH}}; & \
      & pic (AI) {nonfillable subject={Subject AI}}; & \
      & pic[draw=red] (AJ) {nonfillable subject={Subject AJ}}; & \
      & pic (AK) {nonfillable subject={Subject AK}}; & \
      };
      matrix[manooohE] (matE5) at (5*mymatdist,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{mywidth}{0}
      foreach X in {0,...,5} %<- if you have more or less matrices, adjust 3
      {
      ifnodedefined{matEX}{% has inlay
      path let p1=($(matX.north east)-(matX.south west)$),
      p2=($(matEX.north east)-(matEX.south west)$)
      in
      pgfextra{pgfmathsetmacro{mywidth}{max(x1,mywidth)}
      pgfmathsetmacro{myheight}{max(y1+y2+%
      pgfkeysvalueof{/tikz/inlay top sep}+pgfkeysvalueof{/tikz/matrix top sep},%
      myheight)}
      xdefmywidth{mywidth}xdefmyheight{myheight}
      pgfmathsetmacro{myshift}{(pgfkeysvalueof{/tikz/inlay top sep}+y2)/2}
      ifnumX=0
      xdefLstMatShifts{myshift pt}
      else
      xdefLstMatShifts{LstMatShifts,myshift pt}
      fi};}{% no inlay
      path
      let p1=($(matX.north east)-(matX.south west)$) in
      pgfextra{pgfmathsetmacro{mywidth}{max(x1,mywidth)}
      pgfmathsetmacro{myheight}{max(y1+pgfkeysvalueof{/tikz/matrix top sep},myheight)}
      xdefmywidth{mywidth}xdefmyheight{myheight}};
      ifnumX=0
      xdefLstMatShifts{0pt}
      else
      xdefLstMatShifts{LstMatShifts,0pt}
      fi
      }
      node[anchor=south,yshift=1cm,align=center,font=LARGEbfseriesboldmath]
      at (matX |-matrices.north) (LX) {Level $X$};
      begin{scope}[on background layer]
      % the fit parameters determine the shape of the background rectangles
      node[fit=(LX) (matX) (matrices.south-|matX.south),inner ysep=5mm,
      minimum width=mymatdist-pgfkeysvalueof{/tikz/fit dist}/2,
      fill=orange!30,rounded corners=50pt](FX){};
      end{scope}}
      %typeout{height1:myheight} %
      %
      pgfmathsetmacro{mydist}{mywidth+2*pgfkeysvalueof{/tikz/fit
      sep}+pgfkeysvalueof{/tikz/fit dist}}
      xdefmydist{mydist}
      defmymatbottom{0pt}
      foreach X in {0,...,5} %
      {ifnodedefined{matEX}{path let p1=($(matX.north)-(matX.south)$),
      p2=($(matEX.north)-(matEX.south)$),
      n1={max(abs(y1)/2+abs(y2)+2*pgfkeysvalueof{/tikz/inlay top sep},mymatbottom)}
      in pgfextra{xdefmymatbottom{n1}}
      node[anchor=south east,xshift=-3cm,font=LARGEbfseries] (ElX)
      at (matEX.north){Electives};
      begin{scope}[on background layer]
      node[fit=(matEX) (ElX)] (FEX){};
      fill[blue!30,rounded corners=30pt] (X*mymatdist-
      mymatdist/2+pgfkeysvalueof{/tikz/fit dist}/4+10pt,0|-FEX.north)
      rectangle (X*mymatdist+
      mymatdist/2-pgfkeysvalueof{/tikz/fit dist}/4-10pt,0|-FEX.south);
      end{scope}}{}}
      %typeout{shifts(end):LstMatShifts}
      makeatletter
      immediatewrite@mainaux{xdefstringmymatdist{mydist pt}relax}
      immediatewrite@mainaux{xdefstringmymatbottom{-mymatbottom}relax}
      immediatewrite@mainaux{xdefstringmyheight{myheight}relax}
      immediatewrite@mainaux{xdefstringLstMatShifts{{LstMatShifts}}relax}
      makeatother

      % now add the arrows
      foreach X in {C,D,E,F,G,H,I,J} {
      draw[very thick,blue,-latex] (A-Title) to[out=0,in=180] (X-Title);
      draw[very thick,red,-latex] (B-Title) to[out=0,in=180] (X-Title);
      }
      foreach X in {L,O} {
      draw[very thick,orange,-latex] (C-Title) to[out=0,in=180] (X-Title);
      }
      foreach X in {K,N,O,Z} {
      draw[very thick,green,-latex] (D-Title) to[out=0,in=180] (X-Title);
      }
      end{tikzpicture}
      end{Form}

      vfill

      end{document}


      What I have done



      Thanks!!







      tikz-pgf horizontal-alignment






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 13 mins ago









      manoooohmanooooh

      1,0171516




      1,0171516






















          0






          active

          oldest

          votes











          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%2f480186%2fhow-to-determine-nodes-to-reduce-their-length-using-tikzpicture-environment%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f480186%2fhow-to-determine-nodes-to-reduce-their-length-using-tikzpicture-environment%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

          Installing LyX: “No textclass is found.”LyX installation error- text class not found- 'Reconfigure' or...

          (1602) Indiana Índice Designación y nombre Características orbitales Véase...

          Universidad Autónoma de Occidente Índice Historia Campus Facultades Programas Académicos Medios de...