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 answer is very font dependent, and I can't access your particular font for which the problem arises. But it seems to me that the kind of kerning you seek almost needs to be reset for each letter. If one were prepared to do that once for an oft-used font, here might be a way.
REVISED SOLUTION (SLOWER, BUT HANDLES \scriptsize
, \scriptscriptsize
):
Lines beginning with %%%% indicate measures you can alter to conform to your particular font. First I create a stacked dot arrangement (\talldot
), merely to have something the vertical height of the desired hat, and which will change size with the math style. I also create \hatglyphCONTENT
which is a box containing a cropped \hat
. I use that box and scale it to the size of \talldot
, designating the result \hatglyph
. Note that, since \talldot
scales with the math style, so will \hatglyph
.
The macro \shifthat
stacks the scaled hat over the desired letter in the appropriate math style, employing a horizontal shift of the hat that was passed as an argument.
The macro \newhat
is where you define the horizontal shift of the hat for each individual glyph, relative to the centered (non-italic) configuration. Rather than specifying that shift in absolute measure, it is given as a multiplier on \glyphwidth
which is 1ex
, measured at the appropriate math style.
One of the keys to this solution is scalerel
package's \ThisStyle{...\SavedStyle...}
syntax, which imports (via \SavedStyle
) the math style at invocation to places where that math style is otherwise lost, for example inside boxes or as arguments to other macros.
\documentclass{article}
\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{verbatimbox}
\newlength\glyphwidth
\newcommand\talldot{%
\ThisStyle{%
%%%% 1ST ARGUMENT OF \stackengine (GAP BETWEEN STACKED DOTS)
\stackengine{.0ex}{$\SavedStyle.$}{$\SavedStyle.$}{O}{c}{F}{F}{S}%
}}
\newsavebox\hatglyphCONTENT
\sbox\hatglyphCONTENT{%
%%%% 1ST OPTIONAL ARGUMENT OF \addvbuffer (CROP OFF TOP OF STACKED hat)
%%%% 2ND OPTIONAL ARGUMENT OF \addvbuffer (CROP OFF BOTTOM OF STACKED hat)
\addvbuffer[-0.05ex -1ex]{%
\stackengine{-.1ex}{ }%
{\(\hat{}\)}{O}{c}{F}{F}{L}%
}}
\newcommand\hatglyph{\ThisStyle{\scalerel*{\usebox{\hatglyphCONTENT}}%
{\SavedStyle\talldot}}}
\newcommand\shifthat[2]{%
\ThisStyle{%
%%%% 1ST ARGUMENT OF \stackengine (GAP BETWEEN GLYPH AND \hatglyph)
\stackengine{0.0ex}{\(\SavedStyle#2\)}%
{\(\rule{#1}{0ex}\SavedStyle\hatglyph\)}{O}{c}{F}{T}{S}%
}%
}
\newcommand\newhat[1]{%
\ThisStyle{\setlength\glyphwidth{\widthof{$\SavedStyle x$}}%
\if A#1\shifthat{0.5\glyphwidth}{#1}\else
\if B#1\shifthat{0.2\glyphwidth}{#1}\else
\if x#1\shifthat{0.1\glyphwidth}{#1}\else
\shifthat{0.15\glyphwidth}{#1}% THIS IS THE DEFAULT VALUE
\fi
\fi
\fi
}%
}
\fboxsep=0pt\fboxrule=.25pt
\begin{document}
\centering
{\tiny How hatglyph is being scaled to \verb|\talldot| (stacked dots)\\
at different mathstyles}
\[
x
\scalerel{\fbox{\hatglyph}}{\ThisStyle{\fbox{$\SavedStyle\talldot$}}}
\scriptstyle
\scalerel{\fbox{\hatglyph}}{\ThisStyle{\fbox{$\SavedStyle\talldot$}}}
\scriptscriptstyle
\scalerel{\fbox{\hatglyph}}{\ThisStyle{\fbox{$\SavedStyle\talldot$}}}
\]
\[
\begin{array}{l}
\hat A \hat B \hat x \hat y A_{{\hat x}_{\hat B \hat A \hat x}}\\
\newhat A \newhat B \newhat x \newhat y A_{{\newhat x}_{\newhat B
\newhat A \newhat x}}\\
\end{array}
\]
\end{document}
ORIGINAL SOLUTION (FAST BUT CAN'T HANDLE \scriptsize
, \scriptscriptsize
):
The macro \newhat
does a test on what letter is the argument and uses a horizontal shift on the hat symbol to set the location for that letter. If a letter has not been "rekerned" in this fashion, it defaults to a setting (as shown for the letter "y" in my example. The value of \Sstackgap
determines the vertical spacing betwen the top of the letter and the bottom of the hat. The negative value was required, because my hat is actually an elevated had over a null symbol, and I had to bring it down a bit, when stacked over an additional letter.
The MWE shows the normal \hat
on the first line, and \newhat
on the second. As I said, since I don't have your font, my font doesn't really suffer the problems yours does, so there is not a great difference.
Note: instead of using a "default" shift, as I do in this MWE, you could alternately use \hat{#1}
as the default, which would get you back to where you were. Also, I use pts as units of my shift. You might prefer ex's, so as to retain usage when the font is scaled.
\documentclass{article}
\usepackage[oldsyntax]{stackengine}
\def\stacktype{S}\Sstackgap=-4.3pt
\newcommand\shifthat[2]{%
\stackengine{\Sstackgap}{$#2$}{\(\hspace{#1}\hat{}\)}{O}{l}{F}{T}{S}}
\newcommand\newhat[1]{%
\if A#1\shifthat{5.2pt}{#1}\else
\if B#1\shifthat{4.8pt}{#1}\else
\if x#1\shifthat{3.6pt}{#1}\else
\shifthat{3.4pt}{#1}% THIS IS THE DEFAULT VALUE
\fi
\fi
\fi
}
\begin{document}
\[
\begin{array}{l}
\hat A \hat B \hat x \hat y\\
\newhat A \newhat B \newhat x \newhat y
\end{array}
\]
\end{document}
[EDIT: This MWE uses obsolete stackengine syntax for setting stackgap lengths (e.g., \Sstackgap=1ex), which prevented scalable lengths from scaling under a fontsize change. Version 2 of the package (submitted JUL-11-13) remedies the problem with a small syntax change.]
Best Answer
I believe this should be reported as a bug in
babel-spanish
.Anyway, since typing
\widehat{<}
is not really good because it will produce wrong spaces, you can use a workaround: define a command before the special action ofbabel-spanish
enters the scene.If you want to type
\hat{<}
or\widehat{<}
in the body of the document, you can't unless you loadbut, as I said at the beginning, this would produce wrong spacing because
\hat{<}
would be considered an ordinary symbol.Thanks to Dan for pointing out that in a former version of the answer
\string
was not needed.