0

I created a tikz graph. There are still some unwanted lines. I get error messages when I delete them. Any recommendations?

\documentclass[tikz,border=10pt]{standalone}
\usepackage{forest}
\usetikzlibrary{shadows}
\tikzset{every shadow/.style={shadow xshift=5pt,shadow yshift=-5pt}}
\begin{document}
% starting point: https://tex.stackexchange.com/a/341454/121799
\begin{forest}
  for tree={
    font=\sffamily,
    line width=1pt,
    draw,
    child anchor=north,
    parent anchor=south,
    grow=south,
    align=center,
    edge path={
      \noexpand\path[line width=1pt, \forestoption{edge}]
      (!u.parent anchor)  |- ([yshift=4pt].child anchor) -- (.child anchor) \forestoption{edge label};
    },
  },
  s sep+=20pt,
  [Strong Diabatic Heating,drop shadow,
  fill=white
    [Synoptic-Scale\\ Dynamics 
     [Thermodynamic Equation]
     [,phantom]
     [PV Equation]
     [Continuity Equation
          [O(\epsilon^2)]
     [~\\~,opacity=0,name=phantom1
      [~\\~,opacity=0,name=phantom2
      ]
      ]
     [O(\epsilon^3)]
     ]
     [Averaged Horizontal \\ Momentum Equation ]
     [Hydrostatic Balance \\ Equation]
    ]
    [Mesoscale\\ Dynamics
     [Thermodynamic\\ Equation
        [$O(\epsilon^1)$]
        [~\\~,opacity=0,name=phantom3
        [~\\~,opacity=0,name=phantom4]
        ]
        [$O(\epsilon^2)$]
     ]
     [~\\~,opacity=0,name=phantom5
      [~,opacity=0,name=phantom6
      ]
      ]
     [Vorticity\\ Equation]
     [Continuity Equation
        [$O(\epsilon^1)$]
        [~\\~,opacity=0,name=phantom7
        [~\\~,opacity=0,name=phantom8
        ]
        ]
        [$O(\epsilon^2)$]
    ]
    [Hydrostatic Balance \\ Equation]
    [Mesoscale Horizontal \\Divergence Equation]
     ]
   ]
  \begin{scope}[line width=1pt]
   \foreach \X in {1,...,4}
   {\draw (phantom\X.north) -- (phantom\X.south);}
  \end{scope}
\end{forest}
\end{document}

EDIT: This is an example output. The lines belonged to additional boxed. I would like to remove them but I get an error message.

enter image description here

4
  • 1
    Your code gives Missing $ inserted.. You can't use \epsilon in text mode. Make sure all O(\epsilon^n) expressions are between $...$ (it's not the case for the first two).
    – jlab
    Commented May 21 at 13:17
  • @jlab thanks for your comment, I corrected it
    – s28
    Commented May 21 at 13:18
  • Can you describe your desired output? I don't understand what lines you are trying to add with the phantom names. Even a hand-drawn image would help.
    – Sandy G
    Commented May 21 at 13:48
  • @SandyG see edit
    – s28
    Commented May 21 at 13:51

1 Answer 1

2

I'm not sure what the extra draw commands are doing, but here is a start with the unnecessary code removed.

Also, I suggest using the built-in forked edges option (requires the forest library edges.

enter image description here

\documentclass[tikz,border=10pt]{standalone}
\usepackage{forest}
\usetikzlibrary{shadows}
\useforestlibrary{edges}
\tikzset{every shadow/.style={shadow xshift=5pt,shadow yshift=-5pt}}
\begin{document}
% starting point: https://tex.stackexchange.com/a/341454/121799
\begin{forest}
  forked edges,
  for tree={
    font=\sffamily,
    line width=1pt,
    edge={line width=1pt},
    draw,
    %child anchor=north,
    %parent anchor=south,
    %grow=south,
    align=center,
    %edge path={
    %  \noexpand\path[line width=1pt, \forestoption{edge}]
    %  (!u.parent anchor)  |- ([yshift=4pt].child anchor) -- (.child anchor) \forestoption{edge label};
    %},
  },
  s sep+=20pt,
  [Strong Diabatic Heating,drop shadow,
  fill=white
    [Synoptic-Scale\\ Dynamics 
     [Thermodynamic Equation]
     %[,phantom]
     [PV Equation]
     [Continuity Equation
          [$O(\epsilon^2)$]
     %[~\\~,opacity=0,name=phantom1
      %[~\\~,opacity=0,name=phantom2
      %]
      %]
     [$O(\epsilon^3)$]
     ]
     [Averaged Horizontal \\ Momentum Equation ]
     [Hydrostatic Balance \\ Equation]
    ]
    [Mesoscale\\ Dynamics
     [Thermodynamic\\ Equation
        [$O(\epsilon^1)$]
        %[~\\~,opacity=0,name=phantom3
        %[~\\~,opacity=0,name=phantom4]
        %]
        [$O(\epsilon^2)$]
     ]
     %[~\\~,opacity=0,name=phantom5
      %[~,opacity=0,name=phantom6
      %]
      %]
     [Vorticity\\ Equation]
     [Continuity Equation
        [$O(\epsilon^1)$]
        %[~\\~,opacity=0,name=phantom7
        %[~\\~,opacity=0,name=phantom8
        %]
        %]
        [$O(\epsilon^2)$]
    ]
    [Hydrostatic Balance \\ Equation]
    [Mesoscale Horizontal \\Divergence Equation]
     ]
   ]
  %\begin{scope}[line width=1pt]
   %\foreach \X in {1,...,4}
   %{\draw (phantom\X.north) -- (phantom\X.south);}
  %\end{scope}
\end{forest}
\end{document}
1
  • thank you very much!
    – s28
    Commented May 21 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .