Hello,
is it possible to align the hat (made with \hat) above y like it is (centered) over the x? Is this possible using a global option/adjustment?
Math & Science ⇒ hat position over underlined letter
hat position over underlined letter
Last edited by Montag on Wed Mar 02, 2011 11:43 am, edited 1 time in total.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
NEW: TikZ book now 40% off at Amazon.com for a short time.

hat position over underlined letter
I'm not sure if this is going to solve your problem, since you didn't give a Minimal Working Example.
My guess is that the line underneath the 'y' is done with \underline{y}. Then your code probably looked like:
Now this goes wrong: LaTeX centers the hat automatically above its argument. The argument here is \underline{y}, where the underline is wider than the y.
Solution: center it above the y and then define the underlining:
My guess is that the line underneath the 'y' is done with \underline{y}. Then your code probably looked like:
Code: Select all
\hat{\underline{y}}
Solution: center it above the y and then define the underlining:
Code: Select all
\underline{\hat{y}}
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
Follow howtoTeX on twitter
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
hat position over underlined letter
With respect to the line underneath both characters, the hat is centred. It optically looks like it's not because the »y« appears more slanted (we know it isn't). What you want is to shift it according to your personal thus subjective feeling. And this feeling seems to depend on the used font (keyword MWE). With the standard CM it looks OK. Nevertheless you can define a new command that does this job.Montag wrote:[…] is it possible to align the hat (made with \hat) above y like it is (centered) over the x? Is this possible using a global option/adjustment?
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\newcommand*{\xhat}[1]{#1\kern-0.35em\hat{\phantom{#1}}}
\begin{document}
$\hat{y}\xhat{y}$
\end{document}
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: hat position over underlined letter
Thank you both.
Frits' suggestion seems to work fine.
The new command by you (Thorsten) seems to be a little bit shifted to the right, either I underline first and the put that hat on it or vice versa. But then, I am next to not familiar with kerning properties/options of characters at all.
Frits' suggestion seems to work fine.
The new command by you (Thorsten) seems to be a little bit shifted to the right, either I underline first and the put that hat on it or vice versa. But then, I am next to not familiar with kerning properties/options of characters at all.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
hat position over underlined letter
You should be able to adjust \kern-0.35em according to your needs. It simply stands for some negative space. Just play around with it. Valid length units like »em« or »ex« should be familiar to you.Montag wrote:[…] But then, I am next to not familiar with kerning properties/options of characters at all.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
hat position over underlined letter
Ok, thank you ... now I got it, I think. The em value "was" (-> is) directly connected to the font metrics, thus font-dependent and that's why the spacing command you posted has to be changed.localghost wrote:You should be able to adjust \kern-0.35em to your needs. It simply stands for some negative space. Just play around with it. Valid length units like »em« or »ex« should be familiar to you.Montag wrote:[…] But then, I am next to not familiar with kerning properties/options of characters at all.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1