Recently I asked this question: Dashed left arrow over symbol
I needed to know how to put an dashed left arrow over a symbol. I received two answers, one of them used Tikz for this, other use pure LaTeX solution. I had problems with the Tikz-created arrow, so I went with the LaTeX solution. Solution worked great.
However, now I need to create the same arrow, only directing to the right.
I tried to modify (by trial and error) the code that I was provided by user mapf. But because I do not have good grip on what the commands mean, I am getting wierd results.
I managed to: 1) import dashed right arrow symbol from MnSymbol (symbol \dashedrightarrow, 96) 2) Define command \dashedrightarrowtip
I failed to: 1) Define command \odrafill.
I tried different ways, but the arrows were not aligned and the dashes did not appear correctly.
I added a picture that shows my "testing". I added text to the pictures to describe what are my expectations.
Here is the code I am using:
\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$}
%Test 1
%$\m@th\mkern-0.5mu\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill\mkern-5mu\dashedrightarrowtip$}
%Test 2
%$\m@th\dashedrightarrowtip\mkern-5mu\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill\mkern-0.5mu$}
%Test 3
%$\m@th\mkern0mu\dashedrightarrowtip\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill$}
%% put 5pt space above and 1pt below the tip
\def\dashedleftarrowtip{%
\raisebox{\z@}[5pt][1pt]{$\mathord{\dashedleftarrow}$}}
%% put 5pt space above and 1pt 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}