Bar in LaTeX (\bar{x})

xˉ\bar{x}
LaTeX command
\bar{x}
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Sets a short horizontal bar over one symbol, typically for a sample mean or a complex conjugate.

Statistics uses \bar{x} for the sample mean, (1/n)\sum x_i; complex analysis writes \bar{z} for the conjugate; and \bar{A} may denote the closure of a set. The bar has a fixed width roughly that of one letter, so \bar{xy} looks wrong: use \overline{xy} to span several symbols, which is also the usual choice for conjugating an expression such as \overline{z + w}. In text, the macron accent is \={a}, not \bar. Bold vectors take it fine: \bar{\mathbf{v}}.

Also listed under: الاحتمالات والإحصاء

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

xˉ=1n∑i=1nxi\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i
\documentclass{article}
\begin{document}
Bar: $\bar{x}$

\[ \bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i \]
\end{document}

Related symbols

All التشكيل والمعدّلات →

Frequently asked questions

How do I write Bar in LaTeX?
Type \bar{x} in math mode, for example $\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i$. It works in plain LaTeX without loading any package.
Which package do I need for \bar{x}?
None. \bar{x} is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use \bar{x} in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\bar{x}$ in running text.
Math poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf

يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي

  • أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
  • ارفع صورة وحولها إلى LaTeX بسلاسة
  • احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث