Search code examples
latex

Keep first row with two columns, the rest single columns wide with wrap for words


I am trying to, keep two columns at the top row, and make the rest single column with automatic wide expansion. But, I don't know how to do it. I read in the documentation, but was too much details for me to comprehend.

Code:

\documentclass[a4paper,11pt]{article}

\usepackage{tabularx}
\usepackage{tabularray}
\usepackage{float}

\begin{document}
\begin{table}[ht]
    \begin{tblr}{width=\textwidth,
            colspec={X[l]  X[r]},
            hline{1,3} = {solid},
        }
        \text{Lorem Ipsum} & \text{Ipsum Lorem}\\
        It is easy with "tabularray" package to set row fonts. And you can change the environment from "tblr" to "longtblr" to get a long table. \\
    \end{tblr}
\end{table}
\end{document}

Current output:

enter image description here

Desired output:

enter image description here


Solution

  • You can use \SetCell to merge multiple cells:

    \documentclass[a4paper,11pt]{article}
    
    \usepackage{tabularray}
    
    \begin{document}
    \begin{table}[ht]
        \begin{tblr}{width=\textwidth,
                colspec={X[l]  X[r]},
                hline{1,3} = {solid},
                cell{2-Z}{1} = {halign=j,wd=\linewidth-12pt}
            }
            \textit{Lorem Ipsum} & \textit{Ipsum Lorem}\\
            \SetCell[c=2]{} It is easy with "tabularray" package to set row fonts. And you can change the environment from "tblr" to "longtblr" to get a long table. &\\
            \SetCell[c=2]{} It is easy with "tabularray" package to set row fonts. And you can change the environment from "tblr" to "longtblr" to get a long table. &\\
        \end{tblr}
    \end{table}
    \end{document}
    

    enter image description here