[Tex/LaTex] Dashed left arrow over symbol

arrowssymbols

I want to put dashed left arrow over symbol.

Dashed left arrow looks like this:

$x \dashedleftarrow y$

I want arrow to be over symbol $x$, like in

$\overleftarrow{x}$

, only dashed.

I tried to search, but come up only with this:
“Broken” arrow symbol

I did not find it in “The Comprehensive LaTeX Symbol List”, and DeTexify does not work here for obvious reasons (it can only give me dashed left arrow, but not dashed left arrow over symbol).

EDIT: Read from http://ctan.vgtu.lt/info/symbols/comprehensive/symbols-a4.pdf, that there is package esvect for defining vectors, but it does not help, as it only allows to choose some styles of vector.

EDIT2: Package "extpfeil" could be helpful:
http://ctan.vgtu.lt/macros/latex/contrib/extpfeil/README

should be a list of three symbols (single
tokens or {} groups), giving (in this order):
– left end of the arrow
– middle part of the arrow (will be multiplicated,
mostly \relbar or \Relbar)
– right end of the arrow.

But what should be the middle part, then? I have not used macros before much and this is bit confusing for me..

EDIT3:
I ended up using mapf's answer, because I had rendering problems with Gonzalo's answer.

Now I discovered that I need to have a dashed right arrow as well.

I messed around with parameters in mapf's answer to find out how it works. I tried to just reverse the parameters in the definition of left dashed arrow, but I got wierd results 🙂

Mapf, maybe You can explain what do the parameters mean?

Here is the minimal example and the problems I am having right now:

\documentclass[12pt,a4paper,draft]{article}
\pagestyle{plain}
\usepackage[estonian]{babel}
\usepackage[a4paper]{geometry}
\usepackage{hyphenat}
\usepackage{enumerate}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{indentfirst}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{color}
\usepackage{tikz} 

% =============================================
%Import symbol "\dashedleftarrow" from font MnSymbol without importing the whole package
% =============================================

\DeclareFontFamily{U} {MnSymbolA}{}

\DeclareFontShape{U}{MnSymbolA}{m}{n}{
  <-6> MnSymbolA5
  <6-7> MnSymbolA6
  <7-8> MnSymbolA7
  <8-9> MnSymbolA8
  <9-10> MnSymbolA9
  <10-12> MnSymbolA10
  <12-> MnSymbolA12}{}
\DeclareFontShape{U}{MnSymbolA}{b}{n}{
  <-6> MnSymbolA-Bold5
  <6-7> MnSymbolA-Bold6
  <7-8> MnSymbolA-Bold7
  <8-9> MnSymbolA-Bold8
  <9-10> MnSymbolA-Bold9
  <10-12> MnSymbolA-Bold10
  <12-> MnSymbolA-Bold12}{}

\DeclareSymbolFont{MnSyA} {U} {MnSymbolA}{m}{n}

\DeclareMathSymbol{\dashedleftarrow}{\mathrel}{MnSyA}{98}
\DeclareMathSymbol{\dashedrightarrow}{\mathrel}{MnSyA}{96}

\def\Gg{{\mathbf{G}}}
\def\gc{{\mathbf{g}}}

