# Create custom symbol: diamond / rhombus shape

I read this little article: http://www.elfsoft2000.com/projects/bipole.pdf and the other two mentioned in this. I want to create a symbol to use in my papers and projects. In my country, some of them are different from the european or american ones so I decided to make them myself.

I managed to two Romanian circuit symbols as presented here: github.com/PopAdi/circuitikz-romanian-symbols

Now I have to do something similar: instead of a circle, there should be a diamond/rhombus. How can I achieve that? I want them to look like the ones presented here: Circuitikz american controlled voltage signs

In my code, for the one with the circle I have:

\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0cm}{\ResUp}}{\pgfpoint{\ResRight}{0cm}}


I managed to make a square with this:

\pgfpathrectanglecorners{\southwest}{\northeast}


But I really don't know how to rotate that square or to change it with a diamond. Can you help my figure this out? Thanks!

Edit: my code looks like this:

\documentclass{article}

\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{shapes,arrows,positioning}
\usetikzlibrary{decorations.markings}

\makeatletter
\pgf@circ@Rlen = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\def\TikzBipolePath#1#2{\pgf@circ@bipole@path{#1}{#2}}
\makeatother

\newlength{\ResUp}
\newlength{\ResRight}

\ctikzset{bipoles/romanianCCS/height/.initial=.60}
\ctikzset{bipoles/romanianCCS/width/.initial=.60}

\pgfcircdeclarebipole{}
{\ctikzvalof{bipoles/romanianCCS/height}}
{romanianCCS}
{\ctikzvalof{bipoles/romanianCCS/height}}
{\ctikzvalof{bipoles/romanianCCS/width}}
{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

\pgfextracty{\ResUp}{\northeast}
\pgfextractx{\ResRight}{\southwest}

%Desenam cerculetul
\pgfpathrectanglecorners{\southwest}{\northeast}

%First little arrow
\pgfmoveto{\pgfpoint{1.0\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{0.1\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{0.3\ResRight}{-0.25\ResUp}}
\pgfmoveto{\pgfpoint{0.1\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{0.3\ResRight}{0.25\ResUp}}

%Second arrow
\pgfmoveto{\pgfpoint{-0.2\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{-1.0\ResRight}{0.0\ResUp}}
\pgfmoveto{\pgfpoint{0.0\ResRight}{0.25\ResUp}}
\pgflineto{\pgfpoint{-0.2\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{0.0\ResRight}{-0.25\ResUp}}

\pgfusepath{draw}
}

\def\romanianCCS#1{\TikzBipolePath{romanianCCS}{#1}}
\tikzset{romanianCCS/.style = {\circuitikzbasekey, /tikz/to path=\romanianCCS, l=#1}}

\begin{document}

\begin{center}
\begin{circuitikz}
\draw (0, 0)
to[romanianCCS, l=${j_1 = 4A}$, *-*] (4, 0);
\end{circuitikz}
\end{center}

\end{document}


which should give you the following result:

I found the solution! I did this:

\pgftransformrotate{-45}
\pgfpathrectanglecorners{\southwest}{\northeast}
\pgftransformrotate{45}


And it's working great!

• Welcome to TeX.SX! What doesn't work with the solution presented on your linked question? Mar 27, 2016 at 14:34
• I added some code to my original post. In the solution presented in that link, they just change the position of some symbols based on the orientation. What I actually want is to define my own symbols, but to use whatever shape I want from the available ones.
Mar 27, 2016 at 14:41
• It would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. Mar 27, 2016 at 15:00
• I added the entire code :)
Mar 27, 2016 at 15:13

If you ever want a diamond instead of a rhombus, you can use:

\documentclass{article}

\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{shapes,arrows,positioning}
\usetikzlibrary{decorations.markings}

\makeatletter
\pgf@circ@Rlen = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\def\TikzBipolePath#1#2{\pgf@circ@bipole@path{#1}{#2}}
\makeatother

\newlength{\ResUp}
\newlength{\ResRight}

\ctikzset{bipoles/romanianCCS/height/.initial=.60}
\ctikzset{bipoles/romanianCCS/width/.initial=.60}

\pgfcircdeclarebipole{}
{\ctikzvalof{bipoles/romanianCCS/height}}
{romanianCCS}
{\ctikzvalof{bipoles/romanianCCS/height}}
{\ctikzvalof{bipoles/romanianCCS/width}}
{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

\pgfextracty{\ResUp}{\northeast}
\pgfextractx{\ResRight}{\southwest}

%Desenam cerculetul
\pgfpathmoveto{\pgfpoint{-\ResRight}{0pt}}
\pgfpathlineto{\pgfpoint{0pt}{-\ResUp}}
\pgfpathlineto{\pgfpoint{\ResRight}{0pt}}
\pgfpathlineto{\pgfpoint{0pt}{\ResUp}}
\pgfpathclose

%First little arrow
\pgfpathmoveto{\pgfpoint{1.0\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{0.1\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{0.3\ResRight}{-0.25\ResUp}}
\pgfpathmoveto{\pgfpoint{0.1\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{0.3\ResRight}{0.25\ResUp}}

%Second arrow
\pgfpathmoveto{\pgfpoint{-0.2\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{-1.0\ResRight}{0.0\ResUp}}
\pgfpathmoveto{\pgfpoint{0.0\ResRight}{0.25\ResUp}}
\pgfpathlineto{\pgfpoint{-0.2\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{0.0\ResRight}{-0.25\ResUp}}

\pgfusepath{draw}
}

\def\romanianCCS#1{\TikzBipolePath{romanianCCS}{#1}}
\tikzset{romanianCCS/.style = {\circuitikzbasekey, /tikz/to path=\romanianCCS, l=#1}}

\begin{document}

\begin{center}
\begin{circuitikz}
\draw (0, 0)
to[romanianCCS, l=${j_1 = 4A}$, *-*] (4, 0);
\end{circuitikz}
\end{center}

\end{document}


• Thanks! I was expecting an answer from you, I really appreciate your work. I thought I can automatically chose whatever shape I want for the symbol. This is a nice implementation too! Thanks again!