Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am searching for a wide hat with a right arrow. So far I've found only the regular wide hat (\widehat, shown at the left of the image), or a curved right arrow (\curvearrowright).

Wide had and wide hat with arrow

Is there a way to get something like what I have badly drawn at the right of the image?

share|improve this question
    
Welcome to TeX.sx!. I have included your image. Soon, you will have enough reputation to do it yourself. –  Qrrbrbirlbel Oct 7 '12 at 17:59
    
Thanks for including the image! –  Paul22 Oct 7 '12 at 18:16

1 Answer 1

up vote 11 down vote accepted

I provide two TikZ solutions.

  1. The first one uses uses an empty node before and after the formula that belongs under the wide hat.
    • Disadvantage: The added vertical height will not be taken into calculation
    • Advantage: Math style (display, text, script, scriptscript) is not effected (other then in the \vphantom.
  2. The second one is a node.
    • Disadvantage: Math style is lost. (Change the first \frac into a \tfrac to realize.)
    • Advantage: Vertical height is known to math mode.

Another disadvantage over \widehat is, that the line width doesn't change over the course of the path.

MWE

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}

% Solution 1
\newcounter{tikzmark}
\newcommand{\tikzmark}[2][]{\tikz[baseline, inner sep=0, overlay, remember picture] \node[anchor=base] (#2) {\vphantom{#1}};}

\newcommand{\widehatarrow}[1]{%
    \tikzmark[#1]{widehatarrow\thetikzmark} #1 \tikzmark[#1]{endwidehatarrow\thetikzmark}%
    \tikz[overlay, remember picture] \draw[-to] (widehatarrow\thetikzmark.north)++(.05em,.4ex) -- ($(widehatarrow\thetikzmark.north)!.5!(endwidehatarrow\thetikzmark.north)+(.05em,.8ex)$) -- ($(endwidehatarrow\thetikzmark.north)+(.05em,.4ex)$);%
    \stepcounter{tikzmark}%
}

% Solution 2
\newcommand{\Widehatarrow}[1]{%
\tikz[baseline] {
    \node[inner sep=0, anchor=base] (widehatarrow){$#1$};
    \draw[-to] (widehatarrow.north west)++(.05em,.4ex) -- ($(widehatarrow.north west)!.5!(widehatarrow.north east)+(.05em,.8ex)$) -- ($(widehatarrow.north east)+(.05em,.4ex)$);%
    }%
}


\begin{document}
\begin{equation} % Solution 1
\widehatarrow{A, B} \cdot \widehatarrow{x, y} = \widehatarrow{A, y, B, x}
\end{equation}

\begin{equation} % Solution 2
\Widehatarrow{A, B} \cdot \Widehatarrow{x, y} = \Widehatarrow{A, y, B, x}
\end{equation}

\begin{equation} % Compare both solutions
 \frac{1}{\widehatarrow{A, B} \cdot \Widehatarrow{A, B}} = \frac{1}{\widehatarrow{A, B} \cdot \widehatarrow{A, B}} = \frac{1}{\Widehatarrow{A, B} \cdot \Widehatarrow{A, B}}
\end{equation}
\end{document}

Output

MWE compiled


(By egreg) It's possible to overcome the limitations with \Widehatarrow, by using a \vphantom and \mathpalette:

\newcommand{\Widehatarrow}[1]{\mathpalette\Widehatarrowaux{#1}}
\newcommand{\Widehatarrowaux}[2]{%
  \vphantom{#1\widehat{#2}}
  \tikz[baseline] {
    \node[inner sep=0, anchor=base] (widehatarrow){$#1#2$};
    \draw[-to] (widehatarrow.north west)++(.05em,.4ex)
     -- ($(widehatarrow.north west)!.5!(widehatarrow.north east)+(.05em,.8ex)$)
     -- ($(widehatarrow.north east)+(.05em,.4ex)$);%
  }%
}

Now the height of \Widehatarrow{AB} will be the same as the height of \widehat{AB} and the sizes will be respected, as shown by trying

$\Widehatarrow{AB}=A_{\Widehatarrow{XY}}$
share|improve this answer
    
Anyone, who has an idea how to solve the problems (“disadvantage”), is welcome to comment or point me in the right direction. :) –  Qrrbrbirlbel Oct 7 '12 at 18:55
    
Both problems can be solved with some cognoscenti trickery, for \Widehatarrow. I'll add it to your solution. –  egreg Oct 7 '12 at 19:11
    
The first solution is quite buggy with me (see mirari.fr/BJr2 ) (and it compiles differently every time). Anyway, the second (and its modified version) works perfectly. Thanks! –  Paul22 Oct 7 '12 at 20:04
    
@Paul22 Yes, the first one needs two compilations and is superseded by the second one (especially with egreg's addition), anyway. –  Qrrbrbirlbel Oct 7 '12 at 20:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.