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}
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}
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 addedtransform shape,scale=0.6
as options to the\draw
creating the circuit. The first of those is needed because the components are created asnode
s, and these are not affected byscale
unless you addtransform shape
. If you don't want the components to be scaled, just the distances between them, removetransform shape
.I also modified the circuit-drawing a little, there is no need for the
++(0,0)
stuff, and for this casecoordinate
s work fine, you don't neednode
s with the empty label.Finally I included the new
sometext
node, which is placed to the left of thel1
node, in thefit
ted node.