I am definitely unfamiliar with both beamer
and tikz
(do not quite get what the \only
are supposed to do) but perhaps this could go in the direction you want:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{chains}
\newcounter{count}
% helper macro:
\long\def\GobToSemiColon #1;{}
\newcommand\myPicture{
\begin{tikzpicture}
\begin{scope}[start chain = going below]
\ifnum\value{count}<1 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>3 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only when counter is between
1 and 3};
\ifnum\value{count}>-1 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only when counter is
negative};
\ifnum\value{count}<100 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>200 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only if counter is between
100 and 200};
\ifnum\value{count}<3 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>20 \expandafter\GobToSemiColon\fi
\node[draw, circle, on chain] {only when counter is in the range 3 to 20};
\end{scope}
\end{tikzpicture}
}
\begin{document}
\begin{frame}
\only{\setcounter{count}{-3}\myPicture}
\only{\setcounter{count}{105}\myPicture}
\only{\setcounter{count}{39}\myPicture}
\only{\setcounter{count}{2}\myPicture}
\only{\setcounter{count}{5}\myPicture}
\end{frame}
\end{document}
![beamer](https://i.stack.imgur.com/h1oev.png)
Setting the trees to use 12pt
font means they take more space than default. (Standard classes default to 10pt
. standalone
, which is often used to create graphics, defaults to 11pt
.)
Here is a forest
version with no adjustments:
\documentclass[12pt,tikz]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
[{$b$}, name=z
[{$b_1$}, name=a
[{$b_1 \, b_1$}, name=b
[{$b_1 \, b_1 \, b_1$}
]
[{$b_1 \, b_1 \, b_2$}
]
]
[{$b_1 \, b_2$}, name=g
[{$b_1b_2E[b_1]$}
]
[{$b_1b_2E[b_2]$}
]
]
]
[{$b_2$}, name=j
[{$b_2 \, E[b_1]$}, name=k
[{$b_2 E[b_1b_1]$}
]
[{$b_2 E[b_1b_2]$}
]
]
[{$b_2 \, E[b_2]$}, name=l
[{$b_2E[b_2]E[b_1]$}
]
[{$b_2E[b_2]E[b_2]$}, name=c
]
]
]
]
\path (a) -- (j) ;
\path (b) -- (g) ;
\path (k) -- (l) ;
\path (k) -- (g) ;
\end{forest}
\end{document}
![forest version](https://i.stack.imgur.com/QEotw.png)
At 172x42mm, this fits within A4 but not at all comfortably unless you rotate the tree.
So let's try a version which incorporates your suggested change:
\documentclass[12pt,tikz]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
[{$b$}, name=z
[{$b_1$}, name=a
[{$b_1 \, b_1$}, name=b
[{$b_1 \, b_1 \, b_1$}
]
[{$b_1 \, b_1 \, b_2$}
]
]
[{$b_1 \, b_2$}, name=g, for children={l+=2\baselineskip}
[{$b_1b_2E[b_1]$}
]
[{$b_1b_2E[b_2]$}
]
]
]
[{$b_2$}, name=j
[{$b_2 \, E[b_1]$}, name=k
[{$b_2 E[b_1b_1]$}
]
[{$b_2 E[b_1b_2]$}
]
]
[{$b_2 \, E[b_2]$}, name=l, for children={l+=2\baselineskip}
[{$b_2E[b_2]E[b_1]$}
]
[{$b_2E[b_2]E[b_2]$}, name=c
]
]
]
]
\path (a) -- (j) ;
\path (b) -- (g) ;
\path (k) -- (l) ;
\path (k) -- (g) ;
\end{forest}
\end{document}
![adjusted tree](https://i.stack.imgur.com/NJoch.png)
The adjusted tree measures 131x52mm which is well within A4.
Best Answer
You have too much empty lines in your code. Empty lines cause paragraph breaks. Remove at least the empty lines after
author
and after beginning the matrix. Better more.It's not produced correctly, because you forgot to specify node size, column sep and row sep.
This works correctly: