我想告诉 tikz 制作一个图像,使其足够宽,以便正确绘制,然后将其缩放到\textwidth
例如
\documentclass{article}
\usepackage{amsmath}
\usepackage[usenames]{color}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary {positioning,arrows.meta,graphs,shapes.misc}
\begin{document}
\newcommand{\z}[4]{
\begin{minipage}{2cm}
\begin{align*}
Z\{&ini&=\\
&it&=\\
&coit&=\\
&curs&=\}
\end{align*}
\end{minipage}
}
\begin{tikzpicture}[
grow=right,
edge from parent/.style={sloped,above,draw},
level distance=7cm,
sibling distance=4cm]
\node {\z{p1,p2,p3}{\O}{\O}{p_0}}
child {
node {\z{p2,p3}{p_0}{\O}{p_1}}
child {
edge from parent node {pop init}
node {\z{p_3}{p_1,p_0}{\O}{p_2}}
}
edge from parent node {pop init}
}
child {
node {\z{p2,p3}{p_0'}{\O}{p_1}}
edge from parent node {pop it}
};
\end{tikzpicture}
\end{document}
看起来 tikz 空间不足了
答案1
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\newcommand{\z}[4]{
\begin{minipage}{2cm}
\begin{align*}
Z\{&ini&=\\
&it&=\\
&coit&=\\
&curs&=\}
\end{align*}
\end{minipage}
}
\resizebox{\textwidth}{!}{%
\begin{tikzpicture}[
grow=right,
edge from parent/.style={sloped,above,draw},
level distance=7cm,
sibling distance=4cm,
]
\node {\z{p1,p2,p3}{\O}{\O}{p_0}}
child {
node {\z{p2,p3}{p_0}{\O}{p_1}}
child {
node {\z{p_3}{p_1,p_0}{\O}{p_2}}
edge from parent node {pop init}
}
edge from parent node {pop init}
}
child {
node {\z{p2,p3}{p_0'}{\O}{p_1}}
edge from parent node {pop it}
};
\end{tikzpicture}}
\end{document}