![创建光分路器节点](https://linux22.com/image/479814/%E5%88%9B%E5%BB%BA%E5%85%89%E5%88%86%E8%B7%AF%E5%99%A8%E8%8A%82%E7%82%B9.png)
您能帮我创建一个光分路器节点吗?该节点有两个输入端口和两个输出端口?形状如下:
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{shapes,arrows,positioning,calc}
\usepackage{circuitikz}
\begin{document}
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
% Draw lines
\draw (-2,1) to [out=0,in=180] (0,0);
\draw (-2,-1) to [out=0,in=180] (0,0);
\draw (0,0) to [out=0,in=180] (2,1);
\draw (0,0) to [out=0,in=180] (2,-1);
% Draw center ellipse
\filldraw (0,0) ellipse (0.2 and 0.1);
\end{tikzpicture}
\end{document}
答案1
您可以创建一个pic
。恕我直言,在这种情况下,apic
比 a 更合适node
(毕竟,您会在分隔符的中心写什么?)
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}[optical splitter/.pic = {
\draw[pic actions] (-2,1) coordinate (#1-in-1) to [out=0,in=180] (0,0)
(-2,-1) coordinate (#1-in-2) to [out=0,in=180] (0,0)
(0,0) to [out=0,in=180] (2,1) coordinate (#1-out-1)
(0,0) to [out=0,in=180] (2,-1) coordinate (#1-out-2);
\filldraw[pic actions] (0,0) ellipse (0.2 and 0.1);
}]
\pic[red] at (0,0) {optical splitter=X};
\draw[blue] (-3,-2) |- (X-in-1);
\draw[purple] (X-in-2) -- ++ (0,-1);
\end{tikzpicture}
\end{document}