TransWikia.com

Text Nodes not behaving nicely

TeX - LaTeX Asked by Kumarm on July 20, 2021

I am trying to recreate this image enter image description here

and so far I have got this.
enter image description here

The text in the right box is 3 lines and it gets weird. I tried increasing text width option.
However its not that nice option and left box also gets huge which I don’t want.

Please help me create this (almost) image.

    documentclass[border=10pt,tikz]{standalone}
    usepackage[utf8]{inputenc}
    usepackage{graphicx}
    usepackage{tikz}
    usetikzlibrary{trees,positioning,shapes,shadows,arrows}
    begin{document}
    
    tikzset{
      basic/.style  = {draw, text width=2cm, drop shadow, font=sffamily, rectangle},
      root/.style   = {basic, rounded corners=2pt, thin, align=center, fill=white},
      level-2/.style = {basic, rounded corners=3pt, thin,align=left, fill=white, text width=7cm},
      level-3/.style = {basic, thin, align=center, fill=white, text width=1.8cm}
    }
    
    
    begin{tikzpicture}[
      level 1/.style={sibling distance=30em, level distance=5em},
    %   {edge from parent fork down},
      edge from parent/.style={->,solid,black,thick,sloped,draw}, 
      edge from parent path={(tikzparentnode.south) -- (tikzchildnode.north)},
      >=latex, node distance=1.2cm, edge from parent fork down]
      node[root] (A) at (0,2)  {$AX=0$};
      draw[->] (A) to (0,.3);
     node[root] {textbf{Always consistent}} 
      child {node[level-2] (c1) {textbf{rank $A=n$}  textbf{Unique Solution $X=0$}}}
      child {node[level-2] (c1) {textbf{rank $A<n$}  textbf{Infinitely many Solutions  $n-r$ arbitrary parameters in solution}}}
      ;
    end{tikzpicture}  
    end{document}

4 Answers

Another solution using usetikzlibrary{calc}

tree v01

documentclass[border=5pt]{standalone}

usepackage{tikz}

usetikzlibrary{calc}

usepackage{makecell}

tikzstyle{orangenode}=[draw=black,minimum height=1cm,minimum width=4cm,fill=myorange]
tikzstyle{bluenode}=[draw=black,minimum height=1cm,minimum width=4cm,fill=myblue]


begin{document}
    begin{tikzpicture}
        definecolor{myorange}{RGB}{249,205,153}
        definecolor{myblue}{RGB}{151,173,172}
        
        %first system
        
        %draw nodes
        node(a0) [orangenode] at (0,0) {$ mathbf{AX=0} $};
        node(a1) [bluenode,anchor=north] at ($ (a0.south) - (0,1) $) {always consistent};
        node(a21) [bluenode,anchor=north] at ($ (a1.south west) - (1,1) $) {makecell[l]{Unique solution: $ mathbf{X=0} $  $ mathrm{rank(textbf{A})=n} $}};
        node(a22) [bluenode,anchor=north] at ($ (a1.south east) + (1,-1) $) {makecell[l]{Infinity of solutions: $ mathbf{X=0} $  $ mathrm{rank(textbf{A})<n} $  $ mathrm{n-r} $ arabitrary  parameters in solution}};
        
        %draw arrows
        draw[-stealth] (a0.south) -- (a1.north);
        draw[-stealth] (a1.south) --++ (0,-0.5cm);
        draw[-stealth] (a1.south) --++ (0,-0.5cm) -| (a21.north);
        draw[-stealth] (a1.south) --++ (0,-0.5cm) -| (a22.north);
        
        %second system
        
        %draw nodes
        node(b0) [orangenode,anchor=north] at ($ (a22.south)!0.5!(a21.south) - (0,1.5)$) {$ mathbf{AX=B, B neq 0} $};
        node(b11) [bluenode,anchor=north] at ($ (b0.south west) - (1,1) $) {makecell[l]{Consistent:  $ mathrm{rank(textbf{A})=rank(textbf{A|B})} $}};
        node(b12) [bluenode,anchor=north] at ($ (b0.south east) + (1,-1) $) {makecell[l]{Inconsistent:  $ mathrm{rank(textbf{A})<rank(textbf{A|B})} $}};
        node(b21) [bluenode,anchor=north] at ($ (b11.south west) - (1,1) $) {makecell[l]{Unique Solution:  $ mathrm{rank(textbf{A})=n} $}};
        node(b22) [bluenode,anchor=north] at ($ (b11.south east) + (1,-1) $) {makecell[l]{Infinity of Solutions:  $ mathrm{rank(textbf{A})<n,} $  $ mathrm{n-r} $ arbitrary   parameters in solution}};
        
        %draw arrows
        draw[-stealth] (b0.south) --++ (0,-0.5cm);
        draw[-stealth] (b0.south) --++ (0,-0.5cm) -| (b11.north);
        draw[-stealth] (b0.south) --++ (0,-0.5cm) -| (b12.north);
        draw[-stealth] (b11.south) --++ (0,-0.5cm);
        draw[-stealth] (b11.south) --++ (0,-0.5cm) -| (b21.north);
        draw[-stealth] (b11.south) --++ (0,-0.5cm) -| (b22.north);
        
    end{tikzpicture}
end{document}

Correct answer by Excelsior on July 20, 2021

With yshift=<value> you can manually adjust the child of the tree.

 documentclass[border=10pt,tikz]{standalone}
    usepackage[utf8]{inputenc}
    usepackage{graphicx}
    usepackage{tikz}
    usetikzlibrary{trees,positioning,shapes,shadows,arrows}
    begin{document}
    
    tikzset{
      basic/.style  = {draw, text width=2cm, drop shadow, font=sffamily, rectangle},
      root/.style   = {basic, rounded corners=2pt, thin, align=center, fill=white},
      level-2/.style = {basic, rounded corners=3pt, thin,align=left, fill=white, text width=7cm},
      level-3/.style = {basic, thin, align=center, fill=white, text width=1.8cm}
    }
    
    
    begin{tikzpicture}[
      level 1/.style={sibling distance=30em, level distance=5em},
    %   {edge from parent fork down},
      edge from parent/.style={->,solid,black,thick,sloped,draw}, 
      edge from parent path={(tikzparentnode.south) -- (tikzchildnode.north)},
      >=latex, node distance=1.2cm, edge from parent fork down]
      node[root] (A) at (0,2)  {$AX=0$};
      draw[->] (A) to (0,.3);
     node[root] {textbf{Always consistent}} 
      child {node[level-2] (c1) {textbf{rank $A=n$}  textbf{Unique Solution $X=0$}}}
      child {node[level-2,yshift=-6pt] (c1) {textbf{rank $A<n$}  textbf{Infinitely many Solutions  $n-r$ arbitrary parameters in solution}}};
    end{tikzpicture}  
    end{document}

enter image description here

Answered by Roland on July 20, 2021

Edit: added are code for the second tree diagram, definition for math operator ``rank`, a bit improved code.

With use of the forest package is simple:

documentclass[border=10pt, preview]{standalone}
usepackage{mathtools}            % <---
DeclareMathOperator{rank}{rank} % <---
usepackage[edges]{forest}
usetikzlibrary{arrows.meta,
                shadows}

begin{document}
    begin{forest}
for tree = {
% nodes
    draw, semithick,% rounded corners,
    minimum width = 4em, 
if level = 0{fill=orange!30}{fill = teal!30, text width=34mm},
    drop shadow,
    font = sffamilysmalllinespread{0.84}selectfont,
% tree
     grow = south,
   anchor = north,
    forked edge,        % for forked edge
    edge  = {-Stealth},
    s sep = 2mm,    % sibling distance
    l sep = 8mm,    % level distance
 fork sep = 4mm,    % distance from parent to branching point
            }
[$mathbf{AX=0}$,
    [Always consistent
        [{$rank(mathbf{A})=n$}      smallskip
         Unique Solution {$X=0$}]
        [{$rank(mathbf{A})<n$}      smallskip
         Infinitely many Solutions 
         $n-r$ arbitrary parameters 
         in solution]
    ]
]
end{forest}

medskip
    begin{forest}
for tree = {
% nodes
    draw, semithick,% rounded corners,
    minimum width = 4em,
if level = 0{fill=orange!30}{fill = teal!30, text width=34mm},
    drop shadow,
    font = sffamilysmalllinespread{0.84}selectfont,
% tree
     grow = south,
   anchor = north,
    forked edge,        % for forked edge
    edge  = {-Stealth},
    s sep = 2mm,    % sibling distance
    l sep = 8mm,    % level distance
 fork sep = 4mm,    % distance from parent to branching point
            }
[$mathbf{AX=B, B neq 0}$;
    [Consistent:  
     ${rank(mathbf{A})=rank(mathbf{A|B})}$
            [Unique Solution:  
             {$rank(mathbf{A})=n$}]
            [Infinity of Solutions: 
             {$rank(mathbf{A})<n$,}  
             $n-r$ arbitrary parameters in solution]
    ]       
    [Inconsistent:  
     $rank(mathbf{A})<rank(mathbf{A|B})$]
]
    end{forest}
end{document}

enter image description here

Answered by Zarko on July 20, 2021

I am trying to give my own illustration with simple code. The texts rank A on the left and on the right are horizontally aligned.

enter image description here

documentclass[tikz,border=5mm]{standalone}
usepackage{amsmath,amssymb}
begin{document}
begin{tikzpicture}[>=stealth,thick]
defa{3}   
defb{1.8} 
path[nodes={draw,minimum width=4.5cm}]
(0,0) node[fill=yellow!50,minimum height=12mm,align=center] (H) {$mathbf{Ax=0}$[1mm]$mathbf{A}=mtimes n, mleqslant n, mathbf{x}inmathbb{R}^n$}
++(0,-b) node[fill=cyan!50,minimum height=8mm] (H1){Always consistent}
+(a,-1.5*b) node[fill=cyan!50,minimum height=22mm] (H2r){}
+(-a,-1.5*b) node[fill=cyan!50,minimum height=22mm] (H2l){}
;
path 
(H2r.north) node[below=1mm,align=left]{
    Infinitely many Solutions[2mm] 
    $r=text{rank}A<n$
    $n-r$ arbitrary 
    parameters in solutions}
(H2l.north) node[below=1mm,align=left]{
    Unique Solution[2mm] 
    $r=text{rank}A=n$
}
;

draw[->] (H)--(H1); 
draw[->] (H1)--++(0,-1)-|(H2r);
draw[->] (H1)--++(0,-1)-|(H2l);
end{tikzpicture}
end{document}

Answered by Black Mild on July 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP