![插入段落,文本垂直居中 tikzpicture](https://linux22.com/image/411586/%E6%8F%92%E5%85%A5%E6%AE%B5%E8%90%BD%EF%BC%8C%E6%96%87%E6%9C%AC%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD%20tikzpicture.png)
答案1
人们通常希望将 的基线tikzpicture
置于 中心的正常大小节点的基线处tikzpicture
,否则上下空间将不对称。此处方可制成样式。
\documentclass{article}
\usepackage{tikz}
\tikzset{
op/.style = {shape=rectangle, rounded corners, draw=black, align=center,
fill=blue!30},base align tikzpicture/.style={execute at end picture={
\path (current bounding box.north) -- (current bounding box.south)
node[midway](Xphantom){\phantom{X}};},baseline={(Xphantom.base)}}
}
\begin{document}
Si A est l'arbre
\begin{tikzpicture}[base align tikzpicture]
\node [op] {'+'}
child { node {B} } child { node {C} };
\end{tikzpicture}, alors d\'erivee(A) est l'arbre
\end{document}
答案2
\documentclass{article}
\usepackage{tikz}
\tikzset{
op/.style = {box/.style = {draw, rounded corners, fill=blue!30},
level distance=9mm, sibling distance=9mm,
baseline = (current bounding box.center)}
}
\begin{document}
Si A est l'arbre
\begin{tikzpicture}[op]
\node [box] {'+'}
child { node {B} } child { node {C} };
\end{tikzpicture}
, alors dérivee(A) est l'arbre
\end{document}