Written and maintained by CASRAI Editorial Board
Last updated
To put a bar over a symbol or expression in LaTeX, use \overline{...} inside math mode, for example $\overline{x+y}$. This is the “overline LaTeX” command: it draws a horizontal line over everything inside the braces. For a bar over a single character, the accent command \bar{x} is the separate, narrower alternative. This guide shows when to use which, how the output looks, and what to check when the bar does not appear.
Who this is for: researchers and analysts typesetting sample means, complex conjugates, set complements or closures in a paper, thesis or problem set, who need the bar to render correctly the first time.
What an overline is used for in research
A bar over a symbol is notation by convention, not a single fixed meaning. Common research uses are a sample mean (x̄), a complex conjugate, a set complement and a topological closure. Because the meaning depends on the field, define the bar in your paper the first time you use it.
Install or access
\overline is documented in the LaTeX2e reference manual, so it needs no extra package in a standard LaTeX installation. You can compile locally with a TeX distribution such as TeX Live or MiKTeX, or in a browser editor such as Overleaf. Math mode delimiters are \(...\) or $...$ inline and \[...\] or the equation environment for display math (the equation* variant comes from the amsmath package).
Step by step: put a bar over text or math
- Open math mode. Write
$ ... $for inline math or\[ ... \]for a displayed line. - For a bar over one character, type
\bar{x}. The Wikibooks LaTeX mathematics chapter lists\bar{a}among its math accents. - For a bar spanning a group, type
\overline{, the expression, then}, as in\overline{x+y}. The same chapter lists\overline{aaa}as the bar that spans the whole group. - Compile. The line is drawn above everything between the braces.
Overline LaTeX versus bar: which to use
The LaTeX2e reference manual states that \overline “differs from the accent command \bar”. The accent is built for one character; the overline is built for a group. The table below applies that distinction to common research notation. The meaning of a bar is convention, so check your field’s usage.
| You want | Source input | Why this command |
|---|---|---|
| Bar over one letter, such as a sample mean | $\bar{x}$ |
\bar is a math accent for a single character. |
| Bar over several symbols | $\overline{x+y}$ |
\overline spans the whole group; the manual’s own example is \overline{x+y}. |
| Bar over a longer expression, such as a set complement | $\overline{A\cup B}$ |
A group needs \overline. See set operators in LaTeX for the symbols inside. |
| Line below instead of above | $\underline{x+y}$ |
\underline is the paired command in the same manual section. |
Overline over text (not math)
The manual describes \overline{math}, so the argument is math. To put a bar over a word, wrap it in math mode, for example $\overline{\mathrm{total}}$. For underlining ordinary text, the manual points to the ulem package, which also allows line breaking.
Output and how to read it
The compiled line sits above the argument and covers its full width: \overline{aaa} gives a bar over all three letters, while \bar{a} gives a short bar over one. Mixing the two conventions for the same kind of symbol in one document can look inconsistent, so pick one per symbol and keep it throughout. Other accents such as \widehat follow the same pattern; see LaTeX math signs for symbols and LaTeX vector notation for vectors.
Troubleshooting
- The bar is missing or LaTeX reports a math-mode error.
\overlinetakes math, so use it between$ ... $or in a display environment, not in plain running text. - The bar covers only part of what you wanted. Check the braces: the bar spans exactly the group inside
\overline{ }. - Older documents with fragile commands. According to the manual,
\overlineand its sibling commands have been robust since about 2019; before that they were fragile and needed\protectin moving arguments such as section titles. - Unknown command such as \overbar. The commands documented in the sources for this guide are
\overlineand\bar; use those.
Free ways to compile the example
| Option | Type | Source note |
|---|---|---|
| TeX Live | Local TeX distribution | The CTAN amsmath package page (read 2026-11-07) lists amsmath as part of TeX Live and MiKTeX. |
| MiKTeX | Local TeX distribution | Same CTAN page. |
| Overleaf free plan | Browser editor | Overleaf’s plans page (read 2026-08-29) shows a free plan with one collaborator and a basic compile timeout. |
Related reading: LaTeX mathbb for blackboard bold and crossing out terms in LaTeX.
FAQ
What is the difference between overline and bar in LaTeX?
\bar is a math accent for one character; \overline draws a line over a whole group. The LaTeX2e manual says \overline “differs from the accent command \bar”.
How do I write overline in LaTeX for a long expression?
Put the expression inside the braces in math mode: $\overline{x+y}$.
Can I use overline outside math mode?
The manual documents \overline{math}, so put the content in math mode. For underlining text, the manual points to the ulem package.
Sources
- Unofficial reference manual covering LaTeX2e, section “Over- or under math”, latexrefman, read 2026-11-07.
- Wikibooks, LaTeX/Mathematics, Accents, read 2026-11-07.
- LaTeX2e reference, Math accents, read 2026-11-07 (
\bar: “Math bar-over accent”). - Overleaf, Mathematical expressions, for math-mode delimiters.







