# How to draw a vertical bar on top of a math symbol?

I can do $_\tau^{|}$ which renders:

What I don't like is:

1. The tau becomes under the baseline
2. I can't control the line's length

Can someone help me? Thanks!

Try with

$\stackrel{|}{\tau}$  base
$\stackrel{\tikz{\draw[black] (0,1) -- (0,0) ;}}{\tau}$


the second option with TikZ.

• Great! I wanted to be able to control the line's length, but I found that I can do \substack{|\\ |} and it's good enough. Thanks Jun 19, 2016 at 18:53
• @Mageek If you don't mind loading TikZ, with the last edit you should be able to do it quite at pleasure.
– c.p.
Jun 19, 2016 at 19:09

If the vertical bar should a kind of math accent, you can use the following idea:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\DeclareRobustCommand{\vbar}[1]{{\vbar@accent{#1}}}
\newcommand\vbar@accent[1]{%
\overset{%
\text{\smash[b]{\rule[-0.4ex]{0.4pt}{0.8ex}}}% <-- customize 0.8ex
}{#1}%
}
\makeatother

\begin{document}

$X+\vbar{\tau}_{\vbar{\tau}}$

\end{document}