Tabularray inside tabularray (table inside table, scaling)

macrostablestabularray

I am trying to make a table inside a table using tabularray. However, the scaling of the inner table does not match the column width of the outer table. How do I get the width of the inner table to match that of the outer table?

Here is what I got:

enter image description here

The MWE:

\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}

Also, I would like to be able to use a macro like MyCommand so that I don't have to create a table manually at every row I make.

Best Answer

Set the width of an inner table to \linewidth, which takes the value of its surrounding cell

enter image description here

\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}
Related Question