So erstellen Sie eine 2x2-Matrixbox

So erstellen Sie eine 2x2-Matrixbox

Ich möchte eine 2x2-Matrixbox wie auf dem Bild erstellen. Haben Sie eine Idee, wie das geht?

Bildbeschreibung hier eingeben

Antwort1

Als Ausgangspunkt (mit etwas fortgeschrittenem Code) ...

\documentclass[margin=3mm]{standalone}
\usepackage{makecell}

\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
    {\multicolumn{#1}{c|}{#2}}

\begin{document}
{
\setlength\extrarowheight{2pt}
    \begin{tabular}{| *3{p{5em}|} }
    \cline{2-3}
\mcc{}      & \mcc[2]{\makecell{Events occurs in\\ 
                                the following 24 months}}   \\
    \cline{2-3}
\mcc{}      & \mcc{Crisis}  & \mcc{No crisis}               \\
    \hline
Signal      &   A           &   B                           \\
    \hline
No Signal   &   C           &   D                           \\
    \hline
    \end{tabular}
}
\end{document}

Einführende Texte zum Schreiben von Tabellen finden Sie im WEB, zum BeispielWiki: Tabellen.

Bildbeschreibung hier eingeben

Antwort2

Ein Vorschlag mit {NiceTabular}.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
{
\setlength{\extrarowheight}{2pt}
\begin{NiceTabular}{*3{p{5em}}}[corners,hvlines]
            & \Block{1-2}{Events occurs in\\ the following 24 months}   \\
            & \Block{}{Crisis}  & \Block{}{No crisis} \\
Signal      &   A           &   B                     \\
No Signal   &   C           &   D                     \\
\end{NiceTabular}
}
\end{document}

Ausgabe des obigen Codes

verwandte Informationen