🍣

TikZを使って相似や弧、平行記号を出力する方法

に公開1

目的

\LaTeX において日本式の相似記号を出力するためには様々な方法が存在している。
しかし、私が気に入る形状のものはなかったため、TikZを利用して記号を作成した。

一緒に弧記号と平行記号も作成した。

記号

相似記号

\NewDocumentCommand{\jsim}{}{%
    \mathrel{
        \begin{tikzpicture}[baseline={([yshift=-0.25ex]char.base)}, every node/.style={}, every path/.style={}]
            \node[inner sep=0pt, outer sep=0pt] (char) at (0,0){$\phantom{\equiv}$};
            \path let \p1 = ($(char.center)!0.5!(char.east)$) in coordinate (char-east-anchor) at (\x1,\x1);
            \path let \p1 = ($(char.center)!0.5!(char.west)$) in coordinate (char-west-anchor) at (\x1,\x1);
            \draw[line width=0.139ex] let \p1 = (char-east-anchor) in (char-west-anchor) arc [start angle=270, end angle=70, radius=\x1];
            \draw[line width=0.139ex] let \p1 = (char-east-anchor) in (char-west-anchor) to[out=0, in=180] (char-east-anchor) arc [start angle=90, end angle=-110, radius=\x1];
        \end{tikzpicture}
    }%
}

jsim

弧記号

\NewDocumentCommand{\jarc@original}{ m }{%
    \begin{tikzpicture}[every node/.style={}, every path/.style={}]%
        \node[outer sep=0pt, inner sep=0pt] (char) at (0,0){$\mathrm{#1}$};
        \draw[semithick] ([xshift=1pt, yshift=2pt]char.north west) to[out=30, in=150] ([xshift=-1pt,yshift=2pt]char.north east);
    \end{tikzpicture}
}

\NewDocumentCommand{\jarc}{ m }{%
    \mathord{
        \begin{tikzpicture}[baseline={(char.base)}, every node/.style={}, every path/.style={}]%
            \node[outer sep=0pt, inner sep=0pt] (char) at (0,0){\jarc@original{#1}};
        \end{tikzpicture}
    }%
}

jarc

平行記号

\NewDocumentCommand{\jparallel}{}{%
    \mathrel{%
        \begin{tikzpicture}[baseline={(char.base)}, every node/.style={}, every path/.style={}]%
            \node[outer sep=0pt, inner sep=0pt] (char) at (0,0){\phantom{A}};
            \draw[line width=0.139ex, line cap=round] ([xshift=-0.46ex]char.north east) -- (char.south west);
            \draw[line width=0.139ex, line cap=round] (char.north east) -- ([xshift=0.46ex]char.south west);
        \end{tikzpicture}
    }%
}

jparallel

Discussion