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 would like to use a hat in exponent for a notation, and I have found no satisfactory way of doing this. If I go for $f^{\hat{\null}}$, the hat is far too high, while $f^\wedge$ gives to big and too acute a hat. I would like to have the regular hat, but placed in exponent just as if it where usually drawn in the center of the line, not on the top. Any idea?

Precision: I seek a symbol that I could use quite like \wedge, in the sense that I should be able to write $f^\solution$ and more importantly $f_x^\solution$ with the hat and the index aligned correctly. A solution that would need to rewrite all my $f^\wedge$ in a slightly different way but would give good alignment without too much twiddling would already be good.

Additional precision: I also have to deal with double anitderivatives, so I need to be able to have the equivalent of $f^{\wedge\wedge}$, with both hats on level. The really best solution would be to extract the symbol used by \hat, without the surrounding command (i.e., the command that puts this symbol on top of the next letter).

share|improve this question
    
What about $f\text{\^{}}$ ? –  tibL Jun 4 '12 at 11:33
    
@tibL: bad idea, this would not give the usual behavior of an exponent; for example, in $f_x\text{\^{}}$ the hat is not above the x. –  Benoît Kloeckner Jun 4 '12 at 11:50
    
Can you post a picture of what you are trying to achieve. (A doctored one would be just fine. :)) –  Count Zero Jun 4 '12 at 11:53
    
@count Zero: alone, $f\text{\^{}}$ looks good to me, it is the alignment problem that bothers me as soon as there is an index. –  Benoît Kloeckner Jun 4 '12 at 13:00
1  
this is very like the question more-aesthetic-perhaps-shallower-superscript-check-symbol/52708#52708 although the exponent there was a check, not a hat. –  barbara beeton Jun 4 '12 at 14:33

4 Answers 4

up vote 9 down vote accepted

You can get a decent result with

$f\hat{\mkern6mu}$

or

$f{\mathchar"5E}$

In the second case the spacing is perhaps too much; here they are side by side with a symbol after them to show the spacing

enter image description here

share|improve this answer
    
Of course, if you use that alot, you shall put \newcommand*{\binhat}{\hat{\mkern6mu}} in your preamble, but you probably know that... –  tohecz Jun 4 '12 at 12:43
    
As said in the comment, this kind of solution does not answer my question; when there is an index to f, things are not in the right place. I want a true symbol that I can put in exponent. I should edit my question. –  Benoît Kloeckner Jun 4 '12 at 12:55
    
In fact, I realized that your answer needs only a bit of twiddling with \raisebox and \scalebox to fulfill all my demands. I guess the ratio between the quickness of your answer and the length of my acceptation is the largest I ever saw on this family of sites. –  Benoît Kloeckner Jul 11 '12 at 14:13
    
@BenoîtKloeckner Just today I got accepted an answer I gave on May 30, 2011. :) But the interval between question and answer in that case was longer: three hours. :) –  egreg Jul 11 '12 at 14:18

The following code introcudes \ehat that can be used only in exponents (!). Macro \mathchoice lets you use different code in different level of "exponent". Then we \raisebox the properly-sized hat to move it lower. It can be used as "low exponent" too.

enter image description here

\documentclass{article}
\begin{document}

\newcommand*{\ehat}{{\mathchoice{%
  \hbox{[do not use `ehat` in display style]}%
  }{%
  \hbox{[do not use `ehat` in text style]}%
  }{%
  \mbox{\raisebox{-0.75\height}{$\hat{\mkern4mu}$}}%
  }{%
  \mbox{\raisebox{-0.75\height}{$\scriptstyle\hat{\mkern4mu}$}}%
  }}}%

\[
e^\ehat h
\quad
e^2 h
\quad
f^{f^\ehat h} h
\quad
e_\ehat h
\]

\end{document}
share|improve this answer
    
This is in the right direction, but there is some issue with the height. First, I do not get the same result than you, the hat looks higher (even copy-pasting your code in a document containing nothing else); moreover, the height seems not to adapt to the height of the letter, so in particular $s^\ehat$ looks very weird. –  Benoît Kloeckner Jun 5 '12 at 13:26
    
I guess that then you'll have stuck with the egreg's solution –  tohecz Jun 5 '12 at 15:23
    
May I ask why you have to put it in an exponent? Because it is close to impossible to detect what was before some macro in TeX... –  tohecz Jun 5 '12 at 15:24
    
I do not have to, I want to. It is a notation that I think is clear and makes sense (it is a kind of antiderivative, so I want a notation close to $f'$). –  Benoît Kloeckner Jun 6 '12 at 13:36
    
I guess that a solution would be to design a hat as a letter in metafont (so that instead of detecting manually what is behind, one would let the exponentiation do the job), but I do not know how to do that. –  Benoît Kloeckner Jun 6 '12 at 13:37

The amsxtra package offers \sphat for a superscript hat, which works in sub- and superscripts, too. However, in the usual \textstyle, I'd say that it has a spacing problem: it protrudes to much to the right. So you'd have to manually add some \, or so. On the plus side, \sphat works together with subscripts.

superscript hat

\documentclass{article}
\usepackage{amsxtra}
\begin{document}
$f\sphat$, $a_{f\sphat}$ and $f\sphat_x$
\end{document}

There's also \sptilde for a superscript tilde and a few other superscript accents.

share|improve this answer
    
This is quite close to what I'd like, but I do have some spacing problems , and the hat is two large for my taste. Isn't there any mean to get the character in the usual hat alone (i.e. not the command that puts this character on top of the letter ?) –  Benoît Kloeckner Jul 11 '12 at 11:54
    
Moreover, I would like to be able to write $f^{\myhat\myhat}$ for a double antiderivative, with both hats on level. Sorry for having such demands... –  Benoît Kloeckner Jul 11 '12 at 11:56
    
@Benoît: Yes, I mentioned the spacing problem in my answer. I did see in the comments to the other answers that you wanted to be able to write f^{\myhat}, but that's not what amsxtra offers :-( About the mean to get the character in the usual hat alone: That's what egreg offers in his answer! I think tohecz has what you want; try adjusting the -0.75 to your needs. –  Hendrik Vogt Jul 11 '12 at 13:25
    
@Henry Vogt: in fact I did not realize that the only problems with egreg's answer, which were the baseline (I would like to have the symbol on level with the baseline, so that I can use it in a superscript) and the size (since I put in a superscript, I prefer it slightly larger), can both be solved using \raisebox and \scalebox. –  Benoît Kloeckner Jul 11 '12 at 14:11
\documentclass{article}
\usepackage{amsmath}
\def\Hat{\mkern-3mu\text{\textasciicircum}}
\begin{document}

$f\Hat f\Hat\Hat$

\end{document}

enter image description here

share|improve this answer

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.