我目前正在创建一个表格来解释我在 tikz 流程图中使用的不同节点。但是无论我如何尝试,所包含的 tikz 节点后的列都会垂直错位。
\begin{center}
\begin{tblr}{
colspec = {c l},
column{1} = {halign=c, valign=t},
column{2} = {8cm, halign=l, valign=t},
hlines = {1pt, black, solid},
}
\tikz{\node[circle, draw=black] (n) {Circle};} & Text \\
\end{tblr}
\end{center}
正如你在上图中所看到的,尽管我设置了,但文本肯定没有与单元格的顶部对齐column{2}={8cm, halign=l, valign=t}
感谢您的帮助;)
答案1
您可以使用baseline=...
tikz 的选项来更改 tikz 图片的对齐方式:
\documentclass{article}
\usepackage{tabularray}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tblr}{
colspec = {c l},
column{1} = {halign=c, valign=t},
column{2} = {8cm, halign=l, valign=t},
hlines = {1pt, black, solid},
}
\tikz[baseline=(n.base)]{\node[circle, draw=black] (n) {Circle};} & Text \\
\end{tblr}
\end{center}
\end{document}
或者北对齐:
\documentclass{article}
\usepackage{tabularray}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tblr}{
colspec = {c l},
column{1} = {halign=c, valign=t},
column{2} = {8cm, halign=l, valign=t},
hlines = {1pt, black, solid},
}
\raisebox{\baselineskip}{\tikz[baseline=(n.north)]{\node[circle, draw=black] (n) {Circle};}} & Text \\
\end{tblr}
\end{center}
\end{document}