\newcommand{\toright}[1]{\overrightarrow{#1}}
\newcommand{\toleft}[1]{\overleftarrow{#1}}

\newcommand{\torightleft}[1]{\toleft{\toright{#1}}}
\newcommand{\toprerightleft}[1]{\toleft{\topreright{#1}}}    
\newcommand{\torightpreleft}[1]{\topreleft{\toright{#1}}}    
\newcommand{\toprerightpreleft}[1]{\topreleft{\topreright{#1}}}

\newcommand{\toleftright}[1]{\toright{\toleft{#1}}}
\newcommand{\topreleftright}[1]{\toright{\topreleft{#1}}}
\newcommand{\toleftpreright}[1]{\topreright{\toleft{#1}}}
\newcommand{\topreleftpreright}[1]{\topreright{\topreleft{#1}}}

% =============================================
% How to make dashed left arrow over symbol:
% https://tex.stackexchange.com/questions/114501/dashed-left-arrow-over-symbol
% =============================================
\makeatletter
\newcommand{\topreleft}[1]{%
  \vbox {\m@th\ialign{##\crcr
  \odlafill \crcr
  \noalign{\kern-\p@\nointerlineskip}
  $\hfil\displaystyle{#1}\hfil$\crcr}}}

\newcommand{\topreright}[1]{%
  \vbox {\m@th\ialign{##\crcr
  \odrafill \crcr
  \noalign{\kern-\p@\nointerlineskip}
  $\hfil\displaystyle{#1}\hfil$\crcr}}}

%% fill with (short) minus signs
\def\odlafill{%
$\m@th\dashedleftarrowtip\mkern-5mu\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill\mkern-0.5mu$}
%  $\m@th\mkern0mu\dashedleftarrowtip\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill$}

%% fill with find (short) minus signs
\def\odrafill{%
$\m@th\mkern-5mu\cleaders\hbox{$\mkern-3mu\shortbar\mkern4mu$}\hfill\mkern-0.5mu\dashedrightarrowtip$}
%$\m@th\mkern-0.5mu\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill\mkern-5mu\dashedrightarrowtip$}
%$\m@th\dashedrightarrowtip\mkern-5mu\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill\mkern-0.5mu$}
%$\m@th\mkern0mu\dashedrightarrowtip\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill$}

%% put 2pt space above and below the tip
\def\dashedleftarrowtip{%
  \raisebox{\z@}[5pt][1pt]{$\mathord{\dashedleftarrow}$}}

%% put 2pt space above and below the tip
\def\dashedrightarrowtip{%
  \raisebox{\z@}[5pt][1pt]{$\mathord{\dashedrightarrow}$}}

%% make the minus shorter to fit \dashedleftarrow
\def\shortbar{%
%  \smash{\scalebox{1}[1.0]{$-$}}}
\smash{\scalebox{0.4}[1.0]{$-$}}}
\makeatother

% =============================================


\begin{document}
Arrow over G should fit nicely into the brackets:

$\left[\toleft{\Gg}\right] = \left[ \topreleft{\Gg} \right].$

Dashed right arrow and left arrow should be of the same length:

$\toprerightleft{\gc}$

Left and right arrow are misaligned:

$\toprerightpreleft{\gc}$

Just for comparison:

$\torightleft{[\gc]}$

Both dashed arrows should be of the same length and align:

$\topreright{\topreleft{\Gg}}$

\end{document}

Current situation

Best Answer

Here is a pure LaTeX solution that uses \dashedleftarrow from MnSymbol, and makes it extendable with (shortened) minus signs, as usual for extendable accents. The new command to use is \odla{...}, short for \overdashedleftarrow.

\documentclass{article}

\usepackage{graphicx}
\usepackage{MnSymbol}

\makeatletter
\newcommand{\odla}[1]{%
  \vbox {\m@th\ialign{##\crcr
  \odlafill \crcr
  \noalign{\kern-\p@\nointerlineskip}
  $\hfil\displaystyle{#1}\hfil$\crcr}}}

%% fill with (short) minus signs
\def\odlafill{%
  $\m@th\dashedleftarrowtip\mkern-5mu\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill\mkern-0.5mu$}

%% put 2pt space above and below the tip
\def\dashedleftarrowtip{%
  \raisebox{\z@}[2pt][2pt]{$\mathord{\dashedleftarrow}$}}

%% make the minus shorter to fit \dashedleftarrow
\def\shortbar{%
  \smash{\scalebox{0.4}[1.0]{$-$}}}
\makeatother

\begin{document}
\begin{equation*}
  \odla{x} \quad \odla{ab} \quad \odla{abc} \quad \odla{abcd} \quad \odla{abcde} \quad \odla{a}^{\:\odla{b}} \quad \odla{abcdefghijklmnop}
\end{equation*}
\end{document}

sample output

In the likely case you don't want to use MnSymbol as your math font just to have the \dashedleftarrow we use as a the arrow tip here, we can use this symbol like this:

\documentclass{article}

\usepackage{graphicx}

\DeclareFontFamily{U}{MnSymbolA}{}
\DeclareSymbolFont{MnSyA}{U}{MnSymbolA}{m}{n}
\DeclareFontShape{U}{MnSymbolA}{m}{n}{
    <-6>  MnSymbolA5
   <6-7>  MnSymbolA6
   <7-8>  MnSymbolA7
   <8-9>  MnSymbolA8
   <9-10> MnSymbolA9
  <10-12> MnSymbolA10
  <12->   MnSymbolA12}{}
\DeclareMathSymbol{\dashedleftarrow}{\mathrel}{MnSyA}{98}

\makeatletter
\newcommand{\odla}[1]{%
  \vbox {\m@th\ialign{##\crcr
  \odlafill \crcr
  \noalign{\kern-\p@\nointerlineskip}
  $\hfil\displaystyle{#1}\hfil$\crcr}}}

%% fill with (short) minus signs
\def\odlafill{%
  $\m@th\dashedleftarrowtip\mkern-5mu\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill\mkern-0.5mu$}

%% put 2pt space above and below the tip
\def\dashedleftarrowtip{%
  \raisebox{\z@}[2pt][2pt]{$\mathord{\dashedleftarrow}$}}

%% make the minus shorter to fit \dashedleftarrow
\def\shortbar{%
  \smash{\scalebox{0.4}[1.0]{$-$}}}
\makeatother

\begin{document}
\begin{equation}
  \odla{x} \quad \odla{ab} \quad \odla{abc} \quad \odla{abcd} \quad \odla{abcde} \quad \odla{a}^{\:\odla{b}} \quad \odla{abcdefghijklmnop}
\end{equation}
\end{document}