# Create element symbol with newcommand and tikz

I want to design a new element symbol. I couldn't add the middle line. How can I add the middle line to my code?

\newcommand{\myinn}[1]
{
\hspace{\spp}
\tikz[line width=\lw,line cap=round,rotate=#1,baseline=-0.4ex]
{\draw (-0.5*\w,0.5*\h) -- (-0.5*\w,0.5*\w-0.5*\h)
arc (-180:0:0.5*\w) -- (0.5*\w,0.5*\h);}
\hspace{\spp}
}
\newcommand{\myin}{\myinn{270}}


My code:

\documentclass[a5paper]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{tikz}
\def\h {1.3ex} % cup and cap height
\def\w {1.2ex} % cup and cap width
\def\lw{0.12ex} % cup and cap line width
\def\spp{0.7269ex} % space before and after

\newcommand{\myinn}[1]
{
\hspace{\spp}
\tikz[line width=\lw,line cap=round,rotate=#1,baseline=-0.4ex]
{\draw (-0.5*\w,0.5*\h) -- (-0.5*\w,0.5*\w-0.5*\h)
arc (-180:0:0.5*\w) -- (0.5*\w,0.5*\h);}
\hspace{\spp}
}
\newcommand{\myin}{\myinn{270}}
\begin{document}
$\myin$
\end{document}

• You shouldn't do \def\<one-letter-macro> in LaTeX, better use \newcommand*\<one-letter-macr> instead, and even then you should perhaps pick a longer name. Oct 5, 2021 at 6:35
• Also, what is wrong with using \in instead? Oct 5, 2021 at 6:35
• It's not wrong, I just want to know how the code for the middle line is @Skillmon Oct 5, 2021 at 6:37

You just have to add another line to your self drawn symbol. The middle of your cup is at the x-coordinate 0 and you must go from -.5*\h to .5*\h:

\documentclass[a5paper]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{tikz}
\newcommand*\h {1.3ex} % cup and cap height
\newcommand*\w {1.2ex} % cup and cap width
\newcommand*\lw{0.12ex} % cup and cap line width
\newcommand*\spp{0.7269ex} % space before and after

\newcommand{\myinn}[1]
{%
\leavevmode
\kern\spp
\tikz[line width=\lw,line cap=round,rotate=#1,baseline=-0.4ex]
\draw
(-0.5*\w,0.5*\h) -- (-0.5*\w,0.5*\w-0.5*\h)
arc (-180:0:0.5*\w) -- (0.5*\w,0.5*\h)
(0,-.5*\h) -- (0,.5*\h)
;%
\kern\spp\relax
}
\newcommand{\myin}{\myinn{270}}
\begin{document}
$\myin \renewcommand*\h{3.5ex}\myin % <- works for other sizes as well$
\end{document}


• This is very good thank you for your support @Skillmon Oct 5, 2021 at 6:42
• How can I align the symbol vertically up? @Skillmon Oct 5, 2021 at 7:12
• @cufcuf use the baseline key in the optional argument of \tikz. You can search the pgfmanual for an explanation. Oct 5, 2021 at 7:28
• thank you :) @Skillmon Oct 5, 2021 at 10:14