如果我内联一个这样的有界线段:
the distance \tikz{ \draw [|-|] (0,0) -- (5ex,0); } overarching the activities
我怎样才能使线条垂直居中显示(自动考虑线条高度)。
答案1
baseline
您可以使用选项直接告诉基线应该在哪里与图片相交
\documentclass{article}
\usepackage{tikz}
\begin{document}
the distance \tikz[baseline=-0.5ex]{ \draw [|-|] (0,0) -- (5ex,0); } overarching the activities
\end{document}
答案2
当我想要插入一个小的内联图时,percusse 和 Claudio 的答案都不起作用。相反马丁的建议做\raisebox
了工作。
例子
代码
\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}