是否有一个包可以将单词垂直分布在 LaTeX 表格单元格中?
\documentclass{article}
\usepackage{tabularray,tabularx}
\UseTblrLibrary{booktabs, siunitx}
\begin{document}
\begin{table}
\begin{talltblr}[
caption={table}
]{colspec={X[c] X[c]}
}
\SetCell[r=2]{m}{{{H e l l o}}}&{{{1\\2\\3\\4\\5\\6\\7}}}\\
&{{{8\\9}}}
\end{talltblr}
\begin{talltblr}[
caption={table}
]{colspec={X[c] X[c]}
}
\SetCell[r=2]{m}{{{H\\e\\l\\l\\o}}}&{{{1\\2\\3\\4\\5\\6\\7}}}\\
&{{{8\\9}}}
\end{talltblr}
\end{table}
\end{document}
在第二个表格中,Hello
不是垂直分布的。那么如何让它在那个单元格中垂直分布呢?
答案1
我不确定我是否回答了这个问题。使用 tikzpicture...
\documentclass{article}
\usepackage{tabularray}
\usepackage{tikz}
\usetikzlibrary {positioning}
\begin{document}
\begin{tblr}{}
\SetCell[r=2]{m}{%
\begin{tikzpicture}[baseline=(current bounding box.center),inner sep=0pt, outer sep=0pt,node distance=1ex]
\node (A) {H};
\node (B) [below=of A] {e};
\node (C) [below=of B] {l};
\node (D) [below=of C] {l};
\node (E) [below=of D] {o};
\end{tikzpicture}}
&{1\\2\\3\\4\\5\\6\\7}\\
&{8\\9}
\end{tblr}
\end{document}
评论后更新,我不是 expl3 方面的专家。
距离 0pt 的 tikz 框的评估
距离 0pt 的 tblr 框的评估
tikz 框中的距离计算和修改
\documentclass{article} \usepackage{tabularray} \usepackage{tikz} \usetikzlibrary {positioning} \begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%% \ExplSyntaxOn \dim_new:N \distance \dim_set:Nn \distance {0pt} \ExplSyntaxOff \newcommand{\mytikz}{% \begin{tikzpicture}[baseline=(current bounding box.center),inner sep=0pt, outer sep=0pt,node distance=\distance] \node (A) {H}; \node (B) [below=of A] {e}; \node (C) [below=of B] {l}; \node (D) [below=of C] {l}; \node (E) [below=of D] {o}; \end{tikzpicture}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\mytblr}{ %\begin{tblr}[b]{hlines}% \begin{tblr}[b]{} \SetCell[r=2]{m}{% \mytikz } &{1\\2\\3\\4\\5\\6\\7}\\ &{8\\9} \end{tblr}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ExplSyntaxOn \vbox_set:Nn \l_tmpa_box { \mytblr } \vbox_set:Nn \l_tmpb_box { \mytikz } The~ height~ of~ \verb|\l_tmpa_box|~ is:~ \dim_use:N \box_ht_plus_dp:N \l_tmpa_box \par The~ height~ of~ \verb|\l_tmpb_box|~ is:~ \dim_use:N \box_ht_plus_dp:N \l_tmpb_box \par \dim_set:Nn \distance { \fp_to_decimal:n {(\dim_use:N \box_ht_plus_dp:N \l_tmpa_box-\dim_use:N \box_ht_plus_dp:N \l_tmpb_box)/5}pt} % \rule{4pt}{\dim_use:N \box_ht_plus_dp:N \l_tmpa_box} \vspace{-\dim_use:N \box_ht_plus_dp:N \l_tmpa_box}\mytblr \ExplSyntaxOff \mytblr \end{document}