
Я хотел бы изменить код здесь:
http://www.texample.net/tikz/examples/scenario-tree/
чтобы поместить его на страницу Beamer. Код работает на обычной странице статьи, но дерево слишком большое для слайда Beamer.. что мне изменить в коде, чтобы дерево поместилось на одном слайде?
Большое спасибо за вашу помощь!
решение1
Если вас не смущает scale
оригинальное дерево, у вас есть два простых решения.
Первое: использованиеstandalone
класс для создания обрезанного дерева, которое будет включено в презентацию вашего проектора с помощью \includegraphics
команды.
Измените minimal
класс с помощью standalone
pdflatex. Больше ничего менять не нужно.
% Scenario tree
% Author: Rasmus Pank Roulund
% \documentclass{minimal}
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{amsmath}
\usepackage{xspace}
\newcommand{\A}{\ensuremath{\mathcal{A}}\xspace}
\newcommand{\B}{\ensuremath{\mathcal{B}}\xspace}
\newcommand\pa[1]{\ensuremath{\left(#1\right)}}
\begin{document}
\begin{tikzpicture}[
grow=right,
level 1/.style={sibling distance=3.5cm,level distance=5.2cm},
level 2/.style={sibling distance=3.5cm, level distance=6.7cm},
edge from parent/.style={very thick,draw=blue!40!black!60,
shorten >=5pt, shorten <=5pt},
edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)},
kant/.style={text width=2cm, text centered, sloped},
every node/.style={text ragged, inner sep=2mm},
punkt/.style={rectangle, rounded corners, shade, top color=white,
bottom color=blue!50!black!20, draw=blue!40!black!60, very
thick }
]
\node[punkt, text width=5.5em] {Country~\B}
%Lower part lv1
child {
node[punkt] [rectangle split, rectangle split, rectangle split parts=3,
text ragged] {
\textbf{Scenario 1}
\nodepart{second}
$\text{Country \B}\colon s\bar{Q}$
\nodepart{third}
$\text{Country \A}\colon\pa{1-s}\bar{Q}$
}
edge from parent
node[kant, below, pos=.6] {Unchanged parity}
}
%Upper part, lv1
child {
node[punkt, text width=6em] {Country~\A}
%child 1
child {
node [punkt,rectangle split, rectangle split,
rectangle split parts=3] {
\textbf{Scenario 2}
\nodepart{second}
$\text{Country \B}\colon s\bar{Q}+2\alpha\Delta E -sc$
\nodepart{third}
$\text{Country \A}\colon\pa{1-s}\bar{Q}-\alpha\Delta E -
\pa{1-s}c$
}
edge from parent
node[below, kant, pos=.6] {Unchanged parity}
}
%child 2
child {
node [punkt, rectangle split, rectangle split parts=3]{
\textbf{Scenario 3}
\nodepart{second}
$\text{Country \B}\colon s\bar{Q}-2sc$
\nodepart{third}
$\text{Country \A}\colon\pa{1-s}\bar{Q}-2\pa{1-s}c$
}
edge from parent
node[kant, above] {Devalues}}
edge from parent{
node[kant, above] {Devalues}}
};
\end{tikzpicture}
\end{document}
Теперь включите это в свою презентацию.
\documentclass{beamer}
\begin{document}
\begin{frame}{Probability tree}
{\par\centering
% 106998 is the name I've used for probability tree figure.
\includegraphics[width=\linewidth]{106998}
\par}
\end{frame}
\end{document}
Результат:
Во-вторых: включите Tikz
код в презентацию вашего проектора, но измените его размер с помощью \resizebox
команды:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{amsmath}
\usepackage{xspace}
\newcommand{\A}{\ensuremath{\mathcal{A}}\xspace}
\newcommand{\B}{\ensuremath{\mathcal{B}}\xspace}
\newcommand\pa[1]{\ensuremath{\left(#1\right)}}
\begin{document}
\begin{frame}{Probability tree}
{\par\centering\resizebox{\linewidth}{!}{%
\begin{tikzpicture}[
grow=right,
level 1/.style={sibling distance=3.5cm,level distance=5.2cm},
level 2/.style={sibling distance=3.5cm, level distance=6.7cm},
edge from parent/.style={very thick,draw=blue!40!black!60,
shorten >=5pt, shorten <=5pt},
edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)},
kant/.style={text width=2cm, text centered, sloped},
every node/.style={text ragged, inner sep=2mm},
punkt/.style={rectangle, rounded corners, shade, top color=white,
bottom color=blue!50!black!20, draw=blue!40!black!60, very
thick }
]
\node[punkt, text width=5.5em] {Country~\B}
%Lower part lv1
child {
node[punkt] [rectangle split, rectangle split, rectangle split parts=3,
text ragged] {
\textbf{Scenario 1}
\nodepart{second}
$\text{Country \B}\colon s\bar{Q}$
\nodepart{third}
$\text{Country \A}\colon\pa{1-s}\bar{Q}$
}
edge from parent
node[kant, below, pos=.6] {Unchanged parity}
}
%Upper part, lv1
child {
node[punkt, text width=6em] {Country~\A}
%child 1
child {
node [punkt,rectangle split, rectangle split,
rectangle split parts=3] {
\textbf{Scenario 2}
\nodepart{second}
$\text{Country \B}\colon s\bar{Q}+2\alpha\Delta E -sc$
\nodepart{third}
$\text{Country \A}\colon\pa{1-s}\bar{Q}-\alpha\Delta E -
\pa{1-s}c$
}
edge from parent
node[below, kant, pos=.6] {Unchanged parity}
}
%child 2
child {
node [punkt, rectangle split, rectangle split parts=3]{
\textbf{Scenario 3}
\nodepart{second}
$\text{Country \B}\colon s\bar{Q}-2sc$
\nodepart{third}
$\text{Country \A}\colon\pa{1-s}\bar{Q}-2\pa{1-s}c$
}
edge from parent
node[kant, above] {Devalues}}
edge from parent{
node[kant, above] {Devalues}}
};
\end{tikzpicture}}
\par}
\end{frame}
\end{document}
Третий вариант — изменить дерево, чтобы оно вписывалось в слайды бимера, но это не так просто. Вот несколько идей для изучения: заставить его расти вниз, изменить размер шрифта, ...