Graphics, Figures & TablesBooktabs caption alignment problem

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
timtico
Posts: 6
Joined: Wed Sep 01, 2010 6:59 pm

Booktabs caption alignment problem

Post by timtico »

Hello guys,

Since a few weeks I'm preparing a LaTeX template which I will use to typeset my PhD thesis.. However I've run into a little problem I could use some help with.
My problem is related to this topic: http://www.latex-community.org/forum/vi ... =45&t=4450. But I'm unable to solve it using the floatrow package.

Anyway. I have a booktabs table. The table is horizontally centered and the caption is also horizontally centered. I would like to have the caption start where the Table starts. Instead of having it centered. I'm sure it is something obvious i'm missing here... anyway here is the code:

Code: Select all

%part of my preamble
\usepackage{booktabs}
\usepackage[labelfont={bf,sf},labelsep=period,format = plain,margin=0pt,textfont={sf},figurewithin=section,skip= 6pt, singlelinecheck = true]{caption}
\captionsetup[table]{format = plain, justification = raggedright}

\begin{table}[b]
\caption{Lucie's assay}\label{table:lucie}
\centering
\begin{tabular}{@{}lll@{}}
\toprule
\multicolumn{1}{r}{} & \multicolumn{2}{c}{Assay condition}\\
\cmidrule (r){2-3} 
\multicolumn{1}{l}{Enzymatic Activity} & substrate & pH\\
\midrule 
x & x & 4.2 \\
x & x & 4.2 \\
x& x) & 6.0 \\
x & x & 8.4 \\
\bottomrule
\end{tabular}
\end{table}
Now as some suggested I should be using the floatrow package, using something like:

Code: Select all

\ttabbox{\caption{Lucie's assay}\label{table:lucie}}
However when I do this, the caption becomes a multiline centered caption, very weird. It seems as the floatrow package cannot determine the tablewidth or something.

Any help would be greatly appreciated :)
Last edited by timtico on Mon Sep 06, 2010 6:03 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Booktabs caption alignment problem

Post by sommerfee »

timtico wrote:

Code: Select all

\ttabbox{\caption{Lucie's assay}\label{table:lucie}}
The correct syntax of \ttabbox is:

Code: Select all

\ttabbox{<caption>}{<tabular>}
timtico
Posts: 6
Joined: Wed Sep 01, 2010 6:59 pm

Booktabs caption alignment problem

Post by timtico »

Thanks for your fast reply Sommerfee!

After some testing, it still kept centering my caption...
But

Code: Select all

\captionsetup{singlecheck=false}
did the trick!

The following code is working for me.

Code: Select all

\documentclass{article}

%some table testing
\usepackage{booktabs}
\usepackage{caption}
\captionsetup{singlelinecheck = false}
\usepackage{floatrow}
\floatsetup[table]{style=plaintop}

\begin{document}
\section{Results}
\begin{table}[h]
\ttabbox{\caption{Lucie's assay}\label{table:lucie}}
{\begin{tabular}{@{}lll@{}}
\toprule
\multicolumn{1}{r}{} & \multicolumn{2}{c}{Assay condition}\\
\cmidrule (r){2-3} 
\multicolumn{1}{l}{Enzymatic Activity} & substrate & pH\\
\midrule 
x & x & 4.2 \\
x & x & 4.2 \\
x& x & 6.0 \\
x& x & 8.4 \\
\bottomrule
\end{tabular}}
\end{table}
\end{document}
Post Reply