[Tex/LaTex] Rectangle fitting some text and scaled circuit from circuitikz

circuitikzfittikz-pgf

I am trying to draw a rectangle with some text on the left and with an electrical schema on the right (all inside one rectangle)
I am using following packages:

\usepackage{circuitikz}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,shapes}

The scheme I want to place into the rectangle is something like this:

\documentclass[12pt,oneside,a4paper]{article}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}

\usepackage{circuitikz}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,shapes}

\begin{document}

\begin{circuitikz} [ european resistors ]
\draw[help lines, dotted] (-5,-5) grid (10,6); 


% \scalebox{0.6}{
\draw (4, 2) 
to [vR, *-*]  ++(-2,-2)
to node (l1) {} ++(0,0)
to [vR, *-*] ++(2,-2)
to [short, -o] ++(0, -1)
to node (b1) {} ++(0,0)
to [short] ++(0, 1)
to [vR, *-*]  ++(2,2)
to node (r1) {} ++(0,0)
to [vR, *-*]    ++(-2,2)
to [short,-o]   +(0, 1)
to node (t1) {} ++(0,0)
; 
% }
\node[fit=(t1) (b1) (l1) (r1), draw, black, rectangle, inner sep=10pt]{};


\end{circuitikz}

\end{document}

enter image description here

But when I try to scale it with some factor (0.6) it accidentally scales nodes, but doesn't do the same with the outer rectangle.

\documentclass[12pt,oneside,a4paper]{article}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}

\usepackage{circuitikz}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,shapes}

\begin{document}

\begin{circuitikz} [ european resistors ]
\draw[help lines, dotted] (-5,-5) grid (10,6); 


\scalebox{0.6}{
\draw (4, 2) 
to [vR, *-*]  ++(-2,-2)
to node (l1) {} ++(0,0)
to [vR, *-*] ++(2,-2)
to [short, -o] ++(0, -1)
to node (b1) {} ++(0,0)
to [short] ++(0, 1)
to [vR, *-*]  ++(2,2)
to node (r1) {} ++(0,0)
to [vR, *-*]    ++(-2,2)
to [short,-o]   +(0, 1)
to node (t1) {} ++(0,0)
; 
}
\node[fit=(t1) (b1) (l1) (r1), draw, black, rectangle, inner sep=10pt]{};

\end{circuitikz}

\end{document}

enter image description here

I really have no idea how to put text inside this pseudo-fitting rectangle.

I am relatively new to the world of tikz, so please give me advice on how to accomplish my task: to place text with scaled scheme inside?

To compound the problem, I need to draw several boxes (with text and scaled schemas) like the above. So, I will be very disappointed if there is not some convenient method of grouping blocks of nodes (and connections between them) as a single node, and then being able to use it further (as a sort of a variable) in other connections.

Best Answer

I think the code below does what you're after. Note first that I've removed the \scalebox, and instead I've added transform shape,scale=0.6 as options to the \draw creating the circuit. The first of those is needed because the components are created as nodes, and these are not affected by scale unless you add transform shape. If you don't want the components to be scaled, just the distances between them, remove transform shape.

I also modified the circuit-drawing a little, there is no need for the ++(0,0) stuff, and for this case coordinates work fine, you don't need nodes with the empty label.

Finally I included the new sometext node, which is placed to the left of the l1 node, in the fitted node.

\documentclass[12pt,oneside,a4paper]{article}

\usepackage{circuitikz}
\usepackage{tikz}
\usetikzlibrary{positioning,fit}

\begin{document}

\begin{circuitikz} [ european resistors ]
%\draw[help lines, dotted] (-5,-5) grid (10,6); 

\draw [transform shape,scale=0.6] (4, 2) 
to [vR, *-*]  ++(-2,-2)
coordinate (l1) 
to [vR, *-*] ++(2,-2)
to [short, -o] ++(0, -1)
coordinate (b1) 
to [short] ++(0, 1)
to [vR, *-*]  ++(2,2)
coordinate (r1) 
to [vR, *-*]    ++(-2,2)
to [short,-o]   +(0, 1)
coordinate (t1) 
; 

\node (sometext) [left=of l1,align=left,text width=4cm] 
  {Lorem ipsum dolor sit amet consectetur and a bunch more text just for this example.};

\node[fit=(t1) (b1) (sometext) (r1), draw, black, rectangle, inner sep=10pt]{};

\end{circuitikz}

\end{document}

enter image description here