1

I don't get any error for the compiling, but I don't get what I expected either, which was for my second node to show up with the same set of numbers as my first node. Can someone please let me know what is it that I am doing wrong for this problem? I appreciate any help given.

\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}

enter image description here

1
  • 1
    Shoudn't you shift the node one2 instead of the fit?
    – user121799
    Commented Mar 27, 2019 at 20:36

2 Answers 2

2

A scope is just a way to apply special conditions or options to certain commands. Therefore, your second scope is drawn over the first one. But you can shift it:

\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}

enter image description here

2

If you shift one2 instead of the fit you get

\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}

enter image description here

You must log in to answer this question.

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