Having the following MWE:
\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
% \captionsetup[subfigure]{justification=centering}
\centering
\begin{subfigure}[t]{0.31\textwidth}
\includegraphics[width=\textwidth]{example-image-a}
\caption{\texttt{image 1}}%
\label{fig:image1}
\end{subfigure}
~%
\begin{subfigure}[t]{0.31\textwidth}
\includegraphics[width=\textwidth]{example-image-b}
\caption[\texttt{image 2}]{\texttt{image 2}\\*
Longer text containing description of the image contents.}
\label{fig:image1}
\end{subfigure}
~%
\begin{subfigure}[t]{0.31\textwidth}
\includegraphics[width=\textwidth]{example-image-c}
\caption[\texttt{image 3}]{\texttt{image 3 having a name longer than the other two images}\\*
Longer text containing description of the image contents.}
\label{fig:image1}
\end{subfigure}
\end{figure}
\end{document}
I wonder if it is possible to change the formatting of subfloat captions so that the first line of (b) will be centered (as in (a)). In general, if there are multiple lines defined in a caption, each of them should be centered if it occupies less than one \linewidth
and justified if it is longer – like a default behavior for a caption, but applied separately for different lines.
Optionally, second and further lines need not to be indented for the label, so they can take all the width of their subfloat.