This is an add-on to another question.
Same usecase: "make \caption to print both short and long captions for a float, where short caption uses boldface"
Solution by Teepeemm was
\let\oldcaption=\caption
\renewcommand{\caption}[2][]{\oldcaption[#1]{\textbf{#1} #2}}
and it works perfectly.
But I also use the subcaption package and it breaks it for some reason. Any fixes?
MWE (or minimum not working example):
\documentclass{scrreprt}
\usepackage{subcaption}
\let\oldcaption\caption
\renewcommand{\caption}[2][]{\oldcaption[#1]{\textbf{#1} #2}}
\begin{document}
\begin{figure}
\centering
\rule{5cm}{1cm}
\caption[This is a figure]{This is the more detailed description of the figure}
\end{figure}
\begin{table}
\centering
\rule{5cm}{1cm}
\caption[This is a table]{This is the more detailed description of the table}
\end{table}
\end{document}
Edit: Added the complete solution from the previous question
\caption[\bfseries This is a table]{This is the more detailed description of the table}? Then you do not need to redefine the\captioncommand. – user187802 Aug 22 '22 at 18:12\let\oldcaption=\captionis placed. You could use\makeatletter \let\oldcaption=\caption@caption \makeatotherto make sure you are using the caption package caption. – John Kormylo Aug 22 '22 at 23:34\let\oldcaption=\captionis placed after\usepackage{subcpation}as\captionhas already be redefined at that point? – PaulMndn Aug 23 '22 at 08:49\usepackage{subcaption}it still works, so it must have something to do withsubcaption(orcaptionas my tests suggest which is included insubcaption) – PaulMndn Aug 23 '22 at 15:52