While experimenting with KOMA-Script's features I have found captionbeside. That's a really great option for me as I want my captions to be formatted this way. The only problem is that in a long document of mine I do not want to rewrite every figure.
So the question is how I could automatically change (by redefinition):
\begin{figure}
\includegraphics{}
\caption{Blub}
\end{figure}
to be treated as
\begin{figure}
\begin{captionbeside}{Blub}
\includegraphics{}
\end{captionbeside}
\end{figure}
If it helps, I use LuaLaTeX, so a Lua solution would be okay too (although I would prefer LaTeX).
Complete code example:
\documentclass{scrartcl}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics[height=10\baselineskip]{example-image}
\caption{Test a}\label{testa}
\end{figure}
\begin{figure}
\begin{captionbeside}{Test b}
\centering
\includegraphics[height=10\baselineskip]{example-image}
\label{testb}
\end{captionbeside}
\end{figure}
\end{document}
Update: I have redefined figure to gobble captions. In that sense captionbeside works, but it of course won't output the right caption. How could I realize this (using the parameter of a not-yet-issued macro)?
\documentclass{scrartcl}
\usepackage{graphicx}
\makeatletter
\let\oldfigure\figure
\let\oldendfigure\endfigure
\renewenvironment{figure}{
\oldfigure\let\caption\@gobble
\begin{captionbeside}{Figure}
}{\end{captionbeside}\oldendfigure}
\makeatother
\begin{document}
\begin{figure}
\centering
\includegraphics[height=10\baselineskip]{example-image}
\caption{Test a}\label{testa}
\end{figure}
\begin{figure}
\centering
\includegraphics[height=10\baselineskip]{example-image}
\caption{Test b}\label{testb}
\end{figure}
\end{document}

figure-environment to include thecaptionbeside-environment. The issue with redefining the\captioncommand might be a little tricky. Maybe a two run solution does work. – Skillmon May 13 '17 at 17:34figureenvironment, but have no clue how I would capture the argument of\captionto be given tocaptionbeside. A two-run-solution would be fine for me. – TeXnician May 13 '17 at 17:36\captionaboveand\captionbelowcall the same macro (\scr@caption), they set a boolean switch for the formatting behavior (if I'm not mistaken). – Skillmon May 14 '17 at 10:41