
我想將“傳統”tikznode
和circuitikz
組件混合在一起tikzpicture
,但我在定位它們時遇到問題。
例如,我想得到這樣的結果:
但透過下面的 MWE,我得到了這個結果(節點與電池組件重疊):
如何在不手動增加節點和電池之間距離的情況下避免節點和電池重疊?
微量元素
\documentclass{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) to [battery1={bat}, name=bat] ++(0.5,0)%
(bat.east) -- ++(0.5,0)%
node[rectangle,draw] (Nod1) {Node 1}%
;%
\end{tikzpicture}
\end{document}
答案1
您只需要為節點指定一個錨點,預設值(您擁有的)是anchor=center
,但您需要anchor=west
。
更新:根據扎科的評論,我提供了另一種選擇,即移除east
電池中的錨並改變距離。
\documentclass{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) to [battery1={bat}, name=bat] ++(0.5,0)%
(bat.east) -- ++(0.5,0)%
node[anchor=west,rectangle,draw] (Nod1) {Node 1};
%%%%%%% Or better (See Zarko and Romano's comments):
\draw (0,-2) to [battery1=bat, name=bat2] ++(0.96,0) node[anchor=west,draw] (Nod1) {Node 1};
\end{tikzpicture}
\end{document}