[Tex/LaTex] Inline TikZ – vertical centering

inline()tikz-pgfvertical alignment

If I inline a bounded line segment like this:

the distance \tikz{ \draw [|-|] (0,0) -- (5ex,0); } overarching the activities

how can I make the line appear vertically centered on the line (automatically taking into account the line height).

Best Answer

You can directly tell where the baseline should meet the picture using the baseline option

\documentclass{article}
\usepackage{tikz}
\begin{document}
the distance \tikz[baseline=-0.5ex]{ \draw [|-|] (0,0) -- (5ex,0); } overarching the activities
\end{document}

enter image description here