# Center the first line of the caption and justify the second line of the caption

I have a code where the title and table notes are written with the caption command all-together. I give a snapshot below. How can I center the Table name (first line of the caption), and justify the rest of the text (second line of the caption)? It would be super helpful if anybody could share their insights on below ... Apologies if the question is really simple, I cannot make it work.. Thanks a lot!!!

 \caption{ \newline
\hspace{\textwidth} \protect  \small{  Text text text }} \\


You can use caption; I recommend using margins for the caption, in order to make it more evident with respect to the context.

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{lipsum} % just for the example

\DeclareCaptionLabelFormat{center}{\hspace*{\fill}\textbf{#1 #2}\hspace*{\fill}}
\captionsetup{
labelformat=center,
labelsep=newline,
justification=justified,
margin=.1\textwidth
}

\begin{document}

\lipsum[2]

\begin{figure}[htp]
\centering

\includegraphics[width=6cm]{example-image}

\caption{This is a longish caption that should show that
the text is justified, while the label is centered
above it. Some more text for filling more lines, hope
this is sufficient.}

\end{figure}

\lipsum[3]

\end{document}


• This works like magic, thanks so much @egreg! Aug 23 '16 at 21:39