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 using mathpazo to format a document and have just become annoyed that a hat appears to be rendering too close to the letter it's decorating. I'd like to move the hat upwards, but am not sure how to go about doing it.

My LaTeX is just \hat{x}_{t+1}, which renders as:

rendered \hat{x}_{t+1}

Is there any way to change this?

share|improve this question

2 Answers 2

up vote 10 down vote accepted
\documentclass{article}
\usepackage{mathpazo}
\usepackage{amsmath}   %% come by habit ;)
\begin{document}
    \[
      \hat{x}_{t+1}
    \]
    \[
      \hat{\rule{0ex}{1.2ex}\mkern-3mu x}_{t+1}
    \]
\end{document}

enter image description here

share|improve this answer
    
Fantastic! This also introduced me to \rule{width}{height} as well as \mkernUNITS and mu units, none of which I'd used before. Thanks! –  lmjohns3 Apr 29 at 4:50

You could use a \vphantom{} which inserts a vertical height equal to the parameter provided but of zero width. So using \vphantom{f} will make the \hat behave as if the hat needs to be on top of an f:

enter image description here

To have more fine tuned control you can use a scaled parameter via \hat{\vphantom{\scalebox{1.1}{x}} x}:

enter image description here


The \vphantom{} trick is useful in other cases such as with \sqrt{x} \sqrt{y} (as below on the left) which looks odd but is better with a \sqrt{x\vphantom{y}} \sqrt{y} (on the right) where both the top and bottom of the \surd are now aligned:

enter image description here

Code:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
    \[
      \hat{\vphantom{f}x}_{t+1} \hat{f}_{t+1}
    \]
    or using \verb|\scalebox{}|
    \[
      \hat{x}_{t+1}
      \hat{\vphantom{\scalebox{1.1}{x}} x}_{t+1}
      \hat{\vphantom{\scalebox{1.2}{x}} x}_{t+1}
     \]
\end{document}
share|improve this answer
    
This is also a great answer, with an excellent explanation. Wish I could accept both. –  lmjohns3 Apr 29 at 16:11

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.