1

What I would like to do : put table captions directly above my tables without space between the caption and the table

Here is what I get : enter image description here

I am using the floatrow, subfig and caption package and I am writing in the report class

What I don't understand :

  • Why my table captions are by default below the tables ? I thought Latex usually put table captions above ? So I have to specify it with the floatrow package by \floatstyle[table]{capposition=top} However, with the caption package, the command \captionsetup[table]{position=above} does not seem to work.

  • Why can not I remove the space between caption and table ? with the floatrow package, the command \floatstyle[table]{captionskip=0pt}seems to have an impact but not as expected whereas with the caption package, it does not work (\captionsetup[table]{skip=0pt}).

Is there any package conflicts I am not aware of ?

Here is a simplified code with truncated tables :

\documentclass[12pt,a4paper,oneside]{report}
\usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[utf8]{inputenc}
\usepackage{floatrow}
\usepackage{multirow,bigdelim}
\usepackage{booktabs}
\usepackage{textgreek}
\usepackage{gensymb}
\usepackage[label font=bf,labelformat=simple]{subfig}%using for my other figures
\usepackage[font=footnotesize,labelfont=bf]{caption}%also using for my other figures
    \floatsetup[table]{capposition=top,captionskip=0pt}
\usepackage[table]{xcolor}
    \definecolor{GrayTable}{gray}{0.90}
    \definecolor{GrayText}{gray}{0.55}
    \definecolor{BlueTable}{rgb}{0.0,0.6,0.9}

\begin{document}

\begin{table}[!htb]
    \caption{Mix PCR pour vérifier la présence des LCT}
    \rowcolors{2}{GrayTable}{white}
    \resizebox{\textwidth}{!}{% Using this command because the table is large
    \begin{tabular}{ccccc}
    \toprule
    \rowcolor{BlueTable} LCT & Séquence SU & Taille de l'amplicon (pb) & Température d'hybridation (\degree C) & Concentration en MgCl$_{2}$ \\
    \midrule
LCT\_0071   &   AAAAGAGCGTGTTATTTTAGGCA &   200 &   60  &   2   \\
LCT\_0078   &   TGGCCACCTTCTCTTTCCAT    &   143 &   60  &   2   \\
LCT\_0090   &   ACGGCTTTGCTTTCAGTTGT    &   160 &   60  &   2   \\
    \bottomrule
    \end{tabular}}
\end{table}

\begin{table}[!htb]
    \singlespacing
    \caption{Mix PCR pour vérifier la présence des LCT}
    \begin{tabular}{ccccc}
    \toprule
    \rowcolor{BlueTable} Réactifs & Concentration initiale & Concentration finale & Volume pour 1 tube (\textmu L)  \\
    \midrule
    Buffer & 5X & 1X & 5\\
    \bottomrule
    \end{tabular}
\end{table}

\end{document}

Thanks !

  • 1
    To get a uniform space below the caption of both tables, remove the \singlespacing command from the second table. Apart from that, you might want to use a package like mhchem for chemical formulae (\ce{MgCl2}). Also I'd recommend to not use resizebox on a table as it will lead to inconsistent and very small font sizes. You could introduce linebreaks in the column headers instead. Personally, I'd also not use colors for table headers as this will decrease the contrast between the text and the background and therefor decrease readability. – leandriis May 21 at 10:59
  • Thanks for all your advices it is useful, it was just the singlespacing... – Azerth anis May 21 at 13:32
  • Be warned that floatrow does strange things to captions. See tex.stackexchange.com/questions/403661/… – John Kormylo May 21 at 15:19
  • Thanks for the feedback, I do not have problem with floatrow at least for now – Azerth anis May 22 at 8:43
1

The large space between the caption and the second table is caused by the singlespacing command. If you remove this, you will get the following output:

enter image description here


Personally, I'd redesign your tables as follows:

a) Usage of mhchem for easier input of chemical formulae

b) Usage of siunitx for units (By the way: The unit for the concentration in the first table is missing)

c) Removing all color as usage of color does not enhance the readability of the tables

d) Removing the \resizebox command from the first table. Replaced long table headers with appropriate abbreviations that are explained below the table.

Thouse changes will result in the following output:

enter image description here

Corrensponding MWE:

\documentclass[12pt,a4paper,oneside]{report}
\usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{floatrow}
\usepackage{booktabs}

\usepackage[label font=bf,labelformat=simple]{subfig}%using for my other figures
\usepackage[font=footnotesize,labelfont=bf]{caption}%also using for my other figures
    \floatsetup[table]{capposition=top,captionskip=0pt}

\usepackage[version=4]{mhchem}
\usepackage{makecell}
\usepackage{tabularx}
\usepackage{siunitx}

\begin{document}

\begin{table}[!htb]
    \caption{Mix PCR pour vérifier la présence des LCT}
    \begin{tabular}{ccccc}
    \toprule
     LCT & Séquence SU & l(ampl.) & T(hybrid.) & c(\ce{MgCl2}) \\
    \midrule
LCT\_0071   &   AAAAGAGCGTGTTATTTTAGGCA &   200 &   60  &   2   \\
LCT\_0078   &   TGGCCACCTTCTCTTTCCAT    &   143 &   60  &   2   \\
LCT\_0090   &   ACGGCTTTGCTTTCAGTTGT    &   160 &   60  &   2   \\
    \bottomrule
    \multicolumn{5}{l}{l(ampl.) = Taille de  l'amplicon (pb)}\\
    \multicolumn{5}{l}{T(hybrid.) = Température d'hybridation (\si{\celsius})}\\
    \multicolumn{5}{l}{c(\ce{MgCl2}) = Concentration en \ce{MgCl2}}
    \end{tabular}
\end{table}

\begin{table}[!htb]
    %\singlespacing
    \caption{Mix PCR pour vérifier la présence des LCT}
    \begin{tabular}{ccccc}
    \toprule
     Réactifs & \multicolumn{2}{c}{Concentration}  & Volume pour 1 tube (\si{\micro\liter})  \\
     \cmidrule{2-3}
     & initiale &  finale \\
    \midrule
    Buffer & 5X & 1X & 5\\
    \bottomrule
    \end{tabular}
\end{table}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.