I want to put a vertical line among some words in order to separate them, for example I want this:

Website | Email | Address

But I cannot produce these vertical line perfectly. What should I do? (I do not want to use tabular environment)

  • 3
    You can use $\vert$, $\mid$, or $|$. If you are using T1 encoding, you can use | directly, but I don't recommend it, because if you change the font encoding back to OT1, it will come out wrong. Commented Nov 7, 2017 at 11:13
  • What's wrong with |?
    – Ignasi
    Commented Nov 7, 2017 at 11:14
  • 1
    If you need something wider/longer, you could use \kern1pt\rule[-\dp\strutbox]{.6pt}{\baselineskip}\kern1pt set up as a macro. Commented Nov 7, 2017 at 11:16
  • Thank you guys, the problem with '|' was about making horizontal line in the pdf file
    – Ehsan
    Commented Nov 7, 2017 at 11:20
  • 2
    As I note in my answer, the horizontal line (aka em dash) occurs when you are using the default OT1 font encoding and use a | in non-math mode. Commented Nov 7, 2017 at 11:27

2 Answers 2


Note that | does not work with default OT1 font encoding (it comes out as an em dash). Comment out my \usepackage[T1]{fontenc}, recompile, and see.

The most versatile would be \mybar, which you define as a \rule of specified dimensions in the preamble.

The math versions include \vert, |, and \mid.

Lastly, variants can be applied to \vert and | in the form of \big, \bigg, \Big, and \Bigg; however, this will mess up line spacing when used inline.

\mybar Email%

enter image description here

For comparison, here is using a few "big" variants, as well as OT1 encoding.

\mybar Email%

enter image description here

  • Is it possible to have the vertical bar always at the same place? I use your solution, but if there is a "wider" number like for example "100" is wider than "1", the vertical bar moves to the left or the right next to the number. Can I set a permanent width to either of the sides of the of the bar
    – Bolle
    Commented Feb 27, 2023 at 13:23
  • @Bolle My guess is that this issue is that you have a stray space unaccounted for in your input, rather than an issue with \mybar. Commented Feb 27, 2023 at 14:23

I have a question to the provided solution:


How can I colorize the bar? I tried this, below it doesn't work.


call with:

\mybar[red] Foo
\mybar[green] Bar 
  • 1
    This is a question, not an answer. Commented Aug 11, 2023 at 6:56
  • With an optional parameter, you need to provide a default value. Note also the presence of \begingroup and \endgroup to keep the color changes local: \newcommand\mybar[1][black]{\begingroup\color{#1}\kern1pt\rule[-\dp\strutbox]{1pt}{\baselineskip}\kern1pt\endgroup}
    – user94293
    Commented Aug 11, 2023 at 7:01
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review
    – cabohah
    Commented Aug 11, 2023 at 7:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .