[Tex/LaTex] How to align text within a caption

captionsindentation

I want to give a survey on several techniques within a figure. It turned out, that there are many techniques, so I employed subcaption with subref to describe the matter. However, as there are too many labels, I found it convenient to put each description in a single line by employing \\\hspace{textwidth} as linebreak workaround. I do not want to put the info in subcaption below the image, as I don't like it and it would break the format of the whole document, where ever I have subcaptions I will refer to its label (with \subref) within the figure caption. As subref labels, consume different width, the left side of the caption looks quite jaggy, angular. A MWE:

\documentclass[oneside,DIV=17]{scrbook}
\usepackage[font={scriptsize,sf},labelfont={scriptsize,sf,bf}]{caption}
\usepackage[subrefformat=parens,labelfont={normalfont,scriptsize,sf},labelsep=space]{subcaption}
\setcapindent{0pt}

\begin{document}
 \begin{figure}
   \subcaptionbox{\label{fig:a}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:b}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:c}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:d}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:e}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:f}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:g}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:h}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:i}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:j}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:k}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \hspace{0.3\textwidth}
   \caption{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus
sem. Nulla et lectus vestibulum urna fringilla ultrices.\\\hspace{\textwidth}
    \subref{fig:a} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:b} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:c} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:d} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:e} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:f} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:g} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:h} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:i} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:j} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:k} Short text fit in one line
   }
 \end{figure}
\end{document}

which renders to (the redline, highlights the problem):

jaggy left margin

I know, if I would not linebreak the caption text, everything would be ok. But I would argue, that the reader might find it easier to select description from the column, then by searching the label item within the text. Thanks for any suggestions.

Best Answer

I hope you won't have to print a List of Figures in your document with such captions... In such a case, remember to use the optional argument of \caption:

\caption[short caption]{long caption}

Here are three alternatives.

First alternative:

\documentclass[oneside,DIV=17]{scrbook}
\usepackage[font={scriptsize,sf},labelfont={scriptsize,sf,bf}]{caption}
\usepackage[subrefformat=parens,labelfont={normalfont,scriptsize,sf},labelsep=space]{subcaption}
\setcapindent{0pt}

\begin{document}
 \begin{figure}
   \subcaptionbox{\label{fig:a}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:b}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:c}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:d}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:e}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:f}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:g}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:h}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:i}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:j}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:k}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \hspace{0.3\textwidth}
   \caption{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus
sem. Nulla et lectus vestibulum urna fringilla ultrices.\\
    \llap{\subref{fig:a}} Short text fit in one line\\
    \llap{\subref{fig:b}} Short text fit in one line\\
    \llap{\subref{fig:c}} Short text fit in one line\\
    \llap{\subref{fig:d}} Short text fit in one line\\
    \llap{\subref{fig:e}} Short text fit in one line\\
    \llap{\subref{fig:f}} Short text fit in one line\\
    \llap{\subref{fig:g}} Short text fit in one line\\
    \llap{\subref{fig:h}} Short text fit in one line\\
    \llap{\subref{fig:i}} Short text fit in one line\\
    \llap{\subref{fig:j}} Short text fit in one line\\
    \llap{\subref{fig:k}} Short text fit in one line
   }
 \end{figure}
\end{document} 

enter image description here

Second alternative:

\documentclass[oneside,DIV=17]{scrbook}
\usepackage[font={scriptsize,sf},labelfont={scriptsize,sf,bf}]{caption}
\usepackage[subrefformat=parens,labelfont={normalfont,scriptsize,sf},labelsep=space]{subcaption}
\setcapindent{0pt}

\begin{document}
 \begin{figure}
   \subcaptionbox{\label{fig:a}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:b}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:c}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:d}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:e}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:f}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:g}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:h}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:i}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:j}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:k}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \hspace{0.3\textwidth}
   \caption{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus
sem. Nulla et lectus vestibulum urna fringilla ultrices.\\
    \protect\makebox[.5cm]{\subref{fig:a}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:b}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:c}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:d}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:e}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:f}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:g}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:h}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:i}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:j}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:k}} Short text fit in one line
   }
 \end{figure}
\end{document} 

enter image description here

Third alternative:

\documentclass[oneside,DIV=17]{scrbook}
\usepackage[font={scriptsize,sf},labelfont={scriptsize,sf,bf}]{caption}
\usepackage[subrefformat=parens,labelfont={normalfont,scriptsize,sf},labelsep=space]{subcaption}
\setcapindent{0pt}

\begin{document}
 \begin{figure}
   \subcaptionbox{\label{fig:a}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:b}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:c}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:d}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:e}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:f}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:g}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:h}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:i}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:j}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:k}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \hspace{0.3\textwidth}
   \caption{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus
sem. Nulla et lectus vestibulum urna fringilla ultrices.\\
    \protect\makebox[.5cm][l]{\subref{fig:a}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:b}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:c}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:d}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:e}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:f}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:g}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:h}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:i}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:j}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:k}} Short text fit in one line
   }
 \end{figure}
\end{document} 

enter image description here