I have a following kind of table structure, where my caption text refuses to be typeset properly. The normal text above it is beautifully typeset with hyphenations and spacing, but the caption looks terrible:
My code:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,lmargin={2.5cm},rmargin={2.5cm},tmargin={2.5cm},bmargin =
{2.5cm}]{geometry}
\usepackage{setspace}
\onehalfspacing
\usepackage[parfill]{parskip}
\usepackage{tabularx}
\usepackage{caption}
\DeclareCaptionLabelSeparator{period-newline}{. \\}
\captionsetup{labelfont=bf, labelsep=period, format=plain, labelsep=period-newline, justification=raggedright,singlelinecheck=false,font=small}
\usepackage{floatrow}
\floatsetup[table]{font=small, position=top}
\usepackage{booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}[h]
\caption{\textbf{Title.} \\ \smallskip \footnotesize{Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Mauris dolor dui, lacinia sodales condimentum nec,
malesuada vel libero. Vivamus eget ipsum non lacus lacinia tincidunt sit amet eu
metus. Fusce venenatis accumsan dui, ac commodo lorem aliquam ut. Curabitur volutpat
urna purus. Nullam in ex sed enim feugiat ornare. Fusce sit amet auctor enim.
Praesent nec ex eu massa feugiat tristique..}}
\centering
\begin{tabularx}{\textwidth}{lYYYYYYYYYYY}
\toprule
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
\midrule
Low & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\
2 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\
3 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
I wonder if my quite complicated caption code is causing this? Is there a better way to come up with a similar end result or can this typesetting fixed in some other way?
You disable hyphenation for your captions with justification=raggedright
in your caption setup. Either remove this entirely to get justified text for all captions or locally switch back to hyphenated text for specific captions. Same goes for the font size.
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,lmargin={2.5cm},rmargin={2.5cm},tmargin={2.5cm},bmargin =
{2.5cm}]{geometry}
\usepackage{setspace}
\onehalfspacing
\usepackage[parfill]{parskip}
\usepackage{tabularx}
\usepackage{caption}
\DeclareCaptionLabelSeparator{period-newline}{. \\}
\captionsetup{labelfont={small,bf}, labelsep=period, format=plain, labelsep=period-newline, justification=justified,singlelinecheck=false,font=footnotesize}
\usepackage{floatrow}
\floatsetup[table]{font=small, position=top}
\usepackage{booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Mauris dolor dui, lacinia sodales condimentum nec,
malesuada vel libero. Vivamus eget ipsum non lacus lacinia tincidunt sit amet eu
metus. Fusce venenatis accumsan dui, ac commodo lorem aliquam ut. Curabitur volutpat
urna purus. Nullam in ex sed enim feugiat ornare. Fusce sit amet auctor enim.
Praesent nec ex eu massa feugiat tristique..
\begin{table}[h]
\caption[short version for list of tables]{{\small \textbf{Title.}\smallskip\par} Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Mauris dolor dui, lacinia sodales condimentum nec,
malesuada vel libero. Vivamus eget ipsum non lacus lacinia tincidunt sit amet eu
metus. Fusce venenatis accumsan dui, ac commodo lorem aliquam ut. Curabitur volutpat
urna purus. Nullam in ex sed enim feugiat ornare. Fusce sit amet auctor enim.
Praesent nec ex eu massa feugiat tristique..}
\centering
\begin{tabularx}{\textwidth}{lYYYYYYYYYYY}
\toprule
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
\midrule
Low & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\
2 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\
3 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}