Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Caption of figure not typeset properly

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:

enter image description here

My code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

\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?

>Solution :

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{\textbf{\small Title.} \\[1ex]  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}

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading