LaTeX forum ⇒ Graphics, Figures & TablesMultibranched tree in TikZ with arrows[solved] Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
Turbomichi
Posts: 2
Joined: Wed Jul 12, 2017 12:56 pm

Multibranched tree in TikZ with arrows[solved]  Topic is solved

Postby Turbomichi » Wed Jul 12, 2017 1:42 pm

Hello people,

I want to create a tree in TikZ with more than two branches.
With the code below I get the first shown image, but I need a tree as shown
in the second picture. The arrow positions should not given in explicit coordinates, but
relative to the boxes. The arrows should all start on the same point and end on top of the boxes in the middle.

Thank you for your help


  1. \documentclass[border=10pt]{standalone}
  2. \usepackage{tikz}
  3. \usepackage{nicefrac}
  4. \usepackage{amssymb}
  5. \usetikzlibrary{positioning,arrows,automata,calc,shapes}
  6. \begin{document}
  7. \newcommand{\Symmetry}[3]
  8. {
  9. \begin{minipage}{1.5cm}
  10. \centering
  11. {{#1}}%
  12. \linebreak
  13. {{#2}}%
  14. \linebreak
  15. {{#3}}%
  16. \end{minipage}
  17. }
  18.  
  19. \newcommand{\Wyckoff}[3]
  20. {
  21. \begin{minipage}{1.5cm}
  22. \centering
  23. {{#1}}%
  24. \linebreak
  25. {{#2}}%
  26. \linebreak
  27. {{#3}}%
  28. \end{minipage}
  29. }
  30.  
  31.  
  32.  
  33. \begin{tikzpicture}[->,>=stealth',shorten >=1pt,node distance=3.0cm]
  34. %% Fill Color Styles
  35. \tikzstyle{ElementFill} = [fill=yellow!15]
  36.  
  37.  
  38. %% Element Styles
  39. \tikzstyle{Element} = [draw=black, ElementFill, minimum width=1.75cm, minimum height=1.75cm, node distance=1.75cm]
  40. \tikzstyle{every state}=[fill=white,draw=black,text=black,minimum size=45pt]
  41.  
  42. \node[name=Na11, Element] {\Symmetry{Na:}{1\textit{a}}{$\bar{3}$\textit{m}}};
  43. \node[name=KoNa11, below of=Na11, Element] {\Wyckoff{0}{0}{0}} ;
  44. \node[name=Na12, below=2cm of KoNa11, Element] {\Symmetry{Na:}{2\textit{a}}{2/\textit{m}}};
  45. \node[name=KoNa12, below of=Na12, Element] {\Wyckoff{0}{0}{0}} ;
  46. \node[name=Na13, below=2cm of KoNa12, Element] {\Symmetry{Na1:}{4\textit{g}}{2}};
  47. \node[name=KoNa13, below of=Na13, Element] {\Wyckoff{0}{0.1578}{0}};
  48. \node[name=Na14, right of=Na13, Element] {\Symmetry{$\Box$:}{2\textit{a}}{2/\textit{m}}};
  49. \node[name=KoNa14, below of=Na14, Element] {\Wyckoff{0}{0}{0}};
  50. \node[name=Na21, right of=Na14, Element] {\Symmetry{$\Box$:}{2\textit{a}}{2/\textit{m}}};
  51. \node[name=KoNa21, below of=Na21, Element] {\Wyckoff{0}{0}{0}};
  52. \node[name=Na22, right of=Na21, Element] {\Symmetry{$\Box$:}{2\textit{a}}{2/\textit{m}}};
  53. \node[name=KoNa22, below of=Na22, Element] {\Wyckoff{0}{0}{0}};
  54. \node[name=Na23, right of=Na22, Element] {\Symmetry{$\Box$:}{2\textit{a}}{2/\textit{m}}};
  55. \node[name=KoNa23, below of=Na23, Element] {\Wyckoff{0}{0}{0}};
  56.  
  57.  
  58.  
  59. \node[name=Mn, right of=Na11, Element] {\Symmetry{Mn:}{2\textit{d}}{3\textit{m}}};
  60. \node[name=KoMn, below of=Mn, Element] {\Wyckoff{\nicefrac{1}{3}}{\nicefrac{2}{3}}{0.6247}};
  61. \node[name=Te, right of=Mn, Element] {\Symmetry{Te:}{2\textit{d}}{3\textit{m}}};
  62. \node[name=KoTe, below of=Te, Element] {\Wyckoff{\nicefrac{1}{3}}{\nicefrac{2}{3}}{0.2571}};
  63.  
  64. \draw[->, blue!50, very thick] (KoNa11) to (Na12);
  65. \draw[->, blue!50, very thick] (KoNa12) to (Na13);
  66. \draw[->, blue!50, very thick] (KoNa12) to (Na14);
  67. \draw[->, blue!50, very thick] (KoNa12) to (Na21);
  68. \draw[->, blue!50, very thick] (KoNa12) to (Na22);
  69. \draw[->, blue!50, very thick] (KoNa12) to (Na23);
  70.  
  71. \end{tikzpicture}
  72. \end{document}
  73.  


tree.png
tree.png (4.53 KiB) Viewed 842 times

tree3.png
tree3.png (4.63 KiB) Viewed 842 times



[solved]
Adding ".south"/".north" to the node names.
"north east" resp. "south west" etc. works too.

\draw[->, blue!50, very thick] (KoNa11) to (Na12);
\draw[->, blue!50, very thick] (KoNa12) to (Na13);
\draw[->, blue!50, very thick] (KoNa12.south) to (Na14.north);
\draw[->, blue!50, very thick] (KoNa12.south) to (Na21.north);
\draw[->, blue!50, very thick] (KoNa12.south) to (Na22.north);
\draw[->, blue!50, very thick] (KoNa12.south) to (Na23.north);

Tags:

User avatar
Stefan Kottwitz
Site Admin
Posts: 8980
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Thu Jul 13, 2017 8:13 pm

Welcome to the forum!

Great to read that you could already solve it! Maybe I can help with the next TikZ question later on.

Just by the way, there's a new syntax now as replacement for \tikzstyle:

  1. %% Fill Color Styles
  2. \tikzset{
  3. ElementFill/.style = {fill = yellow!15},
  4. Element/.style = {draw=black, ElementFill, minimum width=1.75cm,
  5. minimum height=1.75cm, node distance=1.75cm},
  6. every state/.style = {fill=white, draw=black, text=black, minimum size=45pt}
  7. }


It can also be used as argument to the tikzpicture environment:

  1. \begin{tikzpicture}[->, >=stealth', shorten >=1pt, node distance=3.0cm,
  2. %% Fill Color Styles
  3. ElementFill/.style = {fill = yellow!15},
  4. Element/.style = {draw=black, ElementFill, minimum width=1.75cm,
  5. minimum height=1.75cm, node distance=1.75cm},
  6. every state/.style = {fill=white, draw=black, text=black, minimum size=45pt}
  7. ]
  8. \node ...


Stefan
Site admin

Turbomichi
Posts: 2
Joined: Wed Jul 12, 2017 12:56 pm

Postby Turbomichi » Mon Jul 17, 2017 2:26 pm

Hi Stefan,

thank you for the information. I will try it.

Greetz Turbomichi


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 8 guests