Help with complicated table

excel2latextables

I'm trying to replicate complicated table (scheme) from Excel:

enter image description here

Cells with numbers (1, 2, …) should be more or less squared. Lines forming right angle around center table are thicker than ordinary borders (not shown here).

I can make every table separately, but have no idea how to combine them together (with some small spaces in horizontal and vertical). Tried with excel2latex macro from ctan, but with no luck.

Thank you in advance.

EDIT

As asked in comments, here are separate tables:

\documentclass{article}
\usepackage{multirow}
\usepackage{graphicx}
\begin{document}
    
    \begin{tabular}{|r|r|r|r|r|}
    \hline
    1 & 2 & 3 & 4 & 5\\
    \hline
    1 & 2 & 3 & 4 & 5\\
    \hline
    1 & 2 & 3 & 4 & 5\\
    \hline
    1 & 2 & 3 & 4 & 5\\
    \hline
    1 & 2 & 3 & 4 & 5\\
    \hline
    \end{tabular}

    \begin{tabular}{c|l|r|}
    \cline{2-3} 
    \multirow{5}{*}{\rotatebox[origin=c]{90}{some long text here}} & qwerty 1 & 1 \\[1.5ex]
    \cline {2-3}
    & qwerty 2 & 2 \\[1.5ex]
    \cline {2-3}
    & qwerty 3 & 3 \\[1.5ex]
    \cline {2-3}
    & qwerty 4 & 4 \\[1.5ex]
    \cline {2-3}
    & qwerty 5 & 5 \\[1.5ex]
    \cline{2-3}
    \end{tabular}

    \begin{tabular}{|r|l|}
    \hline
    4 & text \\
    \hline
    3 & text text \\
    \hline
    2 & text text text \\
    \hline
    1 & text \\
    \hline
    \end{tabular}

    \begin{tabular}{|r|r|r|r|r|}
    \hline
    1 & 2 & 3 & 4 & 5 \\
    \hline
    \rotatebox[origin=c]{90}{abc} & \rotatebox[origin=c]{90}{abc abc} & \rotatebox[origin=c]{90}{abc} & \rotatebox[origin=c]{90}{abc abc} & \rotatebox[origin=c]{90}{abc abc abc} \\
    \hline
    \multicolumn{5}{c}{long text here 2} \\
    \end{tabular}
\end{document}

EDIT 2

I ask this question to draw the attention of advanced users and packges' developers to the fact that people need an easy and robust way to make such complex "visual" tables. Complexity of creating tables makes people away from using LaTeX.

Best Answer

A solution with {NiceTabular} of nicematrix.

The rules of each sub-table are drawn by a command \Block (with the key hvlines) inserted in top-left cell of the sub-table.

The thick rule forming right angle is drawn with Tikz in the \CodeAfter after the construction of the tabular (using PGF/Tikz nodes created by nicematrix under the rows, columns and cells of the array).

\documentclass[10pt]{article}

\usepackage{nicematrix,tikz}

\begin{document}

\sffamily
\small
\renewcommand{\arraystretch}{1.8}
\setlength{\tabcolsep}{2pt}
\newcolumntype{R}{w{r}{8mm}}

\begin{NiceTabular}{clRw{c}{4mm}RRRRRcRl}[cell-space-top-limit=2pt]
\Block{5-1}{\rotate some long text here}
& \Block[hvlines]{5-2}{}
  qwerty 1 & 1 & & \Block[hvlines]{5-5}{}
                   1 & 2 & 3 & 4 & 5 & & \Block[hvlines]{4-2}{}
                                         4 & text \\
& qwerty 2 & 2 & & 1 & 2 & 3 & 4 & 5 & & 3 & text text \\
& qwerty 3 & 3 & & 1 & 2 & 3 & 4 & 5 & & 2 & text text text \\
& qwerty 4 & 4 & & 1 & 2 & 3 & 4 & 5 & & 1 & text \\
& qwerty 5 & 5 & & 1 & 2 & 3 & 4 & 5 \\
\\
&          &   & & \Block[hvlines]{2-5}{}
                   1 & 2 & 3 & 4 & 5 & & \Block[C,draw]{2-2}{centered text }\\
\RowStyle{\rotate}
&          &   & & abc & abc abc & abc & abc abc & abc abc abc \\  
\CodeAfter
  \tikz \draw [thick] (1-|4.5) |- (6.5-|10) ;
\end{NiceTabular}

\end{document}

Output of the above code


Answer to the question in the comment

I have non easy solution. I have changed the columns w{r}{8mm} in columns p[r]{8mm} because, in the columns p, it's possible to change the horizontal alignement with \RowStyle{\centering}. However, that creates a problem for the rotatede elements which are now wrapped at 8 mm (maybe I should change that in nicematrix). That's why I have use \makebox...

\documentclass{article}
\usepackage{nicematrix,tikz}

\begin{document}

\sffamily
\small
\renewcommand{\arraystretch}{1.8}
\setlength{\tabcolsep}{2pt}
\newcolumntype{R}{p[r]{8mm}}

\begin{NiceTabular}{clRw{c}{4mm}RRRRRcRl}[cell-space-top-limit=2pt]
\Block{5-1}{\rotate some long text here}
& \Block[hvlines]{5-2}{}
  qwerty 1 & 1 & & \Block[hvlines]{5-5}{}
                   1 & 2 & 3 & 4 & 5 & & \Block[hvlines]{4-2}{}
                                         4 & text \\
& qwerty 2 & 2 & & 1 & 2 & 3 & 4 & 5 & & 3 & text text \\
& qwerty 3 & 3 & & 1 & 2 & 3 & 4 & 5 & & 2 & text text text \\
& qwerty 4 & 4 & & 1 & 2 & 3 & 4 & 5 & & 1 & text \\
& qwerty 5 & 5 & & 1 & 2 & 3 & 4 & 5 \\
\\
\RowStyle{\rotate\centering}
&          &   & & \Block[hvlines]{2-5}{}
                   1 & 2 & 3 & 4 & 5 & & \Block[C,draw]{2-2}{centered text }\\
\noalign{\vskip 11mm}
\RowStyle{\rotate\centering}
&          &   & & \makebox[18mm][r]{abc} & \makebox[18mm][r]{abc abc} & \makebox[18mm][r]{abc} & \makebox[18mm][r]{abc abc} & \makebox[18mm][r]{abc abc abc} \\  
\CodeAfter
  \tikz \draw [thick] (1-|4.5) |- (6.5-|10) ;
\end{NiceTabular}

\end{document}

Output of the above code

Related Question