I want to create diagrams with shapes connected by lines like circuittikz, but the online instructions and examples confuse me. Here is a MWE:
\documentclass[12pt]{article}
\usepackage{etoolbox}
\usepackage{pgfplots}
\usepackage{tikz}
% specify tikz libraries needed
\usetikzlibrary{
arrows.meta,automata,backgrounds,calc,chains,decorations,intersections,
math,patterns,plotmarks,positioning,shadings,shapes,trees}
% need 1.15 compatibility
\pgfplotsset{
compat=1.15,
legend style = {font = \LARGE},
}
\newcommand\CM[2]{
\begin{scope}[shift={#2}]
\draw (0,-0.866) -- (0,-2);
\fill (-1,-0.866) -- (+1,-0.866) -- (0,+0.866) -- cycle;
\draw (-1,+1) -- (0,0) -- (+1,+1);
\draw (-2,-0.433) -- (+2,-0.433);
\fill(0,-2) circle (0.1); % O
\fill(-2,-0.433) circle (0.1); % L
\fill(+2,-0.433) circle (0.1); % R
\fill(-1,+1) circle (0.1); % I
\fill(+1,+1) circle (0.1); % J
\end{scope}
}
\listfiles
\begin{document}
\begin{tikzpicture}
\CM{A}{(-3,-3)} % example shape with terminals
\CM{B}{(+3,+3)} % example shape with terminals
%\node[CM](A) at (-3,-3); % preferred syntax
%\node[CM](B) at (+3,+3); % preferred syntax
\draw (-1,-3-0.433) -- (+1,+3-0.433); % example connecting line
%\draw (A.J) -- (B.I); % preferred syntax
\end{tikzpicture}
\end{document}
I want to label all the circles as ports such as O, L, R, I, J such that if I instance the shape twice with node names A and B, I can then connect them by a line as in \draw (A.J) -- (B.I); which would connect the named circles with lines.
I would be happy to do this with custom tikzset or pgfdeclareshape, but nothing I find online seems to fit what I want to do with simplicity and clarity.



circle[radius=length]as the older syntax sometimes leads to weird problems. I'll update this in the answer when I'm back at my computer. – frougon Apr 11 '20 at 19:12every circle/.style={radius=0.1}for nice factoring. – frougon Apr 11 '20 at 23:05lengthwith? The updated code has been tested too, so unless there was a silly error such as looking at the wrong output file, it should work fine. – frougon Apr 12 '20 at 20:11