Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical Supply Distributor100,000+ medical supplies. 48-hour critical dispatch.Ships from 8 regional U.S. hubs. Net-30 terms for verified institutional accounts.Shop lac.us CodeCASRAIlac.us

LaTeX Vertical Line: |, mid and Table Column Rules

How to type a LaTeX vertical line in text, math and tables: | vs mid vs textbar, double bars, bar sizing and evaluated-at notation.

Written and maintained by CASRAI Editorial Board

Last updated

In LaTeX, a vertical line is written differently depending on where it appears. In math mode, type | (and \| for a double line). In a table, put | in the column specification, as in \begin{tabular}{ |c|c|c| }. In running text, a bare | does not give a bar; use \textbar. This page gives one decision table for all four contexts, then the details for each.

What it is used for in research

Researchers meet the vertical line in four places: as a symbol in text, as a relation or absolute-value bar in equations, as a rule between columns in a results table, and as an “evaluated at” bar in calculus. LaTeX treats each context differently, so the same keystroke can be right in one place and wrong in another. For horizontal rules, see horizontal lines in LaTeX.

Which command to use, by context

Context What to type Result
Running text (text mode) \textbar A vertical bar. A bare | in text mode produces an em dash.
Math mode, single line | A vertical line
Math mode, double line \| A double vertical line
Math mode, as a relation \mid A vertical line whose spacing differs from plain |
Table column rule | inside the column spec, e.g. { |c|c|c| } A vertical line between columns
Table, double column rule || inside the column spec A double vertical line
Larger bar in math \big|, \Big|, \bigg|, \Bigg| Progressively taller single bars
Evaluated-at bar \left. … \right|_0^1 A bar that scales to the expression, with limits

The sources for each row are listed at the end of the page.

Where to run the code

These commands are standard LaTeX and work in any LaTeX editor or distribution. The examples follow the documentation published by Overleaf, an online LaTeX editor, so you can paste them into an Overleaf project and compile.

Step by step, by context

How do I write ‘|’ in LaTeX text?

Use \textbar. In text mode, typing | directly produces an em dash rather than a vertical bar, which surprises many people who expect the keyboard character to pass through.

  1. Write your sentence in normal text, for example Use the \textbar{} character to separate fields.
  2. Compile. The output contains a vertical bar.

How do I insert a vertical line in a LaTeX equation?

In math mode, | gives a vertical line and \| gives a double vertical line.

  1. Enter math mode and type the bars, for example $|x+y|$.
  2. For a double bar, use $\|x+y\|$.
  3. To make the bars taller, use \big|, \Big|, \bigg| or \Bigg| for single bars, and \big\|, \Big\|, \bigg\| or \Bigg\| for double bars.

Overleaf’s guide to brackets and parentheses adds a rule for automatic sizing: when you use \left and \right, both commands are mandatory, even if you only want one bracket. For other math layouts where delimiters matter, see matrices in LaTeX and aligned equations in LaTeX.

What is the difference between | and \mid?

Both draw a vertical line in math mode, but their spacing differs. The Wikibooks LaTeX mathematics page lists the delimiter as “| or \mid (difference in spacing)”, and Wikipedia notes that the spacing of the plain bar also differs from \mid and \parallel, which are relation operators.

For a bar between \left and \right that must resize with the expression, Wikibooks shows \middle|, for example P\left(A=2\middle|...\right).

How do I write ‘evaluated at’ with a vertical bar?

Wikibooks shows two forms. An underscore after a bar denotes evaluation: f(n) = n^5 + 4n^2 + 2 |_{n=17}. For a tall bar after a fraction, use a period as an invisible left delimiter: \left.\frac{x^3}{3}\right|_0^1. The \left. supplies the required opening delimiter without drawing anything, so the closing \right| scales to the fraction.

How do I add vertical lines between table columns?

Put | characters in the column specification, as the Overleaf Tables documentation shows. For example, \begin{tabular}{ |c|c|c| } gives three centred columns separated by vertical lines. Use || for a double vertical line.

  1. Start the table with a column specification that has | where you want a line: { |c|c|c| }.
  2. Add horizontal rules with \hline at the top and bottom, or \cline{i-j} for a partial rule.
  3. To repeat a column, *{3}{|l}| is equivalent to |l|l|l|.
  4. To draw a line on each side of a single merged cell, use \multicolumn with {|c|}.
  5. To change the line thickness, set \setlength{\arrayrulewidth}{0.5mm}.

The horizontal side of table rules is covered in horizontal lines in LaTeX.

Output and how to read it

After compiling, check each case against what you intended. A text-mode bar should be a vertical stroke, not a dash. A math-mode bar should match the height of what it encloses; if it looks too short beside a fraction, use the sizing commands or \left and \right. In a table, each | in the column specification becomes one line at that column boundary, and || becomes a double line.

Troubleshooting

  • An em dash appears instead of a bar: you typed | in text mode. Use \textbar.
  • The bar looks too small: use \big| through \Bigg|, or \left and \right, remembering that both of the pair are mandatory.
  • Spacing around the bar looks wrong: try \mid instead of |, or the reverse; their spacing differs.
  • You need a closing bar with no opening one: pair \right| with \left..

If you are also splitting a formula across lines, see new lines in LaTeX equations.

FAQ

How to write ‘|’ in LaTeX?

In math mode, type |. In text mode, type \textbar, because a bare | produces an em dash there. In a table column specification, | draws a vertical line between columns.

How do I insert a vertical line in LaTeX?

It depends on context: | or \| in math mode, | in a table column spec, \textbar in text. The decision table above lists each.

What is the ‘|’ called?

Wikipedia lists the names pipe, bar, vbar and “or”, and in logic it is the Sheffer stroke. Its Unicode name is VERTICAL LINE (U+007C).

How can you type a vertical line?

Type the | character, then use the context-specific form from the table above so it renders as a bar rather than an em dash or a mis-spaced symbol.

Sources

  • Overleaf, Tables (checked 2026-11-07): column specifications, ||, *{3}{|l}|, \multicolumn, \hline, \cline, \arrayrulewidth.
  • Overleaf, Brackets and Parentheses (checked 2026-11-07): pipes, double pipes, sizing commands, the \left/\right rule.
  • Wikipedia, Vertical bar (checked 2026-11-07): names, Unicode, \textbar, the text-mode em dash, spacing versus \mid and \parallel.
  • Wikibooks, LaTeX/Mathematics (checked 2026-11-07): | versus \mid, \middle, \left., evaluation bars.

Follow CASRAI

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

Ask CASRAI · free to try

Ask about LaTeX Vertical Line: |, mid and Table Column Rules

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 →