Math & Science ⇒ hat position over underlined letter
hat position over underlined letter
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?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
hat position over underlined letter
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}}
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
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: hat position over underlined letter
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.
- 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.
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.