0
\documentclass[a4paper,10pt]{article}
\usepackage[left=24mm,right=30mm,bottom=25mm,top=25mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{fadings, positioning}
\usetikzlibrary{shadows.blur}

\newlength{\borderwidth}
\setlength{\borderwidth}{2mm}

\definecolor{plava.b}{RGB}{91,75,183}
\definecolor{crvena.b}{RGB}{163,32,48}
\definecolor{zelena}{RGB}{149,173,124}
\definecolor{orange.b}{RGB}{245,164,41}
\definecolor{unutra}{RGB}{255,255,225}
\definecolor{s.plava}{RGB}{183,206,225}
\definecolor{purp}{RGB}{129,81,153}
\definecolor{siva}{RGB}{140,138,134}

\tikzset{
    anybox/.style={rectangle, rounded corners, minimum width=3cm, minimum height=1.5cm,
        text width=3cm, align=center, inner sep=10pt, blur shadow={shadow blur steps=3},
        draw, fill=unutra, font=\bfseries\sffamily, border=#1},
    M3/.style={anybox=plava.b},
    nosilac/.style={anybox=zelena},
    signal/.style={anybox=crvena.b},
    BJT/.style={anybox=orange.b},
    DSO/.style={anybox=s.plava},
    diodni/.style={anybox=purp},
    kolo/.style={anybox=siva, minimum height=2.5cm,minimum width=2cm, fill=white},
    modularni/.style={minimum width=2cm, text width=1.5cm, align=center},
    >=stealth, 
} 


\tikzset{
border/.style = {
    postaction = {clip, postaction = {draw = #1, solid, 
    line width = \borderwidth, postaction={draw, path fading = north}},
    }
}}

\newsavebox{\mc}
\sbox{\mc}{%
\begin{circuitikz}
 \draw[->,red](-0.6,0.5)--(-0.6,1.5)node
  [red, left, midway]{$Current$};
\end{circuitikz}

}

\begin{document}
\begin{tikzpicture}[node distance=2cm, font=\sffamily]
\node (prvi) [M3] {M3 Cortex MCU\\STM32F103};
\node (drugi) [nosilac, below = of prvi] {NOSILAC\\DSS AD9833};
\node (treci) [signal,below = of drugi] {SIGNAL PORUKE\\DSS AD9833};  
\node (sesti) [BJT,below right= 3mm and 1cm of drugi] {BJT \\MODULATOR};
\node (osmi) [kolo,right =3cm of sesti, label={pojačavačc RF signala}]{   \\\usebox{\mycircuitb}};
\node (deveti) [DSO,below = of sesti]{\textbf{DSO} \\4x Kanala};
\node (deseti) [diodni] at (deveti-|osmi) {DIODNI detektor \\sa NF RC filterom};

\draw[->] (prvi.west)--++(180:5mm)|-(drugi) node[pos=.25,above,sloped, rotate=180] {SPI interface};
\draw[->] (prvi.west)--++(180:5mm)|-(treci);
\draw[->] (drugi)-|(sesti) node[pos=.25, fill=white] (cetvrti) {0.7V@100kHZ}; 
\draw[->] (treci)-|(sesti) node[pos=.25, fill=white] (peti) {0.7V@5kHZ}; 
\draw[->] (sesti)--(osmi) node[modularni, pos=.5, fill=white] (sedmi) {Modulirani\\signal}; 
\draw[->] (osmi)--(deseti);

\draw[dashed,->,red] (deveti.north) -- (sedmi.west);
\draw[dashed,->,red] (deveti.north) -- (peti.west);
\draw[dashed,->,red] (deveti.north) -- (cetvrti.west); 
\draw[dashed,->,red] (deveti) -- (deseti); 
\end{tikzpicture}





\end{document}

So I searched how to insert tikz picture inside node and found \savebox.I tried it but it keeps overflowing my node and when I try to make circuit inside \savebox and call my box with \usebox but nothing happen.Here is my code so far and picture of what I want to accomplish.If anyone is familiar with \savebox that can store this circuit in picture could you help me or guide me.Thanks

2

4
  • You need to \usepackage{circuitikz}. Also, where you have \usebox{\mycircuitb}, which is undefined, replace with \usebox{\mc}, which is defined. Then it compiles. – Steven B. Segletes Apr 13 at 15:02
  • I did some editing so i forgot to change to \mc but i tried also after I fixed it and nothing happens – user239498 Apr 13 at 15:06
  • Did you add \usepackage{circuitikz} in your preamble yet? – SebGlav Apr 13 at 15:07
  • @WeLazt please see the answer below -- adding circuitikz is mandatory running your code should have given an error -- also the savebox syntax slightly changed as below gives the correct result -- the new syntax copied over from the answer by MartinScharrer here -- tex.stackexchange.com/a/23419/197451 -- you may like to upvote the answer if it met your requirement – js bibra Apr 13 at 15:21
0

Using the savebox defined below works fine

\newsavebox\mybox
\begin{lrbox}{\mybox}
    \begin{circuitikz}
        \draw[->,red](-0.6,0.5)--(-0.6,1.5)node
        [red, left, midway]{$Current$};
    \end{circuitikz}
        \end{lrbox}

enter image description here

MWE

\documentclass[a4paper,10pt]{article}
\usepackage[left=24mm,right=30mm,bottom=25mm,top=25mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{tikz, circuitikz}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{fadings, positioning}
\usetikzlibrary{shadows.blur}

\newlength{\borderwidth}
\setlength{\borderwidth}{2mm}

\definecolor{plava.b}{RGB}{91,75,183}
\definecolor{crvena.b}{RGB}{163,32,48}
\definecolor{zelena}{RGB}{149,173,124}
\definecolor{orange.b}{RGB}{245,164,41}
\definecolor{unutra}{RGB}{255,255,225}
\definecolor{s.plava}{RGB}{183,206,225}
\definecolor{purp}{RGB}{129,81,153}
\definecolor{siva}{RGB}{140,138,134}

\tikzset{
    anybox/.style={rectangle, rounded corners, minimum width=3cm, minimum height=1.5cm,
        text width=3cm, align=center, inner sep=10pt, blur shadow={shadow blur steps=3},
        draw, fill=unutra, font=\bfseries\sffamily, border=#1},
    M3/.style={anybox=plava.b},
    nosilac/.style={anybox=zelena},
    signal/.style={anybox=crvena.b},
    BJT/.style={anybox=orange.b},
    DSO/.style={anybox=s.plava},
    diodni/.style={anybox=purp},
    kolo/.style={anybox=siva, minimum height=2.5cm,minimum width=2cm, fill=white},
    modularni/.style={minimum width=2cm, text width=1.5cm, align=center},
    >=stealth, 
} 


\tikzset{
    border/.style = {
        postaction = {clip, postaction = {draw = #1, solid, 
                line width = \borderwidth, postaction={draw, path fading = north}},
        }
}}

\newsavebox\mybox
\begin{lrbox}{\mybox}
    \begin{circuitikz}
        \draw[->,red](-0.6,0.5)--(-0.6,1.5)node
        [red, left, midway]{$Current$};
    \end{circuitikz}
        \end{lrbox}

\begin{document}
    \begin{tikzpicture}[node distance=2cm, font=\sffamily]
        \node (prvi) [M3] {M3 Cortex MCU\\STM32F103};
        \node (drugi) [nosilac, below = of prvi] {NOSILAC\\DSS AD9833};
        \node (treci) [signal,below = of drugi] {SIGNAL PORUKE\\DSS AD9833};  
        \node (sesti) [BJT,below right= 3mm and 1cm of drugi] {BJT \\MODULATOR};
        \node (osmi) [kolo,right =3cm of sesti, label={pojačavačc RF signala}]{\usebox\mybox };
        \node (deveti) [DSO,below = of sesti]{\textbf{DSO} \\4x Kanala};
        \node (deseti) [diodni] at (deveti-|osmi) {DIODNI detektor \\sa NF RC filterom};
        
        \draw[->] (prvi.west)--++(180:5mm)|-(drugi) node[pos=.25,above,sloped, rotate=180] {SPI interface};
        \draw[->] (prvi.west)--++(180:5mm)|-(treci);
        \draw[->] (drugi)-|(sesti) node[pos=.25, fill=white] (cetvrti) {0.7V@100kHZ}; 
        \draw[->] (treci)-|(sesti) node[pos=.25, fill=white] (peti) {0.7V@5kHZ}; 
        \draw[->] (sesti)--(osmi) node[modularni, pos=.5, fill=white] (sedmi) {Modulirani\\signal}; 
        \draw[->] (osmi)--(deseti);
        
        \draw[dashed,->,red] (deveti.north) -- (sedmi.west);
        \draw[dashed,->,red] (deveti.north) -- (peti.west);
        \draw[dashed,->,red] (deveti.north) -- (cetvrti.west); 
        \draw[dashed,->,red] (deveti) -- (deseti); 
    \end{tikzpicture}
    
    
    
    
    
\end{document}
S
3
  • I guess I make mistake in naming package,now everything works but I have anither problem.When I create bigger circuit it comes out of box.Is there any way to set borders – user239498 Apr 13 at 15:22
  • 1
    @WeLazt you have to provide the code which produces the problem as a minimal example -- suggest a new question to attract a larger audience -- also request upvote the above answer if it met your requirement -- searching the site does take time and manhours – js bibra Apr 13 at 15:24
  • You can use \scalebox{}{} form \graphicx to fit the circuit in your node. – Rmano Apr 13 at 15:50
1

One of the problems of this question is that you do not have provided a minimum example --- you just put in all your code, and that, as correctly stated already, makes the task difficult.

I can show you what I have of an example (this is a correct MWE) using adjustbox, you can adapt it to your usage.

\documentclass{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage[RPvoltages]{circuitikz}

\newsavebox{\mycirc}
\sbox{\mycirc}{% no stray spaces
    \begin{tikzpicture}
        \draw (0,0) node[ground]{} to[R=$R_B$] ++(0,2) coordinate(a)
        -- ++(0,1) node[op amp, anchor=+](A){}
        (a) to[R=$R_A$, *-] (a-|A.out) -- (A.out);
    \end{tikzpicture}% no stray spaces
}

\begin{document}

Normal text at 10pt here.

\begin{tikzpicture}[]
    \node [draw, text width=3cm, align=center]{% no stray spaces
        \adjustbox{width=3cm, height=3cm, keepaspectratio}{\usebox{\mycirc}}%
    };
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

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