1

I would like to:

(A) rotate the tikz figure

(B) add equations below the figure (rotated)

How could I do that? I drew a sketch:

enter image description here

CODE:

\documentclass{article}

\usepackage{forest}
\usetikzlibrary{shadows}
\useforestlibrary{edges}
\tikzset{every shadow/.style={shadow xshift=5pt,shadow yshift=-5pt}}


\begin{document}

\begin{forest}
  forked edges,
  for tree={
    font=\sffamily,
    line width=1pt,
    edge={line width=1pt},
    draw,
    align=center,
  },
  s sep+=20pt,
  [Strong Diabatic Heating,drop shadow,
  fill=white
    [Synoptic-Scale\\ Dynamics 
     [Thermodynamic Equation
     [(1)]
     ]
     [PV Equation
     [(2)]
     ]
     [Continuity Equation
          [(3)]
     [(4)]
     ]
     [Horizontal Momentum \\ Equation
     [(5)]
     ]
     [Hydrostatic Balance \\ Equation
     [(6)]
     ]
    ]
    [Mesoscale\\ Dynamics
     [Thermodynamic\\ Equation
        [(7)]
        [(8)]
     ]
     [Vorticity\\ Equation
     [(9)]
     ]
     [Continuity Equation
        [(10)]
        [(11)]
    ]
    [Hydrostatic Balance \\ Equation
    [(12)]
    ]
    [Mesoscale Horizontal \\Divergence Equation
    [(13)]
    ]
     ]
   ]
\end{forest}
\end{document}
2
  • Welcome. // How does your sketch relate to the tree your code draws?
    – MS-SPO
    Commented May 21 at 18:42
  • Even if you turn it, there is not sufficient space on a standard article page.
    – cfr
    Commented May 21 at 20:12

2 Answers 2

4

You can turn the tree using a sidewaysfigure from the rotating package, but it still won't fit on your page. Very likely you have more \textheight than the default article - even if you are in one of the few places which eschews ISO sizes, the default margins are so great you are probably reducing them - but unless you are using A3 or (possibly?) US legal, this isn't going to fit.

So you have to do something else. I experimented with splitting the text in more nodes and you could also make the font size smaller or reduce the padding in or between the nodes, but it isn't going to look good.

Moreover, I don't know if this is important or not, but you have nodes with the same names in two branches of the tree. Maybe that's just for the minimal example, but I'm guessing your tree has at least rough symmetry geometrically between the two, even if the node content is actually different.

