Justified captions with KOMA-Script and ragged2e

Use \setcaptionalignment{J} after loading package ragged2e. Alignment J means fully justified with ragged2e (see the KOMA-Script documentation).

\documentclass[10pt]{scrbook}
\usepackage[newcommands]{ragged2e}
\setcaptionalignment{J}% <- added
\usepackage{graphicx}
\begin{document}
\chapter{We need justification}
\label{cha:justification}
\begin{figure}
  \centering
  \includegraphics{example-image-a}
  \caption[short caption]{Some random text, just ordinary text, which
    should be some words and lines long.  This text should be
    presented in justified form, as is all the rest of the text of
    this book.  Be careful.  Have a closer look.  This text is flush
    left instead of justified.  What on earth is going on?}
  \label{fig:flushleft}
\end{figure}
\begin{figure}
  \begin{captionbeside}
    [Another short story]{This is a smaller image, where the caption
      is not given below, but beside the image.  Thanks to Markus
      Kohm, who did a great job with this often requested feature.
      This caption text is presented in justified form, as you would
      and should expect.}
    \includegraphics[width=5cm]{example-image-b}
  \end{captionbeside}
\end{figure}
\end{document}

enter image description here

You can also replace \centering by \LaTeXcentering:

\documentclass[10pt]{scrbook}
\usepackage[newcommands]{ragged2e}
\usepackage{graphicx}
\begin{document}
\chapter{We need justification}
\label{cha:justification}
\begin{figure}
  \LaTeXcentering% <- changed
  \includegraphics{example-image-a}
  \caption[short caption]{Some random text, just ordinary text, which
    should be some words and lines long.  This text should be
    presented in justified form, as is all the rest of the text of
    this book.  Be careful.  Have a closer look.  This text is flush
    left instead of justified.  What on earth is going on?}
  \label{fig:flushleft}
\end{figure}
\begin{figure}
  \begin{captionbeside}
    [Another short story]{This is a smaller image, where the caption
      is not given below, but beside the image.  Thanks to Markus
      Kohm, who did a great job with this often requested feature.
      This caption text is presented in justified form, as you would
      and should expect.}
    \includegraphics[width=5cm]{example-image-b}
  \end{captionbeside}
\end{figure}
\end{document}

Using \LaTeXcentering will also work with a standard class:

\documentclass[10pt]{book}% standard class
\usepackage[newcommands]{ragged2e}
\usepackage{graphicx}
\begin{document}
\chapter{We need justification}
\label{cha:justification}
\begin{figure}
  \LaTeXcentering% <- changed
  \includegraphics{example-image-a}
  \caption[short caption]{Some random text, just ordinary text, which
    should be some words and lines long.  This text should be
    presented in justified form, as is all the rest of the text of
    this book.  Be careful.  Have a closer look.  This text is flush
    left instead of justified.  What on earth is going on?}
  \label{fig:flushleft}
\end{figure}
\end{document}

The ragged2e manual, page 6, explains that the option newcommands subtitutes \centering with \Centering; if you do this manually without the option enabled (i.e. use \Centering instead of \centering without loading newcommands), the very same output is produced.

One quick fix would be to simply save the old \centering before loading \usepackage[newcommands]{ragged2e} and then using that instead of \centering in the figure environment:

\let\oldcentering\centering
\usepackage[newcommands]{ragged2e}

Edit: This is actually precisely what \LaTeXcentering (see @esdd's answer) is, see §7.10 of the ragged2e manual (excerpt below).

screenshot


Or, alternatively, as described on page 3 of the ragged2e manual, you may use \justifying inside of the caption environment to turn justification back on, as in \caption{\justifying Lorem ipsum}.

Both of the fixes should also prevent the Underfull \hbox (badness 10000) warnings that you'd get otherwise (or at least I did).


Edit: For a less tedious solution, using KOMA-Script, see @esdd's answer. Alternatively, and this should work for both KOMA-Script and regular classes, you can use the caption package:

\usepackage[newcommands]{ragged2e}

% see page 25 of the `caption` manual:
% http://mirrors.ctan.org/macros/latex/contrib/caption/caption-eng.pdf
\usepackage{caption}
\DeclareCaptionJustification{justified}{\justifying}
\captionsetup{justification=justified}

MWE for scrbook class:

\documentclass[10pt]{scrbook}

\usepackage[newcommands]{ragged2e}

\usepackage{caption}
\DeclareCaptionJustification{justified}{\justifying}
\captionsetup{justification=justified}

\usepackage{graphicx}

\begin{document}

\begin{figure}
  \centering
  \includegraphics{example-image-a}
  \caption{Some random text, just ordinary text, which should
    be some words and lines long.  This text should be
    presented in justified form, as is all the rest of the text of
    this book.  Be careful.  Have a closer look.  This text is flush
    left instead of justified.  What on earth is going on?}
  \label{fig:flushleft}
\end{figure}

\end{document}

screenshot


That the scope of the \Centering command also includes the content of the \caption command, well, that might be a bug. I don't know.

PS: "We need justification" is hilarious, I love it.