Skip to main content
v2026.11,858 entries · CC-BY 4.0

LaTeX Overline: How to Put a Bar Over Text or Math

Use overline{…} in math mode to bar a group and bar{x} for one character; includes a use table for means, conjugates and complements.

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

  1. Open math mode. Write $ ... $ for inline math or \[ ... \] for a displayed line.
  2. For a bar over one character, type \bar{x}. The Wikibooks LaTeX mathematics chapter lists \bar{a} among its math accents.
  3. 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.
  4. 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. \overline takes 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, \overline and its sibling commands have been robust since about 2019; before that they were fragile and needed \protect in moving arguments such as section titles.
  • Unknown command such as \overbar. The commands documented in the sources for this guide are \overline and \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

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about LaTeX Overline: How to Put a Bar Over Text or Math

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →