[Tex/LaTex] Caption on the side of a table

captionsfloatspositioning

I tried to use the floatrow package together with the approach from the accepted answer from (Caption on the side of a figure) to put my table caption to the right top hand side of my table. However, whatever I tried so far did not work out at all. I use the float package. Not very often but that is why I do not want to or cannot use the sidecap package which looks actually much simpler. I quickly tried the minipage approach which seems to work but not sure if I should use it. Here is my simple table which I used to try to bring the caption to the right top:

\documentclass[10pt,DIV=12,a4paper,numbers=noenddot]{scrreprt}

\usepackage{tabu}
\usepackage{booktabs}

\begin{document}

\begin{table}

\begin{tabu} to \textwidth {X[L] X[L]}

\toprule

AAAAAA & BBBBBB \\
AAAAAA & BBBBBB \\
AAAAAA & BBBBBB \\
AAAAAA & BBBBBB \\
AAAAAA & BBBBBB \\

\end{tabu}

\caption{This is the caption This is the caption This is the caption This is the caption This is the caption This is the
caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the
caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the
caption}

\end{table}

\end{document}

Can anyone help with this floatrow approach?

Best Answer

Since you use a KOMA-Script class, you can use its captionbeside environment (adjust the lengths according to your needs):

\documentclass[10pt,DIV=12,a4paper,numbers=noenddot]{scrreprt}
\usepackage{tabu}
\usepackage{booktabs}

\begin{document}

\begin{table}
\begin{captionbeside}
{This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption This is the caption}
[r][\linewidth][0em]
\raisebox{0.8\totalheight}{%
\begin{tabu} to .4\textwidth {X[L] X[L]}
\toprule
AAAAAA & BBBBBB \\
AAAAAA & BBBBBB \\
AAAAAA & BBBBBB \\
AAAAAA & BBBBBB \\
AAAAAA & BBBBBB \\
\bottomrule
\end{tabu}%
}
\end{captionbeside}
\end{table}

\end{document}

enter image description here