I have created my custom electric component named myIC using the circuitikz.sty library. myIC has three pins labeled PinA, PinB, PinC and a default label myIClabel. I defined this component within the pgfdeclareshape environment, allowing me to easily incorporate it into a circuitikz environment.
Question: How can I change the default label text myIClabel during the instantiation of myIC? See the output screenshot below
CODE:
\documentclass[border=0cm]{standalone}
\usepackage{circuitikz}
\pgfdeclareshape{myIC}{
% define saved anchor
% ----------------------------------------
\anchor{center}{\pgfpointorigin}
% define Connectors relative to the center
% ----------------------------------------
% Pin A:
\savedanchor\myICpinA{\pgfpoint{-30}{10}}
\anchor{PinA}{\myICpinA}
% Pin B:
\savedanchor\myICpinB{\pgfpoint{-30}{-10}}
\anchor{PinB}{\myICpinB}
% Pin C:
\savedanchor\myICpinC{\pgfpoint{30}{0}}
\anchor{PinC}{\myICpinC}
\foregroundpath{
\pgfpathrectanglecorners{\pgfpoint{-30}{-30}}{\pgfpoint{30}{30}}
\pgfusepath{draw}
\pgftext[left, at={\myICpinA}]{PinA}
\pgftext[left, at={\myICpinB}]{PinB}
\pgftext[right, at={\myICpinC}]{PinC}
% my static label
\pgftext[center, at={\pgfpoint{0}{35}}]{\small\textcolor{black}{myIClabel}}
}
}
\begin{document}
\begin{circuitikz}
% Instance of the custom component in red
\draw (0,0) node[myIC, red] (myIC1) {};
% Another instance in green
\draw (3,0) node[myIC, green] (myIC2) {};
% Yet another instance in blue
\draw (6,0) node[myIC, blue] (myIC3) {};
\end{circuitikz}
\end{document}
OUTPUT:



node [myIC](labelA){}. And again, this has no relation withcircuitikz. Question: why don't you use a distributedcircuitikzinstead of the git version? And why not usingcircuititzprovided chip or muxdemux components? – Rmano Oct 12 '23 at 18:55textanchor and then saynode[myIC]{a label}– Rmano Oct 12 '23 at 21:14\anchor{text}{\pgfpoint{-.5\wd\pgfnodeparttextbox}{\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox}}– John Kormylo Oct 12 '23 at 21:25myICcomponent inside thecircuitikzenvironment, I want to label this node. For instance, I'd like to do this:\draw (0,0) node[myIC, red, myLabel=testLabel1] {};. Feel free to provide some code using onlycircuitikzinstead using the git version :)? Best regards – Marco Moldenhauer Oct 13 '23 at 00:05circuitikzgitpackage to thecircuitikzpackage since it gives me the same result. I edited my question. Thanks for your suggestion! – Marco Moldenhauer Oct 13 '23 at 00:16myIC, the default labelmyIClabelappears. So far, so good. However, some instances should have a different label other thanmyIClabel. – Marco Moldenhauer Oct 13 '23 at 03:40.initialsets the default. Try it. – cfr Oct 13 '23 at 03:54muxdemuxthat should address all your needs. I have been thinking about it for a long time, but your question prompted me to tackle it... so thanks! https://github.com/circuitikz/circuitikz/pull/746 – Rmano Oct 18 '23 at 09:55