## LaTeX forum ⇒ Text Formatting ⇒ Double hat looks ugly Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Posts: 3
Joined: Fri Jan 14, 2011 7:52 pm

### Double hat looks ugly

Dear friends,

I have a LaTeX question for your amusement.

In maths mode, I want to have a symbol with two hats over it. I have obviously tried using (e.g.) $\hat{\hat{U}}$ but this looks rather ugly: the vertical separation between the two hats is too wide .

Any clever idea on the topic? I am a bit desperate because I tried everything I could think of...

Any help is greatly appreciated,
Cheers
Next

For your information: I am using the document class "elsarticle.cls" and I have a fairly recent version of TeXLive (running on Mac OS X 10.5.8).
Last edited by cgnieder on Fri Oct 19, 2012 11:59 pm, edited 1 time in total.

LaTeXguide.org • LaTeX-Cookbook.net

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

### Double hat looks ugly  Topic is solved

Best I could come up with is the following:

\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}
\begin{document}

$\hat{\vphantom{\rule{1pt}{5.5pt}}\smash{\hat{x}}}$
\end{document}



The smash makes it ignore the height of the inner x with a hat. Instead, it uses the vertical height of the "phantom" rule which isn't printed, so you can change how heigh the outer hat does by changing the second parameter to the \rule command. Adjust to taste.

(Note, you probably need the accents package for this to work at all, though I'm not sure why.)

hathatx.png (500 Bytes) Viewed 9110 times

Posts: 3
Joined: Fri Jan 14, 2011 7:52 pm

### Re: Double hat looks ugly

Thank you so much, this is exactly what i needed! i will try it out tomorrow and let you know how it goes, ok?

if i understand well, vphantom raises and lowers one of the two hats (the inner one)...brilliant!

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

### Double hat looks ugly

What \vphantom{...} does is trick LaTeX into thinking that the current box has a height of the contents of {...} even without printing {...}. So in this case, the upper/outer hat is placed over a box which is treated as having the height of the non-printing rule here.

I haven't made any changes to the height of the inner/lower hat.
Last edited by cgnieder on Sat Oct 20, 2012 12:00 am, edited 1 time in total.

Posts: 3
Joined: Fri Jan 14, 2011 7:52 pm

### Re: Double hat looks ugly

I checked and it works fine, thanks a lot. It does need the accents package, just as you said.

Thanks a lot!

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

### Double hat looks ugly

nextdrinkplease wrote:I checked and it works fine, […]

Then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting).

Best regards and welcome to the board
Thorsten
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1