7

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

2
  • I suppose the dashedness of the arrow is related to some propery of the arrow. This may not be a good general-purpose solution because I don't think you can see the difference between a dashed arrow and a continuous arrow on top of a thin letter such as l....
    – user10274
    May 16, 2013 at 12:48
  • Yes, well I need to but it over big capital letters G, H. So it works well for me :)
    – Rauni
    May 17, 2013 at 3:49

2 Answers 2

3

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}
11
  • Tested, this works fine for me. Thank You! I like that the vector arrowhead is similar to the usual vector arrowhead; it is important because I use dashed arrow and usual arrow on top of each other, so they look really neat. Wish I could accept both answers; both are really good!
    – Rauni
    May 17, 2013 at 19:01
  • Well, Gonzalo's answer has it's good sides and Your answer has it's good sides. I think I will leave Gonzalo's answer accepted, because I like the conciseness of His solution and I think it is more applicable to wider audience; but I will use Your answer in my work because I like the arrowhead better :) I have one problem, though. Package "MnSymbol" seems to overwrite some of the symbols, for example the subset symbol. I like the version of "amssymb" better. How can I keep using the "amssymb" one (or amsmath/amsthm, I don't know where the symbol comes from)?
    – Rauni
    May 17, 2013 at 19:18
  • Importing MnSymbol seems to overwrite many other symbols in the TeX document, which I do not want. I read from tex.stackexchange.com/questions/36006/… that it is possible to load only a certain symbol from MnSymbol font. Can You tell me what symbols exactly You use from MnSymbol and if they can be imported in such a way? If yes, which symbol is it?
    – Rauni
    May 17, 2013 at 19:47
  • Huh, found out that "dashedleftarrow" is symbol no. 98 and imported it as by question tex.stackexchange.com/questions/36006/…. Now I can use it without conflicts :) Maybe You could at least mention that in Your answer?
    – Rauni
    May 17, 2013 at 20:05
  • Hello again! How can I reverse the direction of arrow? I tried like this, but I have problems that the arrows don't align: $\m@th\mkern-0.5mu\cleaders\hbox{$\mkern4mu\shortbar\mkern-3mu$}\hfill\mkern-5mu\dashedrightarrowtip$} \def\dashedrightarrowtip{% \raisebox{\z@}[5pt][1pt]{$\mathord{\dashedrightarrow}$}}
    – Rauni
    Jun 1, 2013 at 5:34
8

Perhaps an overkill, but you could define your arrow with the help of TikZ:

\documentclass{article}
\usepackage{tikz}

\newcommand\overdarrow[1]{%
\begin{tikzpicture}[baseline=(arg.base)]
\node[inner xsep=0pt] (arg) {$#1$};
\draw[densely dashed,dash pattern=on 2pt off 1.5pt,->,shorten >= 0.5pt] (arg.north east) -- (arg.north west);
\end{tikzpicture}%
}

\begin{document}

$a + \overdarrow{LC} = \overdarrow{x} + z$

\end{document}

enter image description here

To have the dashed pattern when the arrow is applied to single small characters, perhaps you could try different dash pattern:

\documentclass{article}
\usepackage{tikz}

\newcommand\overdarrow[1]{%
\begin{tikzpicture}[baseline=(arg.base)]
\node[inner xsep=0pt] (arg) {$#1$};
\draw[densely dashed,dash pattern=on 1pt off 1pt,->,shorten >= 0.5pt] (arg.north east) -- (arg.north west);
\end{tikzpicture}%
}

\begin{document}

$a + \overdarrow{x} = \overdarrow{xy} + z = \overdarrow{ABC}$

\end{document}

enter image description here

3
  • Tested this, in PDF viewer (SumatraPDF) it works very good, but in DVI viewer I encountered a problem. It is probably bug of Yap, though. TeX output shows no errors. Here is stack output from Yap just in case: "Some PostScript specials could not be rendered. Error: /undefined in pgfo Operand stack: --nostringval-- PermitFileReading --nostringval-- PermitFileWriting --nostringval-- Execution stack: ...... MiKTeX GPL Ghostscript 9.00: Unrecoverable error, exit code 1"
    – Rauni
    May 17, 2013 at 18:58
  • I like that the code is short and simple to understand. Thank You!
    – Rauni
    May 17, 2013 at 18:59
  • Overkill is cleaner.
    – user9424
    Jan 19, 2016 at 15:10

You must log in to answer this question.

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