我有一张桌子,里面有 4 棵树,如下所示。
我希望第四列的树向上移动,与顶部的距离与其他树相匹配。
我的 MWE 如下。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{tikz-qtree}
\usepackage[shortlabels, inline]{enumitem}
\setitemize{noitemsep,topsep=0pt,parsep=0pt,partopsep=0ptm, nolistsep, nosep}
\begin{document}
\begin{table}[!]
\small
\begin{flushleft}
\begin{tabular}{|c|c|c|c|}
\hline
descendant & ancestor & (g)\_nibling & sibling
\\
\hline
\begin{tikzpicture}[scale=.8]
\Tree [.person [.... [.adjective ] ] ] ]
\end{tikzpicture} &
\begin{tikzpicture}[scale=.8]
\Tree [.adjective [.... [.person ] ] ] ]
\end{tikzpicture} &
\begin{tikzpicture}[scale=.8]
\Tree [.parent [.... [.adjective ] ] [.person ] ]
\end{tikzpicture} &
\begin{tikzpicture}[scale=.8]
\Tree [.parent [.adjective ] [.person ] ]
\end{tikzpicture}
\\
\hline
\end{tabular}
\end{flushleft}
\end{table}
\end{document}
答案1
一个选项可能是baseline
为所有人选择一个类似的tikzpictures
。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{tikz-qtree}
\usepackage[shortlabels, inline]{enumitem}
\setitemize{noitemsep,topsep=0pt,parsep=0pt,partopsep=0ptm, nolistsep, nosep}
\begin{document}
\begin{table}[!]
\small
\begin{flushleft}
\begin{tabular}{|c|c|c|c|}
\hline
descendant & ancestor & (g)\_nibling & sibling
\\
\hline
\begin{tikzpicture}[baseline=(current bounding box.north),scale=.8]
\Tree [.person [.... [.adjective ] ] ] ]
\end{tikzpicture} &
\begin{tikzpicture}[baseline=(current bounding box.north),scale=.8]
\Tree [.adjective [.... [.person ] ] ] ]
\end{tikzpicture} &
\begin{tikzpicture}[baseline=(current bounding box.north),scale=.8]
\Tree [.parent [.... [.adjective ] ] [.person ] ]
\end{tikzpicture} &
\begin{tikzpicture}[baseline=(current bounding box.north), scale=.8]
\Tree [.parent [.adjective ] [.person ] ]
\end{tikzpicture}
\\
\hline
\end{tabular}
\end{flushleft}
\end{table}
\end{document}
更新:
对于每个顶部节点具有不同高度和深度的情况,最好使用顶部节点的基线作为参考。但这种情况意味着将.label
语法更改为.\node(name){label};
。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{tikz-qtree}
\usepackage{array}
\usepackage[shortlabels, inline]{enumitem}
\setitemize{noitemsep,topsep=0pt,parsep=0pt,partopsep=0ptm, nolistsep, nosep}
\begin{document}
\begin{table}[!]
\small
\begin{flushleft}
\begin{tabular}{|c|c|c|c|}
\hline
descendant & ancestor & (g)\_nibling & sibling
\\
\hline
\begin{tikzpicture}[baseline=(top.base), scale=.8]
\Tree [.\node(top){person}; [.... [.adjective ] ] ] ]
\end{tikzpicture} &
\begin{tikzpicture}[baseline=(top.base), scale=.8]
\Tree [.\node(top){adjective}; [.... [.person ] ] ] ]
\end{tikzpicture} &
\begin{tikzpicture}[baseline=(top.base), scale=.8]
\Tree [.\node(top){parent}; [.... [.adjective ] ] [.person ] ]
\end{tikzpicture} &
\begin{tikzpicture}[baseline=(top.base), scale=.8]
\Tree [.\node(top){parent}; [.adjective ] [.person ] ]
\end{tikzpicture}
\\
\hline
\end{tabular}
\end{flushleft}
\end{table}
\end{document}