Is there a symbol for a right arrow with a square in the middle?

The only problem was finding a suitably small square symbol, which can be found in mathabx and imported.

A few tricks can make for defining also the corresponding left arrow avoiding code duplication. The square is positioned so that the distance from the arrow end to it is half than the distance to the arrow tip; this is of course reversed for the left arrow. You can vary this choice by changing {1}{2} into, say {1.5}{2.5} or whatever you think fit.

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{marvosym}

\DeclareFontFamily{U}{mathb}{}
\DeclareFontShape{U}{mathb}{m}{n}{
  <-5.5> mathb5
  <5.5-6.5> mathb6
  <6.5-7.5> mathb7
  <7.5-8.5> mathb8
  <8.5-9.5> mathb9
  <9.5-11> mathb10
  <11-> mathb12
}{}
\DeclareSymbolFont{mathb}{U}{mathb}{m}{n}
\DeclareMathSymbol{\abxsmallsquare}{2}{mathb}{"05}

\makeatletter
\DeclareRobustCommand{\sqrightarrow}{%
  \mathrel{\mathpalette\sq@arrow{{1}{2}\rightarrow}}%
}
\DeclareRobustCommand{\sqleftarrow}{%
  \mathrel{\mathpalette\sq@arrow{{2}{1}\leftarrow}}%
}
\newcommand{\sq@arrow}[2]{\sq@@arrow#1#2}
\newcommand{\sq@@arrow}[4]{%
  \ooalign{%
    \hskip 0pt plus #2fil
    $\m@th#1\abxsmallsquare$%
    \hskip 0pt plus #3fil\cr
    $\m@th#1#4$\cr}%
}
\makeatother

\begin{document}

$a\sqrightarrow b \sqleftarrow c$

$\scriptstyle a\sqrightarrow b \sqleftarrow c$

$\scriptscriptstyle a\sqrightarrow b \sqleftarrow c$

\end{document}

enter image description here


Two variant solution based on the stackinset command from stackengine and relsize or rotating:

\documentclass[border = 2pt]{standalone}

\usepackage{stackengine} %
\usepackage{amssymb, relsize, rotating}
\usepackage{old-arrows} 
\newcommand\sqarrow{\stackMath\mathrel{\stackinset{c}{0ex}{c}{0.14ex}{\mathsmaller{\mathsmaller{\Box}}}{ ―――→ }}}
\newcommand\varsqarrow{\stackMath\mathrel{\stackinset{c}{0ex}{c}{0.12ex}{\rotatebox{45}{$ \diamond $}}{ ―――→ }}}
\begin{document}

 $ A \sqarrow B$ \quad

$ A \varsqarrow B$

\end{document} 

enter image description here

Tags:

Symbols