[Tex/LaTex] How to make a plus sign with arrowheads on each of the four endpoints

math-modesymbols

There is a common operation in the sparse-direct literature (see pg. 7) called an "extend-add", and it is usually denoted with a particular symbol that looks like a large plus sign with arrowheads on each tip.

enter image description here

I falsely assumed that I could simply overlap $\updownarrow$ and $\leftrightarrow$ via the mathtools package's \mathllap and friends, but the results were far from pleasing (everything was too jumbled).

Is there a simpler way to generate such a symbol?

Best Answer

Simple overlapping

The overlapping of the symbols \leftrightarrow and \updownarrow can be done with \ooalign:

\ooalign{$\leftrightarrow$\cr\hfil$\updownarrow$\hfil}

Some additional work is needed:

  • Adapting to different math styles. The formula above would always use \textstyle.
  • If \mathsurround is set, then the additional space would be added above to the left and right. This can be cured by \m@th that sets \mathsurround to zero.
  • The symbol is used as binary operator, putting it in \mathbin notifies TeX to put additinal space for binary operators.

File:

\documentclass{article}
% \usepackage{txfonts} % similar \usepacakge{pxfonts}
% \usepackage{mathabx}
% \usepackage{MnSymbol}

\makeatletter
\newcommand*{\extendadd}{%
  \mathbin{%
    \mathpalette\extend@add{}%
  }%
}
\newcommand*{\extend@add}[2]{%
  \ooalign{%
    $\m@th#1\leftrightarrow$%
    \vphantom{$\m@th#1\updownarrow$}% fix the height
    \cr
    \hfil$\m@th#1\updownarrow$\hfil
  }%   
}
\makeatother

% for testing the bounding box of the symbol
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.2pt}

\begin{document}
\[
  \mathcal{F}_\mathbf{i} =
  \mathcal{F}_\mathbf{i}^0
  \extendadd
  \mathcal{U}_{\mathbf{c}_1}
  \extendadd
  \mathcal{U}_{\mathbf{c}_2}
  \qquad
  \fbox{$\extendadd$}^{\extendadd^{\extendadd}}
\]
\end{document}

Result for CM fonts:

CM large

Result for package txfonts:

TX large

Result for package mathabx:

mathabx large

Result for package MnSymbol:

MnSymbol large

Observations:

  • The arrow heads are too large.
  • Depending on the font and size \updownarrow might have a smaller total height than the width of \leftrightarrow.

Overlapping with resizing

The idea is to resize \longleftrightarrow to the width of \leftrightarrow to get smaller arrow heads. However, this will also make the lines thinner.

The tricky part is that scaling also changes the vertical position of the symbol. Because of the arrows the height of the character bounding box \leftrightarrow is not too helpful. But we can assume the symbol is vertically centered respective to the mathematical axis. Therefore the code below puts \leftrightarrow to the base line, resizes it and moves it back to the mathematical axis. to the mathematical axis.

The vertical double arrow cannot generated the same way. First the symbol \longupdownarrow is missing. Also we have seen above, that the symbol might be too small in comparison with the \leftrightarrow. Therefore the symbol is generated by rotating the horizontal double arrow.

\documentclass{article}
% \usepackage{txfonts}
% \usepackage{pxfonts}
% \usepackage{mathabx}
% \usepackage{MnSymbol}

\usepackage{graphicx}% (only graphics is needed)

\makeatletter
\newdimen\extend@width
\newdimen\extend@mathaxis
\newcommand*{\extendadd}{%
  \mathbin{%
    \mathpalette\extend@add{}%
  }%
}
\newcommand{\extend@add}[2]{%
  \m@th
  \sbox0{$#1\vcenter{}\smash{\leftrightarrow}$}%
  \extend@width=\wd0 %
  \extend@mathaxis=\ht0 %
  \sbox0{%
    \resizebox{\extend@width}{!}{%
      \raisebox{-\extend@mathaxis}{$#1\longleftrightarrow$}%
    }%
  }%
  \rlap{%
    \raisebox{\extend@mathaxis}{%
      \copy0 %
    }%
  }%
  \dp0=0pt %
  \ht0=0pt %
  \hbox to\extend@width{%
    \hfil
    $#1%
      \vcenter{%
        \hbox{%
          \rotatebox{90}{\copy0}%
        }%
      }%
    $%
    \hfil
  }%
}
\makeatother

% for testing the bounding box of the symbol
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.2pt}

\begin{document}
\[
  \mathcal{F}_\mathbf{i} =
  \mathcal{F}_\mathbf{i}^0
  \extendadd
  \mathcal{U}_{\mathbf{c}_1}
  \extendadd  
  \mathcal{U}_{\mathbf{c}_2}
  \qquad
  \fbox{$\extendadd$}^{\extendadd^{\extendadd}}
\]
\end{document}

Result for CM fonts:

CM scaled

Result for package txfonts:

TX scaled

Result for package mathabx:

mathabx scaled

Result for package MnSymbol:

MnSymbol scaled

It is also possible to have something in between, less scaling, by composing a smaller \longleftrightarrow from \leftarrow and \rightarrow as base for the resized double arrow.