\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}
因此我搜索了如何在节点内插入 tikz 图片并找到了 \savebox。我尝试了它但它一直溢出我的节点,当我尝试在 \savebox 内制作电路并用 \usebox 调用我的盒子时但什么也没有发生。这是我到目前为止的代码和我想要完成的图片。如果有人熟悉 \savebox 并且可以将该电路存储在图片中,您能帮助我或指导我吗?谢谢
答案1
使用下面定义的保存框可以正常工作
\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}
平均能量损失
\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
答案2
这个问题的一个问题是你没有提供一个最小的例子 --- 你只是输入了你所有的代码,而且,正如已经正确指出的那样,这让任务变得困难。
我可以向你展示我所举的一个例子(这是正确的 MWE) adjustbox
,您可以根据自己的使用情况进行调整。
\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}