2

How can I get a left arrow as a math accent to go over single symbols and groups of symbols, in such a way that:

  • the left arrows over a single character and multiple characters have the same heaviness; and
  • the left arrow over a single character is not overly long?

Here is what I've tried so far:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}
\usepackage{accents}
\usepackage{extarrows}

\linespread{1.1} % just to display output here more clearly

\newcommand{\reverse}[1]{\accentset{\leftarrow}{#1}}
\newcommand{\xreverse}[1]{\accentset{\xlongleftarrow{}}{#1}}
\newcommand{\longreverse}[1]{\overleftarrow{#1}}

\begin{document}

Accent single character with left arrow:

\smallskip

$\reverse{\sigma}$ \quad Arrow too short, too light, too small?

$\longreverse{\sigma}$ \quad Arrow too long and heavy!

\medskip

Accent multiple characters with left arrow:

\smallskip

$\xreverse{\sigma \ast \tau}$ \quad Use \verb!\xreverse!: arrow definitely too short. 

$\longreverse{\sigma \ast \tau}$ \quad Use \verb!\longreverse!: arrow long enough, but perhaps too heavy?

\bigskip

Want to use  better arrows in the alternative to \dots
\[(\sigma \ast \tau)^{\leftarrow} \simeq \reverse{\tau} \ast \reverse{\sigma}
\]
\dots that instead puts the long left arrow over the whole group of 3 symbols:

\begin{itemize}

\item $\longreverse{\sigma \ast \tau} \simeq \reverse{\tau} \ast \reverse{\sigma}$ \quad Use \verb!\longreverse! on left, \verb!\reverse! on right.

\item $\longreverse{\sigma \ast \tau} \simeq \longreverse{\tau} \ast \longreverse{\sigma}$ \quad Use \verb!\longreverse! for all.

\end{itemize}

\end{document}

leftarrow accents

I'd strongly prefer a method that avoids using TikZ or other drawing methods. And I need a method that will be relatively robust when a different font family (e.g., lucidabr, mathtimepro2) is used insstead of newtx. also when unicode-math is used along with a math font requiring xelatex.

I am aware of Configurable and Extensible Accents (Arrows, Dots, Vectors) and the item Dashed left arrow over symbol that is referenced by the accepted answer to it.

Addendum: using halloween command \overscriptleftarrow

Following the comment by @GuM, I tried the \overscriptleftarrow command from the halloween package. This does seem to work with all the font families I've tried, no matter whether I'm using pdflatex or, together with unicode-math, xelatex. For example:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{fontspec}
%\setmainfont[Ligatures=TeX]{TeX Gyre Termes}
%\setmainfont[Ligatures=TeX,SmallCapsFont={Latin Modern Roman Caps}]{Latin Modern Roman}
\usepackage{unicode-math}
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}
%\setmathfont[Ligatures=TeX]{Latin Modern Math}

\usepackage{halloweenmath}
\newcommand{\reverse}[1]{\overscriptleftarrow{#1}}

\begin{document}

$\reverse{\sigma \ast \tau} \eqsim \reverse{\tau} \ast \reverse{\sigma}$

\end{document}

Output:

\overscriptleftarrow from halloween.sty and unicode-math

7
  • This question seem to solicit primarily opinion-based answers...
    – Werner
    Sep 11, 2019 at 22:11
  • @Werner: I've rephrased the question. The main point is to use same thickness left arrow accents when over multiple characters as over a single character, but without an overly long accent when over a single character.
    – murray
    Sep 11, 2019 at 22:20
  • Have you tried \overscriptleftarrow from the halloweenmath package?
    – GuM
    Sep 11, 2019 at 22:57
  • @GuM: Will halloweenmath coexist happily with unicode-math and such math fonts as TeX Gyre Termes Math and Latin Modern Math?
    – murray
    Sep 12, 2019 at 1:07
  • halloweenmath does seem to work with every document text & math font I trow at it. I do hate to load in another package with so many definitions -- for "scary" symbols (witches, ghosts, broomsticks, etc.) drawn with pict2e -- irrelevant to ordinary math usage.
    – murray
    Sep 12, 2019 at 14:11

1 Answer 1

3

Here is a solution using the calc and adjustbox packages. You can adjust the thickness of the arrow as well as its height as described below.

enter image description here

First we define the arrow:

\newcommand{\newarrow}{\scalebox{.7}{$\leftarrow$}}

Adjusting the .7 will make the arrow lighter or heavier. Using 1 will give you the original weight of \leftarrow, and will increase the size of the arrowhead.

Next we clip off the body of the arrow using the \clipbox command from the adjustbox package. (Actually it's from the trimclip package which is part of adjustbox.) What remains is .3em of the arrow: mostly just the arrowhead.

After that we scale the arrow body so that the head and body together make up the width of the symbols beneath the arrow. (Actually we clip .1em from the right end because there's some white space there.)

After that we place the reassembled arrow over the symbols using raise and rlap keys from the adjustbox package. If you want to adjust the height of the arrow, you can replace raise=\myheight with raise=1.2\myheight, or any scaling factor.

Here is the macro for \newreverse:

\newcommand{\newreverse}[1]{\settoheight{\myheight}{\ensuremath{#1}}%
\adjustbox{raise=\myheight,rlap}{%
\clipbox*{0 0 {.3em} {1.5\height}}{$\newarrow$}%
\resizebox{\widthof{\ensuremath{#1}}-.3em}{\height}{\clipbox*{{.3em} 0 {\width-.1em} {1.1\height}}{$\newarrow$}}%
}%
#1}

Note that you must define \myheight using \newlength{\myheight}. For some reason, the \adjustbox command doesn't accept raise=\heightof{#1}.

Here is the full code:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}
\usepackage{calc} % for subtracting lengths
\usepackage{adjustbox} % \adjustbox, \clipbox, \scalebox

\newcommand{\newarrow}{\scalebox{.7}{$\leftarrow$}}
\newcommand{\newreverse}[1]{\settoheight{\myheight}{\ensuremath{#1}}%
   \adjustbox{raise=\myheight,rlap}{%
   \clipbox*{0 0 {.3em} {1.5\height}}{$\newarrow$}%
   \resizebox{\widthof{\ensuremath{#1}}-.3em}{\height}{\clipbox*{{.3em} 0 {\width-.1em} {1.1\height}}{$\newarrow$}}%
   }#1}

\newlength{\myheight}

\begin{document}

\begin{itemize}
\item $\newreverse{\sigma \ast \tau} \simeq \newreverse{\tau} \ast \newreverse{\sigma}$
\item $\newreverse{\mathit{abcdefghijklmnop}}$
\end{itemize}

\end{document}
8
  • Perfect explanation, rigorous and precise. Very good.
    – Sebastiano
    Sep 13, 2019 at 19:46
  • 2
    Thank you @Sebastiano. Your comments are always so kind.
    – Sandy G
    Sep 13, 2019 at 21:34
  • :-) I'm said the truth :-):-). My best regards.
    – Sebastiano
    Sep 14, 2019 at 11:54
  • This method still uses the accents package, whose use with unicode-math Ulrike Fischer has cautioned against (see tex.stackexchange.com/questions/507951/…). In any case, the load order with accents is tricky.
    – murray
    Sep 15, 2019 at 14:28
  • @murray, this method does not use accents. I left it in the code for comparison with OPs original attempts (which did use accents). I'll upload a new MWE to be more clear.
    – Sandy G
    Sep 15, 2019 at 16:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .