1

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.

4
  • Could you also point me to the service where it is possible to get a link to a compiled latex code for in turn pasting it here ? – xolodec May 18 '14 at 11:42
  • I use tlhiv.org/ltxpreview but it does not support all packages, in particular it does not support circuitikz – JLDiaz May 18 '14 at 11:44
  • Welcome to TeX.SX! Please always create complete, compilable examples, rather than (a collection of) snippets. Makes it easier for us, and we don't have to make any assumptions about how you've done things. You can compile the PDF on your own machine, take a screenshot, and upload that to your post. – Torbjørn T. May 18 '14 at 12:05
  • Thank you for pointing me out the possibility of screenshot uploading. I have tried once to add image before, but see only form with url to image (web-based) and no possibility to add file from localhost. Edited with compiled results and full examples. – xolodec May 18 '14 at 12:16
2

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

7
  • If I had more upvotes , I would give them all to you! Thank you very much. – xolodec May 18 '14 at 12:30
  • Do you know, by the way, why i couldn't use one plus (to [vR, *-*] +(-2,2)) in circuitikz environment, as i can do in tikz - to draw line, but do not move drawing pointer to the end of line? – xolodec May 18 '14 at 12:34
  • Unless I misremember, the to operation in TikZ simply doesn't support +() or ++(). – kenshin May 18 '14 at 12:43
  • And what is possible to use instead of to ? maybe -- ? – xolodec May 18 '14 at 12:47
  • @PavelShvechikov (You haven't actually used any upvotes yet.) The +() operation doesn't seem to work with to as @kenshin says. Try for example \begin{tikzpicture} \draw (0,0)node{S} to[bend right] +(1,0) to[bend left] +(0,1); \end{tikzpicture}. – Torbjørn T. May 18 '14 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.