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).
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).
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}

Neither percusse's nor Claudio's answer worked for me when I wanted to insert a small inline graph. Instead Martin's suggestion of \raisebox did work.
\documentclass{article}
\usepackage{pgfplots} %for drawing of graphs
\pgfplotsset{compat=newest}
\setlength{\parindent}{0pt}
\begin{document}
The original one
\frame{
\begin{tikzpicture}
\begin{axis}[width=10 ex, height = 3 ex,
scale only axis, hide axis]
\addplot[black] {rand};
\end{axis};
\end{tikzpicture}}
is too high.
And percusse's \verb|[baseline=-0.5 ex]|
\frame{
\begin{tikzpicture}[baseline=-0.5ex]
\begin{axis}[width=10 ex, height = 3 ex,
scale only axis, hide axis]
\addplot[black] {rand};
\end{axis};
\end{tikzpicture}}
does not work, it only shifts
\frame{
\begin{tikzpicture}
\begin{axis}[width=10 ex, height = 3 ex,
scale only axis, hide axis]
\addplot[black] {rand};
\end{axis};
\end{tikzpicture}}
the graph upwards a little.
\verb|\raisebox{-.5 ex}|
\raisebox{-.5 ex}{\frame{
\begin{tikzpicture}
\begin{axis}[
width=10 ex, height = 3 ex, scale only axis,
hide axis,
]
\addplot[black] {rand};
\end{axis};
\end{tikzpicture}}}
does work in this case, but I don't know why.
\end{document}
baseline to be wherever you want.
– percusse
Sep 08 '16 at 16:32
3 ex the height that won't mess with the interline? Also, to answer your question, you wanted to push the baseline 1 ex down (positive value, not negative), not just 0.5 ex (you got the amount and sign wrong in your reply) since the total height is 3 ex and you want it centred at mid x's height, which is 0.5 ex.
– Atcold
Sep 29 '22 at 16:58