1

I cannot figure out how to get an \overleftrightarrow macro to add no vertical space to what is underneath. I am looking for the spacing between lines to appear as if the arrow does not exist and is smashed with the text beneath.

I have seen the following code which is almost perfect, but it still produces vertical space.

\makeatletter
\newcommand{\overleftrightsmallarrow}{\mathpalette{\overarrowsmall@\leftrightarrowfill@}}
\newcommand{\overrightsmallarrow}{\mathpalette{\overarrowsmall@\rightarrowfill@}}
\newcommand{\overleftsmallarrow}{\mathpalette{\overarrowsmall@\leftarrowfill@}}
\newcommand{\overarrowsmall@}[3]{%
    \vbox{%
        \ialign{%
            ##\crcr
            #1{\smaller@style{#2}}\crcr
            \noalign{\nointerlineskip}%
            $\m@th\hfil#2#3\hfil$\crcr
        }%
    }%
}
\def\smaller@style#1{%
    \ifx#1\displaystyle\scriptstyle\else
        \ifx#1\textstyle\scriptstyle\else
            \scriptscriptstyle
        \fi
    \fi
}
\makeatother

Alternatively, I am trying to use the \overleftrightarrow to denote a line. If you suggest an alternate syntax to avoid messing with the vertical space please let me know.

4
  • It’s not completely clear, at least to me, what do you mean, exactly, when you say that you don’t want to add any vertical space to the subformula covered by the arrow: do you mean that the arrow itself should be “smashed”, and that the spacing between the current line and the previous one should be computed as if the arrow were not present (with the arrow possibly overprinting the previous line)? – GuM Jul 25 '17 at 23:45
  • @GuM Yes! I have edited the post to clarify. – Davis Rash Jul 25 '17 at 23:48
  • 1
    Or just \smash{\overleftrightarrow{ABC}}? It seems to achieve the effect you want – Troy Jul 26 '17 at 2:25
  • @Troy: Indeed, \smash{\overleftrightarrow{ABC}} is probably the first solution one thinks of; but I felt like insisting on keeping the original height of the “accentee” (ABC in your example) and smashing only the over-arrow. – GuM Jul 26 '17 at 23:05
1

Here’s a possible solution, with some code borrowed from my halloweenmath package:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath}

\makeatletter

\newcommand*\@Davis@dblstyle@mathpalette[2]{%
  % Works like "\mathpalette", but macro passed in #1 must take
  % (at least) three arguments, of which the first _two_ are
  % style selections.
  \mathchoice
    {#1\displaystyle      \scriptstyle       {#2}}%
    {#1\textstyle         \scriptstyle       {#2}}%
    {#1\scriptstyle       \scriptscriptstyle {#2}}%
    {#1\scriptscriptstyle \scriptscriptstyle {#2}}%
}
\newcommand*\@Davis@dblstyle@overarrow@[4]{%
  % #1 := stretchable covering arrow
  % #2 := base style
  % #3 := style for covering arrow
  % #4 := base symbol
  \vbox{\ialign{##\crcr
    #1#3\crcr
    \noalign{\nointerlineskip}%
    $\m@th\hfil #2#4\hfil$\crcr
  }}%
}
\def\@Davis@arrowfill@#1#2#3#4{%
  $\m@th\thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
   \relax#4\mathsm@sh#4#1\mkern-7mu%
   \cleaders\hbox{$#4\mkern-2mu#2\mkern-2mu$}\hfill
   \mkern-7mu \mathsm@sh#4#3$%
}
\newcommand*\@Davis@leftarrowfill@{%
    \@Davis@arrowfill@\leftarrow\relbar\relbar
}
\newcommand*\@Davis@rightarrowfill@{%
    \@Davis@arrowfill@\relbar\relbar\rightarrow
}
\newcommand*\@Davis@leftrightarrowfill@{%
    \@Davis@arrowfill@\leftarrow\relbar\rightarrow
}

\newcommand*\overDavisrightarrow{%
  \@Davis@dblstyle@mathpalette
    {\@Davis@dblstyle@overarrow@ \@Davis@rightarrowfill@}%
}
\newcommand*\overDavisleftarrow{%
  \@Davis@dblstyle@mathpalette
    {\@Davis@dblstyle@overarrow@ \@Davis@leftarrowfill@}%
}
\newcommand*\overDavisleftrightarrow{%
  \@Davis@dblstyle@mathpalette
    {\@Davis@dblstyle@overarrow@ \@Davis@leftrightarrowfill@}%
}

\makeatother



\begin{document}

A line of text, with some descenders: fgjpqy (and~Q).\\
A formula with ``overarrows'':
\( \overleftrightarrow{A+(B+C)} = \overleftrightarrow{(A+B)+C} \).

A line of text, with some descenders: fgjpqy (and~Q).\\
A formula with ``overarrows'':
\( \overDavisleftrightarrow{A+(B+C)} = \overDavisleftrightarrow{(A+B)+C} \).

\end{document}

The expected output:

Output of the code

Probably, giving some thought to the problem it is possible to find a shorter solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.