我正在尝试使用 在表格内创建一个表格tabularray
。但是,内表的缩放比例与外部表的列宽不匹配。如何使内表的宽度与外表的宽度相匹配?
以下是我得到的结果:
妇女权利委员会:
\documentclass{article}
\usepackage{tabularray}
\usepackage{fontawesome}
\newcommand{\MyCommand}[2]{\begin{tblr}{c l|} \faCalendar & #1 \\ \faMapMarker & #2 \end{tblr}}
\begin{document}
\begin{tblr}{
width=1.1\textwidth,
colspec={@{}| X[l,2] | X[l,4] | X[l,3] | @{}},
column{1} = {font=\bfseries},
rowsep=0.5\baselineskip
}
A & B & \MyCommand{some text that my go beyond the table}{the other line} \\
C & D & \MyCommand{Some more text}{the other line}
\end{tblr}
\end{document}
另外,我希望能够使用类似的宏,MyCommand
这样我就不必在每一行都手动创建一个表。
答案1
将内部表格的宽度设置为\linewidth
,该宽度取其周围单元格的值
\documentclass{article}
\usepackage{tabularray}
\usepackage{fontawesome}
\usepackage{showframe} % Draws frames around a page
\renewcommand{\ShowFrameLinethickness}{0.2pt}
\renewcommand{\ShowFrameColor}{\color{black!20!yellow}}
\newcommand{\MyCommand}[2]{%
\begin{tblr}{
width=\linewidth,
colspec={X[1,c] X[10]},
}
\faCalendar & #1 \\
\faMapMarker & #2
\end{tblr}}
\begin{document}
\noindent%
\begin{tblr}{
width=1\textwidth,
colspec={@{}| X[l,1] | X[l,2] | X[l,4] | @{}},
column{1} = {font=\bfseries},
rowsep=0.5\baselineskip
}
A & B & \MyCommand{some text that my go beyond the table}{the other line} \\
C & D & \MyCommand{Some more text}{the other line}
\end{tblr}
\end{document}