0

I need to plot something like this Tikz picture

So far I have been able to plot using the codes below. I could not find a way to include a vertical tree

\begin{tikzpicture}[
every node/.style = {draw,rounded corners,fill=red!30,text width=18mm,minimum height=9mm,align=center,drop shadow},
>=Stealth,level distance = 30mm,sibling distance=13mm]

\begin{scope}[grow'=right,edge from parent fork right,->]
\node (root) at (0,0) {}
child  {node (b1) {B}};
\end{scope}
\begin{scope}[grow=left,edge from parent fork left,->]
\node (root) at (0,0) {Loschmidt Echo}
child  {node (a1) {C}};
\end{scope}            
\end{tikzpicture}

2 Answers 2

1

To add arrows:

  • use library arrows.meta
  • define a drawing style, e.g. arr
  • use for formatting connections

Please find more details in the tikz manuals, e.g. in the minimal introduction, ch. 3.3: https://ctan.org/pkg .

with arrows

\documentclass[10pt, border=3mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning, arrows.meta}% <<<

\begin{document}
  \tikz [draw, 
         box/.style = 
         { 
           fill=red!30,
           minimum width=18mm,       
         },
         rnd/.style =
         { 
           rounded corners,
           fill=red!30,
           minimum width=18mm,       
         },
         arr/.style={->, >=Latex}% <<<
        ] {
    \node [box] (root) at (0,0) {C (root)};
    \node [rnd] (D) [below=of root] {D};
    \node [box] (A) [right=of root] {A};
    
    \draw [arr] (root) -- (D);% <<<
    \draw [arr] (root) -- (A);
  }
\end{document}
1

Try something more simple, e.g. like this, which is only one way to do it. And please ... provide complete code.

Changes I introduced:

  • abandoned the child&sibling idea
  • defined node-styles as needed
  • used relative positioning

example

\documentclass[10pt, border=3mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
  \tikz [draw, 
         box/.style = 
         { 
           fill=red!30,
           minimum width=18mm,       
         },
         rnd/.style =
         { 
           rounded corners,
           fill=red!30,
           minimum width=18mm,       
         }       
        ] {
    \node [box] (root) at (0,0) {C (root)};
    \node [rnd] (D) [below=of root] {D};
    \node [box] (A) [right=of root] {A};
    
    \draw (root) -- (D);
    \draw (root) -- (A);
  }
\end{document}
1
  • It works. Thank you @MS-SPO ... Can you suggest how can I use arrows instead of lines to join the boxes?
    – user84456
    Jul 3 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.