0

Im currently struggling with a table i latex. I want a table like this:

enter image description here

I have found a way to make a normal table like {|c|c|} and then make the title with multicolumn.

The real struggle I have is in row 2 and 4. When using multicolumn I cannot figure out how to split the text inside the box.

And how do I move the vertical line splitting the boxes from row 2 to 4?

Hope you can help!

2
  • 2
    Start with a table which has 4 columns. Commented Feb 6, 2023 at 10:21
  • Any news? Does answer with comment fulfil your expectation?
    – Zarko
    Commented Mar 8, 2023 at 13:11

2 Answers 2

1

enter image description here

As is suggested in @samcarter_is_at_topanswers.xyz comment:

\documentclass{article}
\usepackage{tabularray}

\begin{document}
    \begin{table}[ht]
\begin{tblr}{width=88mm,
             hlines, vlines,
             colspec = { *{4}{X[l]} },
               hspan = minimal
             }
\SetCell[c=4]{c}    some text
        &       &       &               \\
\SetCell[c=2]{} some longer text in two lines
        &       &   \SetCell[c=2]{} some longer text in two lines
                        &               \\
\SetCell[c=4]{c}    some text     
        &       &       &               \\
\SetCell[c=3]{} some longer text in one line
        &       &       &   some text   \\
\end{tblr}
    \end{table}
\end{document}
2
  • Thanks! But now with the tabularray, how do I color some of the cells?
    – Emilie
    Commented Feb 6, 2023 at 19:32
  • @Emilie, simple. In preamble load xcolor package and than selected cells color by \SetCell{fg=red, bg=yellow} <cell text>. See tex.stackexchange.com/questions/625246, tex.stackexchange.com/questions/629708 and of course, package documentation where is coloring thoroughly described with lot of examples. BTW, in question you not mentioned this problem...
    – Zarko
    Commented Feb 6, 2023 at 19:39
0

Here is a way to create that table with {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{NiceTabular}[width=88mm,hvlines]{X[2]X[1]X[1]}
\Block{1-3}{some text} \\
\Block[l,v-center]{1-1}{some longer text in two lines}
& \Block[l,v-center]{1-2}{some longer text in two\\ lines in the tabular}& \\
\Block{1-3}{some text} \\
\Block[l]{1-2}{some longer text in one line} & & some text 
\end{NiceTabular}

\end{document}

You need several compilations.

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .