Hat in LaTeX (\hat{x})
- LaTeX command
\hat{x}- Package
- No package needed: built into LaTeX
- Mode
- Math mode only
Where it is used
Places a small circumflex over one character, marking estimators, unit vectors or Fourier transforms.
Statisticians write \hat{\theta} for an estimator of \theta and \hat{y} for fitted values in regression, physicists use \hat{x} or \hat{\mathbf{n}} for unit vectors and quantum operators, and analysts write \hat{f} for the Fourier transform. The accent has a fixed width, so it only looks right over a single symbol; for several letters switch to \widehat{xy}. Over an i or j, use the dotless forms \imath and \jmath so the hat does not sit on top of a dot. In running text outside math mode the equivalent circumflex accent is \^{o}, not \hat.
Also listed under: Linear Algebra
Minimal compilable example
Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.
\documentclass{article}
\begin{document}
Hat: $\hat{x}$
\[ \hat{\beta} = (X^\top X)^{-1} X^\top y \]
\end{document}Related symbols
- Wide Hat
\widehat{xyz} - Tilde
\tilde{x} - Wide Tilde
\widetilde{xyz} - Dot
\dot{x} - Double Dot
\ddot{x} - Triple Dot
\dddot{x}
Frequently asked questions
- How do I write Hat in LaTeX?
- Type \hat{x} in math mode, for example $\hat{\beta} = (X^\top X)^{-1} X^\top y$. It works in plain LaTeX without loading any package.
- Which package do I need for \hat{x}?
- None. \hat{x} is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
- Can I use \hat{x} in text mode, or only in math mode?
- Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\hat{x}$ in running text.
Best AI LaTeX Editor, Overleaf Alternative
Octree helps researchers from 15+ universities write research papers faster using AI
- Generate beautiful TikZ diagrams using AI
- Upload image and convert it to LaTeX seamlessly
- Get instant assistance with writing and formatting research papers