I have created a custom \source command which places a second caption under a figure using the \caption* command (see Xavi's answer on this post). Also I have enabled the list option of the subcaption package to include subfigures in the List of Figures.
However, when using the \source command for a figures containing subfigures the caption of the subfigures are wrongly placed in the List of Figures, see the following example.
\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[list]{subcaption}
\usepackage[colorlinks]{hyperref}
\setcapindent{1em}
\newcommand{\source}[1]{\caption*{ {\small Source: {#1}}} }
\begin{document}
\listoffigures
\section{Subcaption Test}
\begin{figure}[h]
\centering
\includegraphics[width=0.35\linewidth]{example-image}
\caption{First Figure}
\end{figure}
Some text
\begin{figure}[h]
\centering
\begin{subfigure}{0.35\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{First Subfigure}
\label{fig:first}
\end{subfigure}%
\hfill
\begin{subfigure}{0.35\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{Second subfigure}
\label{fig:second}
\end{subfigure}
\source{https://tex.stackexchange.com/}
\caption{Second figure with two subfigures}
\end{figure}
Subfigures \ref{fig:first} and \ref{fig:second} have the correct reference but appear wrong in the list of figures.
\end{document}
The example produces the following output.
The two subfigures in the second figure are incorrectly listed under the first figure. However, the labels still correctly refer two 2a and 2b. Therefore I don't understand what causes the problem.
Can somebody explain this behaivour and tell me how to fix it? Or should I not be using \caption* command to create sources?
Note: I have also included the Koma-Script command \setcapindent{1em}, but I don't think that causes the problem.
Also, since this is my first question and I am fairly new to the Latex world I would be gratefull for any advice regarding asking questions on tex.stackexchange.com


\sourcecaption{source}{caption}{label}but I would like to maintain the flexibility of the\captionand\labelcommands. This leads me to the conclusion, that using\caption*for creating a source is not the right approach. How can I redefine the\sourcecommand to work as expected? – marv Dec 15 '21 at 12:16\caption*command even correct? According to the captions manual, the\caption*command typesets the caption without label and without entry in the list of figures. Is this a bug? – marv Dec 15 '21 at 12:28\vspace. – Imran Dec 15 '21 at 13:37\caption*is working correctly. It didn't add any content in the LOF rather due to the use of both\captionand\caption*command, things were messed up. Someone experienced enough might explain the behavior better (I am a beginner). – Imran Dec 15 '21 at 13:41