[If it isn't just for the example, is there a reason 'Hydrostatic Balance Equation' is the last child in one branch and the last but one in the other?]

I suggest you make better use of both dimensions by switching style for the subtrees rooted in root's grandchildren. The edges library provides a folder style, though the specific style below took me an embarrassingly long time to get right.

  • forking tree is just shorthand for the style you were using;
  • major is a style which sets the shadow etc. for the root and adjusts the placement;
  • folders down switches to the folder style, which doesn't respond well to styling subtrees without a bit of fiddling;
    • where level=1{folders down}{} applies this to root's children i.e. level 1 in forest terms (the root level being 0)
  • align grandchild folders aligns all the nth grandchildren of the root node (but it would be easy to tweak it to work from some non-root node).

My images suck due to an Okular bug, but I'm hoping this one may be a bit better.

forked tree with switch to folder style and aligned grandchildren

\documentclass{article}
\usepackage{mathtools}
\usepackage{forest}
\usetikzlibrary{shadows}
\useforestlibrary{edges}
\tikzset{every shadow/.style={shadow xshift=5pt,shadow yshift=-5pt}}
% ateb: https://tex.stackexchange.com/a/718524/ addaswyd o gwestiwn s28: https://tex.stackexchange.com/q/718466/
\forestset{% addaswyd o ateb: https://tex.stackexchange.com/a/690629/
  folders down/.style={
    for tree={
      grow'=0,
      folder,
    },
    for current and siblings={anchor=north west, child anchor=north},
  },
  forking tree/.style={
    calign=edge midpoint,
    for tree={
      fit=band,
      font=\sffamily,
      line width=1pt,
      edge+={line width=1pt},
      draw,
      align=center,   
    },
    forked edges,
  },
  major/.style={%
    drop shadow,
    for children={fork sep'=2ex},
  },
  define long step={grandchildren}{}{sort by=n,sort={branch={children,children}}},
  define long step={grandchildren at n}{n args=1}{%
    filter={grandchildren}{>On={n}{#1}}%
  },
  align grandchild folders/.style={%
    before computing xy={%
      if={ > On> {n children}{1} } {
        tempcounta/.max={>O{n}}{grandchildren},
        tempcountb'=0,
        for nodewalk={%
          fake=first,
          while={ >OR< {n children}{tempcounta}  }{fake=next},
          children
        }{%
          tempcountb/.option=n,
          tempdima/.min={ > O{s} }{fake=parent,fake=parent,grandchildren at n/.register=tempcountb},
          for nodewalk={%
            fake=parent,fake=parent,grandchildren at n/.register=tempcountb
          }{s/.register=tempdima}
        },
      }{},
    },
  },
}
\begin{document}
\pagestyle{empty}%
\begin{forest}
  forking tree,
  where level=1{folders down}{},
  align grandchild folders,
  [Strong Diabatic Heating, major,
  fill=white
    [Synoptic-Scale  Dynamics 
      [Thermodynamic  Equation
        [(1)]
      ]
      [PV  Equation
        [(2)]
      ]
      [Continuity  Equation
        [(3)]
        [(4)]
      ]
      [Horizontal Momentum   Equation
        [(5)]
      ]
      [Hydrostatic Balance   Equation
        [(6)]
      ]
    ]
    [Mesoscale  Dynamics
      [Thermodynamic  Equation
          [(7)]
          [(8)]
      ]
      [Vorticity  Equation
        [(9)]
      ]
      [Continuity  Equation
          [(10)]
          [(11)]
      ]
      [Hydrostatic Balance   Equation
      [(12)]
      ]
      [Mesoscale Horizontal  Divergence Equation
        [(13)]
      ]
    ]
  ]
\end{forest}
\begin{align}
  i^2 &= -1 \label{eqn:i}\\
  \sqrt{1} &= \pm 1 \label{eqn:1}\\
  v &= ut + \frac{1}{2}at^2 \label{eqn:v}\\
  \sin^2\theta + \cos^2\theta &= 1 \label{eqn:theta}\\
  \text{??} &= 42 \label{eqn:h2g2}
\end{align}
\end{document}

EDIT

Here are a couple of other possibilities which don't involve restructuring your tree. I use \small from your duplicate question and also assume you are using A4, since the tree is too wide otherwise, even rotated.

The first option puts both tree and equations in a float. You might use \caption with this. The second simply puts them in an environment which is turned. Both use the rotating package mentioned above.

\documentclass[a4paper]{article}
\usepackage{forest}
\usetikzlibrary{shadows}
\useforestlibrary{edges}
\usepackage{amsmath}
\usepackage{rotating}
\usepackage[left=2.5cm,right=1cm,top=1.25cm,bottom=2cm]{geometry}
\tikzset{every shadow/.style={shadow xshift=5pt,shadow yshift=-5pt}}

\begin{document}

\begin{sidewaysfigure}
  \centering
  \begin{forest}
    forked edges,
    for tree={
      font=\small\sffamily,
      line width=1pt,
      edge+={line width=1pt},
      draw,
      align=left,
      tier/.option=level,
    },
    s sep'+=20pt,
    [Strong Diabatic Heating,drop shadow,
    fill=white
      [Synoptic-Scale Dynamics 
      [Thermodynamic \\ Equation
      [(1)]
      ]
      [PV Equation
      [(2)]
      ]
      [Continuity \\ Equation
            [(3)]
      [(4)]
      ]
      [Hor. Momentum \\ Equation
      [(5)]
      ]
      [Hydrostatic Balance \\ Equation
      [(6)]
      ]
      ]
      [Mesoscale Dynamics
      [Thermodynamic\\ Equation
          [(7)]
          [(8)]
      ]
      [Vorticity\\ Equation
      [(9)]
      ]
      [Continuity \\ Equation
          [(10)]
          [(11)]
      ]
      [Hydrostatic Balance \\ Equation
      [(12)]
      ]
      [Mesoscale Horizontal \\Divergence Equation
      [(13)]
      ]
      ]
    ]
  \end{forest}
  
  \begin{align}
    i^2 &= -1 \label{eqn:ai}\\
    \sqrt{1} &= \pm 1 \label{eqn:a1}\\
    v &= ut + \frac{1}{2}at^2 \label{eqn:av}\\
    \sin^2\theta + \cos^2\theta &= 1 \label{eqn:atheta}\\
    \text{??} &= 42 \label{eqn:ah2g2}
  \end{align}
\end{sidewaysfigure}

\begin{sideways}
  \parbox{\textheight}{%
  \centering
  \begin{forest}
    forked edges,
    for tree={
      font=\small\sffamily,
      line width=1pt,
      edge+={line width=1pt},
      draw,
      align=left,
      tier/.option=level,
    },
    s sep'+=20pt,
    [Strong Diabatic Heating,drop shadow,
    fill=white
      [Synoptic-Scale Dynamics 
      [Thermodynamic \\ Equation
      [(1)]
      ]
      [PV Equation
      [(2)]
      ]
      [Continuity \\ Equation
            [(3)]
      [(4)]
      ]
      [Hor. Momentum \\ Equation
      [(5)]
      ]
      [Hydrostatic Balance \\ Equation
      [(6)]
      ]
      ]
      [Mesoscale Dynamics
      [Thermodynamic\\ Equation
          [(7)]
          [(8)]
      ]
      [Vorticity\\ Equation
      [(9)]
      ]
      [Continuity \\ Equation
          [(10)]
          [(11)]
      ]
      [Hydrostatic Balance \\ Equation
      [(12)]
      ]
      [Mesoscale Horizontal \\Divergence Equation
      [(13)]
      ]
      ]
    ]
  \end{forest}
  
  \begin{align}
    i^2 &= -1 \label{eqn:i}\\
    \sqrt{1} &= \pm 1 \label{eqn:1}\\
    v &= ut + \frac{1}{2}at^2 \label{eqn:v}\\
    \sin^2\theta + \cos^2\theta &= 1 \label{eqn:theta}\\
    \text{??} &= 42 \label{eqn:h2g2}
  \end{align}}
\end{sideways}

\end{document}
3

Too long for a comment. This is not exactly what you asked for, but here's is a suggestion for an alternate format that you may prefer to help the tree fit on one page. Then you don't have to do anything special with your equations.

enter image description here

\documentclass{article}

\usepackage{forest, amsmath}
\usetikzlibrary{shadows}
\useforestlibrary{edges}
\tikzset{every shadow/.style={shadow xshift=5pt,shadow yshift=-5pt}}


\begin{document}

\begin{forest}
  forked edges,
  for tree={
    grow'=east,
    tier/.pgfmath=level(),
    anchor=center,
    font=\sffamily,
    line width=1pt,
    edge={line width=1pt},
    draw,
    align=center,
  },
  s sep+=20pt,
  [Strong\\Diabatic\\Heating,drop shadow,
  fill=white
    [Synoptic-Scale\\Dynamics 
     [Thermodynamic\\Equation
     [(1)]
     ]
     [PV Equation
     [(2)]
     ]
     [Continuity Equation
          [(3)]
     [(4)]
     ]
     [Horizontal Momentum\\Equation
     [(5)]
     ]
     [Hydrostatic Balance\\Equation
     [(6)]
     ]
    ]
    [Mesoscale\\Dynamics
     [Thermodynamic\\Equation
        [(7)]
        [(8)]
     ]
     [Vorticity Equation
     [(9)]
     ]
     [Continuity Equation
        [(10)]
        [(11)]
    ]
    [Hydrostatic Balance \\ Equation
    [(12)]
    ]
    [Mesoscale Horizontal \\Divergence Equation
    [(13)]
    ]
     ]
   ]
\end{forest}

Here are some equations.
\begin{align*}
1+1&=2\\
2+2&=4\\
4+4&=8
\end{align*}
\end{document}
1
  • Absolutely need something not requested: what's asked for needs too much virtual paper. Or a very small font. Personally, I'd probably align the grandchildren by their child anchors, but that admittedly has disadvantages for the leaves. I'm never sure whether folder style is worth the hassle, but it does avoid that issue.
    – cfr
    Commented May 22 at 2:43

You must log in to answer this question.

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