我没有收到任何编译错误,但我也没有得到我期望的结果,即我的第二个节点显示与我的第一个节点相同的数字集。有人能告诉我我做错了什么吗?我非常感谢任何帮助。
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,fit,positioning}
\let\oldemptyset\emptyset
\let\emptyset\varnothing
\begin{document}
\centering
\begin{tikzpicture}[every node/.style={draw=black},scale=0.75,every
node/.append style={transform shape}]
\begin{scope}[local bounding box=f1,scale=0.5]
\node(one1){1};
\node[below left of=one1]{2};
\node[below right of=one1]{3};
\end{scope}
\node[circle,draw,fit=(f1)](root){};
\begin{scope}[local bounding box=f2,scale=0.5]
\node(one2){1};
\node[below left of=one2]{2};
\node[below right of=one2]{3};
\end{scope}
\node [above right=2cm and -7.5 cm of root,circle,draw,fit=(f2)](11){};
\end{tikzpicture}
\end{document}
答案1
Ascope
只是一种将特殊条件或选项应用于某些命令的方法。因此,您的第二个命令scope
将覆盖第一个命令。但您可以shift
这样做:
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,fit,positioning}
\let\oldemptyset\emptyset
\let\emptyset\varnothing
\begin{document}
\centering
\begin{tikzpicture}[every node/.style={draw=black},scale=0.75,every
node/.append style={transform shape}]
\begin{scope}[local bounding box=f1,scale=0.5]
\node(one1){1};
\node[below left of=one1]{2};
\node[below right of=one1]{3};
\end{scope}
\node[circle,draw,fit=(f1)](root){};
\begin{scope}[local bounding box=f2,scale=0.5, shift={(-7.5cm,2cm)}]
\node(one2){1};
\node[below left of=one2]{2};
\node[below right of=one2]{3};
\end{scope}
\node[circle,draw,fit=(f2)](11){};
\end{tikzpicture}
\end{document}
答案2
如果你改变one2
而不是适应你得到
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,fit,positioning}
\let\oldemptyset\emptyset
\let\emptyset\varnothing
\begin{document}
\centering
\begin{tikzpicture}[every node/.style={draw=black},scale=0.75,every
node/.append style={transform shape}]
\begin{scope}[local bounding box=f1,scale=0.5]
\node(one1){1};
\node[below left of=one1]{2};
\node[below right of=one1]{3};
\end{scope}
\node[circle,draw,fit=(f1)](root){};
\begin{scope}[local bounding box=f2,scale=0.5]
\node[above right=2cm and -7.5 cm of one1](one2){1};
\node[below left of=one2]{2};
\node[below right of=one2]{3};
\end{scope}
\node[circle,draw,fit=(f2)](11){};
\end{tikzpicture}
\end{document}