3

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}}

enter image description here

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}
3
  • 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.
    – Skillmon
    Oct 5, 2021 at 6:35
  • Also, what is wrong with using \in instead?
    – Skillmon
    Oct 5, 2021 at 6:35
  • It's not wrong, I just want to know how the code for the middle line is @Skillmon
    – cufcuf
    Oct 5, 2021 at 6:37

1 Answer 1

5

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}

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.