Table compliquée avec slashbox multirows et multicolonnes

Oct 14 2020

J'essaye de faire un tableau assez compliqué. La complexité de mon tableau est que je veux utiliser un slashboxqui devrait être à la fois multicolet multirow. Je veux faire ça:

Toutes mes tentatives jusqu'à présent ont échoué. Toute aide ou conseil serait apprécié, merci d'avance.

Réponses

2 Roland Oct 14 2020 at 06:18

Comme ça:

\documentclass{article}
\usepackage{slashbox}
\usepackage{multirow}

\begin{document}
    
\begin{table}[]

    \begin{tabular}{|c|c|c|c|c|c|}
        \hline

        \multicolumn{2}{|c|}{\multirow{2}{*}{\backslashbox{B}{9}}} & \multicolumn{2}{c|}{J} & \multicolumn{2}{c|}{M} \\ \cline{3-6} 
        \multicolumn{2}{|c|}{}                   & K          & L         & M          & O         \\ \hline
        \multirow{2}{*}{A}          & B          &            &           &            &           \\ \cline{2-6} 
        & C          &            &           &            &           \\ \hline
        \multirow{2}{*}{O}          & E          &            &           &            &           \\ \cline{2-6} 
        & F          &            &           &            &           \\ \hline
    \end{tabular}
\end{table}

    
\end{document} 

2 jsbibra Oct 14 2020 at 07:13

Un exemple similaire avec l'excellent nicematrixpackage

\documentclass{article}
\usepackage{nicematrix}
\usepackage{makecell}

\begin{document}

\begin{NiceTabular}{wC{5mm}cccc}[hvlines-except-corners]
 & \;\diagbox{A}{B} & \makecell{C \\ D} & \makecell{ E \\ F} & \makecell{ G \\ longer} \\
\Block{4-1}{H1} & I & text 1    &      & text \\
                & J & text 2    &      & text \\
                & K & text      &      & other text \\
                & L & text      &      & text \\
\Block{4-1}{H2} & M & text      & smth & text \\
                & N & text      &      & text \\
                & O & text      &      & text \\
                & P & text text &      & text \\
\end{NiceTabular}

\end{document}