[Tex/LaTex] Beamer: left-aligned caption of centered figure

beamercaptionsfloatsgraphicshorizontal alignment

I am doing which should be a simple task, but I cannot fathom why it does not work…
I just want a simple caption of a figure I centered, aligned to the left of the figure, right down its lower left corner.

This is my MWE:

\documentclass{beamer}

\mode<presentation> {
    \usepackage[labelformat=empty,
    font=scriptsize,
    skip=0pt,
    justification=justified,
    singlelinecheck=false]{caption}
}

\begin{document}

\begin{frame}
    \begin{center}
    \includegraphics[width=.5\linewidth]{example-image}
    \captionof{figure}{my caption here}
    \end{center}
\end{frame}

\end{document}

Which produces:

fig1

How can I have the caption right below the bottom left corner of my image? And why does the code above not work?

Please note the solution should also work within a \figure environment to add captions to tikzpictures…

Thanks!

EDIT:
I TRIED justification=justified,singlelinecheck=false AS SUGGESTED HERE, BUT STILL NO SUCCESS…

\documentclass{beamer}

\usepackage[labelformat=empty,font=scriptsize,skip=0pt,
justification=raggedright,singlelinecheck=false]{caption}

\begin{document}

\begin{frame}
    \begin{center}
    \includegraphics[width=.5\linewidth]{example-image}
    \captionof{figure}{my caption here}
    \end{center}
\end{frame}

\end{document}

b

Best Answer

You can use package threeparttable to restrict the caption width to the width of the image:

\documentclass{beamer}

\usepackage{threeparttable}
\usepackage[labelformat=empty,font=scriptsize,skip=0pt,
justification=raggedright,singlelinecheck=false]{caption}

\begin{document}

\begin{frame}
    \begin{figure}
      %\centering% not needed, because default
      \begin{measuredfigure}
        \includegraphics[width=.5\linewidth]{example-image}
        \caption{my caption here}
      \end{measuredfigure}
    \end{figure}
\end{frame}

\end{document}

caption below image restricted to image width

Usually you do not need explicit center or \centering, because beamer centers the figure by default (see the result in the image above). Instead, if you want left aligned or right aligned figures you have to add \raggedright or \raggedleft just after \begin{figure}. Nevertheless, you can activate the commented \centering.