I am generating tex documents automatically (HTML -> pandoc(tex) -> postprocess -> XELATEX), and my general table environment is tabularx (with usage of package ltablex, so these are longtables effectively).
One reason for this choice is the possibility to assign captions consistently (using package caption).
Sometimes need outer tabular's that should display the inner nested tabularx's with caption side-by-side.
My current result is:
which is created with this file
\documentclass[a4paper,dvipsnames]{article}
\usepackage[ngerman]{babel}
\usepackage[paper=portrait,pagesize]{typearea}
\usepackage{color}
\usepackage[table]{xcolor}
\definecolor{tableHighlightRowBackground}{gray}{0.9375}
\definecolor{tablecaptionfontcolor}{RGB}{108, 117, 125}
\definecolor{arrayrulecolor}{RGB}{222,226,230}
\usepackage[most]{tcolorbox}
\usepackage{relsize}
\usepackage{ltablex}
\keepXColumns
\usepackage{multirow}
\usepackage{caption}
\DeclareCaptionFont{muted}{\color{tablecaptionfontcolor}}
\captionsetup[table]{singlelinecheck=false, justification=raggedleft, font={muted,small}}
\setlength\parindent{0pt}
\usepackage{booktabs}
\usepackage{colortbl}
\arrayrulecolor{arrayrulecolor}
\begin{document}
\begin{tabular}{@{}ll@{}}
\toprule
\begin{minipage}[t]{0.47\columnwidth}\raggedright
a
\strut
\end{minipage}
&
\begin{minipage}[t]{0.47\columnwidth}\raggedright
b
\strut
\end{minipage}
\tabularnewline
\begin{minipage}[t]{0.47\columnwidth}\raggedright
\begin{tabularx} {\textwidth} {Xcrr}
\bfseries
Position & \bfseries Year 2020 & \bfseries Year 2021 \
\midrule
\endhead
\bottomrule
\caption{Important Caption} \tabularnewline
\endfoot
\rowcolor{tableHighlightRowBackground} % this is another problem, this command applies the bg color to the complete outer row
\bfseries A & { \bfseries 11,40 € } & { \bfseries 10,00 € } \
\end{tabularx}
\strut
\end{minipage}
&
\begin{minipage}[t]{0.47\columnwidth}\raggedright
d
\strut
\end{minipage}\tabularnewline
\bottomrule
\end{tabular}
\end{document}
The desired output would be a caption below the inner tabularx (inside the outer tabular).
My framework is quite flexible, there is just one invariant: The inner tabularx should be displayed as full-width table with a table caption and number.


booktabsandcolortblpackages as well as the definition of the colortableHighlightRowBackgroundare missing. – leandriis Jul 20 '20 at 12:31longtableinside of aminipageor atabular. Neither of these two can break across pages. – leandriis Jul 20 '20 at 12:33sidenotesorfloatrowpackage in order to place the caption side-by-side with its table? – leandriis Jul 20 '20 at 12:36