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'm trying to typeset a symbol with two hat accents (useful for denoting superoperators in quantum mechanics, for instance), but \hat{\hat{L}} produces too much space between the hats. I found one approach on a LaTeX forum that seems to work, but it requires manual adjustment for each letter that I might want to typeset. If anyone has any suggestions, I'd appreciate it. Thanks!

share|improve this question
1  
I thinks it's acceptable to use amsmath and \hat{\hat{L}} directly. It is also used in manual of amsmath. –  Leo Liu Feb 7 '11 at 18:24

1 Answer 1

up vote 14 down vote accepted

Well, I wrote that suggestion at LaTeX Community, but there I assumed the person wanted fine-grained control. If you don't, then maybe something like this would be more suitable? You may need to tweak the -0.35ex to your liking, though not separately for each character.

How about this?

\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}
\newlength{\dhatheight}
\newcommand{\doublehat}[1]{%
    \settoheight{\dhatheight}{\ensuremath{\hat{#1}}}%
    \addtolength{\dhatheight}{-0.35ex}%
    \hat{\vphantom{\rule{1pt}{\dhatheight}}%
    \smash{\hat{#1}}}}
\begin{document}

$\doublehat{x} \doublehat{L} \doublehat{\prod}$
\end{document}

enter image description here

share|improve this answer
    
That worked beautifully, thank you! One last question, though: would using \mathchoice be a reasonable way of making your code work in a super/subscript context? Once again, thanks for your help! –  Chris Granade Feb 7 '11 at 23:58
    
Hmm. I hadn't thought of sub/superscripts. Yeah, \mathchoice could probably work. Do you need help or do you think you can work it out on your own? –  frabjous Feb 8 '11 at 0:07
    
I got it. It's not all that elegant, as I'm not used to the intricacies of LaTeX macro writing yet, but it does typeset superscript double-hats quite nicely. pastebin.com/XctVhueR –  Chris Granade Feb 8 '11 at 0:32
    
The accents package is needed since plain TeX yields good horizontal alignment of the accent only for single characters; amsmath has some handling of double accents, but only the accents package is able to handle the correct positioning of the \hat over your more complicated construction. –  Hendrik Vogt Feb 8 '11 at 11:14

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.