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}

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}
The command \S
is defined with \DeclareRobustCommand
, so redefining it with \renewcommand
is not the best strategy, see When to use \LetLtxMacro?
If you really want a space after \S
(which is not usual, I should say), it's better to act at a lower level.
The kernel definition of \S
is
% latex.ltx, line 1798:
\DeclareRobustCommand{\S}{\ifmmode\mathsection\else\textsection\fi}
so a better strategy would be
\usepackage{xspace}
\let\S\relax % to avoid spurious warnings
\DeclareRobustCommand{\S}{%
\ifmmode
\mathsection
\else
\textsection~%
\fi
}
You surely don't want a line break after §, do you? So ~
is necessary. Using \xspace
doesn't guarantee that a line break is not taken at the space.
Note. With
\let\OldS\S
\renewcommand{\S}{\OldS\ }
an \S
command that ends up in a caption or other moving argument will result in two spaces. Why?
When LaTeX writes in the .aux
file a command \S 1
appearing in a figure caption, it will write
\protect \S \ 1
because the expansion of \OldS
is still \protect\S
. The same would be written out in the .lof
file. When the .lof
file is read in, \protect
will be ignored, and \S
will be interpreted normally as \OldS\
; this means two spaces, because the following \
would still be there.
For having “double §”, you can do
\documentclass{article}
\makeatletter
\DeclareRobustCommand{\NS}{%
\textsection\@ifnextchar\NS{}{~}%
}
\makeatother
\begin{document}
\NS 1 and \NS\NS 2--3
\end{document}
reserving \S
for the cases where you don't want a space (I can't see when, though).
However, I believe that the simplest way is to type
\S~1 and \S\S~2--3
Best Answer
It is good practice to wrap your wrap the
\vdash
into a command. That way you can change the command once in the preamble (say you suddenly need it bold, or larger, or whatever) and it will be changed everywhere in the document. E.g.,