I am trying to make a 2x4 tabular containing images, with horizontal captions at the top and vertical captions on the left.
Taking inspiration from this thread, I painfully managed to do this:
\documentclass{article}
\usepackage{graphicx}
\newlength{\tempdima}
\newlength{\tempdimb}
\newcommand{\rowname}[1]% #1 = text
{\rotatebox{90}{\makebox[\tempdimb][c]{\scriptsize#1}}}
\newcommand{\rownamee}[1]% #1 = text
{\rotatebox{-90}{\makebox[\tempdimb][c]{\scriptsize#1}}}
\begin{document}
\begin{figure}
\settowidth{\tempdima}{\includegraphics[width=0.2\linewidth]{example-image-duck}}%
\settoheight{\tempdimb}{\includegraphics[width=0.2\linewidth]{example-image-duck}}%
\centering
\begin{tabular}{@{}c@{}c@{}c@{}c@{}c@{}@{}c@{}}
& target & method 1 & method 2 & method 3 & \\
\rowname{mod 1} & \includegraphics[width=\tempdima]{example-image-duck} & \includegraphics[width=\tempdima]{example-image-duck} & \includegraphics[width=\tempdima]{example-image-duck}&\includegraphics[width=\tempdima]{example-image-duck} & \\
\rowname{mod 2} & \includegraphics[width=\tempdima]{example-image-duck} & \includegraphics[width=\tempdima]{example-image-duck} & \includegraphics[width=\tempdima]{example-image-duck}&\includegraphics[width=\tempdima]{example-image-duck} & \\
\end{tabular}
% pet
\end{figure}
\end{document}
which produces the following table:

Clearly this approach is suboptimal.
I discovered tabularray in this thread and it should be able to do something much better, with possibility to control spacing between rows and columns, but I failed to produce anything.
Any help/tips would be greatly appreciated. Thanks!


