Text FormattingDouble hat looks ugly

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

Double hat looks ugly

Post by nextdrinkplease »

Dear friends,

I have a LaTeX question for your amusement. :D

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 :shock: .

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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

Double hat looks ugly

Post by frabjous »

Best I could come up with is the following:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}
\begin{document}
$\hat{\vphantom{\rule{1pt}{5.5pt}}\smash{\hat{x}}}$
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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
hathatx.png (500 Bytes) Viewed 13506 times
nextdrinkplease
Posts: 3
Joined: Fri Jan 14, 2011 7:52 pm

Re: Double hat looks ugly

Post by nextdrinkplease »

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

if i understand well, vphantom raises and lowers one of the two hats (the inner one)...brilliant!
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Double hat looks ugly

Post by frabjous »

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.
nextdrinkplease
Posts: 3
Joined: Fri Jan 14, 2011 7:52 pm

Re: Double hat looks ugly

Post by nextdrinkplease »

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


Thanks a lot!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Double hat looks ugly

Post by localghost »

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
Post Reply