1

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. – Steven B. Segletes Nov 7 '17 at 11:13
  • What's wrong with |? – Ignasi Nov 7 '17 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. – Steven B. Segletes Nov 7 '17 at 11:16
  • Thank you guys, the problem with '|' was about making horizontal line in the pdf file – Ehsan Nov 7 '17 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. – Steven B. Segletes Nov 7 '17 at 11:27
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.

\documentclass{article}
\usepackage[T1]{fontenc}
\newcommand\mybar{\kern1pt\rule[-\dp\strutbox]{.8pt}{\baselineskip}\kern1pt}
\begin{document}
Website%
$\vert$Email%
$\mid$Email%
$|$Email%
\mybar Email%
|Email
\end{document}

enter image description here

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

\documentclass{article}
%\usepackage[T1]{fontenc}
\newcommand\mybar{\kern1pt\rule[-\dp\strutbox]{1pt}{\baselineskip}\kern1pt}
\begin{document}
Website%
$\bigg\vert$Email%
$\mid$Email%
$\Big|$Email%
\mybar Email%
|Email
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.