[Tex/LaTex] Symbol creation in TikZ

symbolstikz-pgf

I've come up with a way of displaying the symbol my lecturer uses for a poset embedding in LaTeX, having not been able to find it as a standard symbol. The method I employed was using a TikZ picture as a new function with the following code

\newcommand{\Sqsubset}{
\kern3pt
\begin{tikzpicture}
\draw (0ex,0ex) -- (0ex,1.3ex);
\draw (0ex,0) -- (1.3ex,0ex);
\draw (0ex,1.3ex) -- (1.3ex,1.3ex);
\draw (0.325ex,0.325ex) -- (1.3ex,0.325ex);
\draw (0.325ex,0.325ex) -- (0.325ex,0.975ex);
\draw (0.325ex,0.975ex) -- (1.3ex,0.975ex);
\end{tikzpicture}
\kern3pt }

I was basically just wondering if there is a way of using this symbol without having to have the compiler draw it from the code every time… perhaps saving it as a glyph?

Best Answer

The symbol quality can be improved.

Spacings:

  • \mathrel takes care of the horizontal math mode spacing in different math contexts.
  • Side bearings for the symbol can be reduced from 3pt to values similar to sqsubset.

Line drawings:

  • Polylines should not be split and the line segments drawn as single lines. Then line join settings does not apply. If the lines are drawn as connected lines, then the line joining can be made smoother. The example below uses setting round.

  • Also the line caps can be made round as in \sqsubset.

Full example:

\documentclass{article}
\usepackage{tikz}

% Old version
\newcommand{\OldSqsubset}{
\kern3pt
\begin{tikzpicture}
\draw (0ex,0ex) -- (0ex,1.3ex);
\draw (0ex,0) -- (1.3ex,0ex);
\draw (0ex,1.3ex) -- (1.3ex,1.3ex);
\draw (0.325ex,0.325ex) -- (1.3ex,0.325ex);
\draw (0.325ex,0.325ex) -- (0.325ex,0.975ex);
\draw (0.325ex,0.975ex) -- (1.3ex,0.975ex);
\end{tikzpicture}
\kern3pt }

% New version
\newcommand{\Sqsubset}{%
  \mathrel{%
    \tikz[line cap=round, line join=round]
    \draw
      (1.3ex, 0ex) -- (0ex, 0ex) -- (0ex, 1.3ex) -- (1.3ex, 1.3ex)
      (1.3ex, 0.325ex) -- (0.325ex, 0.325ex) -- (0.325ex, 0.975ex)
      -- (1.3ex, 0.975ex)
      (-.13ex, 0ex) (1.3ex + .13ex, 0ex) % side bearings
    ;%
  }%
}

\begin{document}
  \noindent
  $A \OldSqsubset B$
  $A \Sqsubset B$
\end{document}

Result

Related Question