我想设计一个新的元素符号。我无法添加中间线。我该如何在代码中添加中间线?
\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}}
我的代码:
\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}
答案1
你只需在自己绘制的符号上添加另一条线即可。杯子的中间位于 x 坐标 0,你必须从-.5*\h
到.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}