Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to have multiple small tables, each of a different vertical size, over two rows. The major problem that I've been trying to solve is to align the tables at the top and the captions below them. From documentation and Google results I've cobbled together a mostly working version using subfig and floatrow, but I run into an odd problem when the tables are too wide: they suddenly shift to the right on the page. Here's as close to a MWE (largely from the floatrow docs, mistakes mine) as I can get, showing it working properly and then shifted:

\documentclass[11pt]{article}
\usepackage{subfig}
\usepackage[heightadjust=all,valign=t]{floatrow}
\usepackage{fr-subfig}
\usepackage{lscape}
\begin{document}

\begin{table}
\floatbox{table}[\FBwidth]{\caption{Here's a caption}\label{tbl:table}}
{\begin{subfloatrow}
\subfloat[t1]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d \\
            e & f
    \end{tabular}}
\subfloat[t2]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d
    \end{tabular}}
\subfloat[t3]{
    \begin{tabular}{cc}
            abasdfsaabasdfsaabasdfsa & babasdfsa \\ 
            cabasdfsa & dabasdfsa
    \end{tabular}}

\end{subfloatrow}

\begin{subfloatrow}
\subfloat[t4]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d 
    \end{tabular}}
\subfloat[t5]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d \\
            e & f \\
            g & h
    \end{tabular}}
\end{subfloatrow}}
\end{table}


\begin{table}
\floatbox{table}[\FBwidth]{\caption{Here's a caption}\label{tbl:table2}}
{\begin{subfloatrow}
\subfloat[t1]{
    \begin{tabular}{cc}
            aabasdfsa & babasdfsa \\ 
            cabasdfsa & dabasdfsa \\
            eabasdfsa & fabasdfsa
    \end{tabular}}
\subfloat[t2]{
    \begin{tabular}{cc}
            aabasdfsa & babasdfsa \\ 
            cabasdfsa & dabasdfsa
    \end{tabular}}
\subfloat[t3]{
    \begin{tabular}{cc}
            abasdfsaabasdfsaabasdfsa & babasdfsa \\ 
            cabasdfsa & dabasdfsa
    \end{tabular}}

\end{subfloatrow}

\begin{subfloatrow}
\subfloat[t4]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d 
    \end{tabular}}
\subfloat[t5]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d \\
            e & f \\
            g & h
    \end{tabular}}
\end{subfloatrow}}
\end{table}
\end{document}

The results look like:

enter image description here

Also, you've probably noticed that the table numbering is completely wrong. I'm sure I'm just making a bunch of n00b mistakes here; any thoughts on how to fix this?

share|improve this question
    
Damnit, of course as soon as I post this, I find part of the answer; using \textwidth instead of \FBwidth solves the shifting problem. The docs even mention this explicitly by saying that it has to fit in the \hbox. I still don't know what's up with the table numbering, though. When I change the .tex to \textwidth, the tables are numbered 2 and 5! –  Winawer Jun 27 '12 at 5:16
add comment

1 Answer 1

up vote 1 down vote accepted

I thought that I would leave this here for posterity's sake. Combining my comment above (using \textwidth instead of \FBwidth) and the answer in this post: Incorrect figure numbering when using subfloats in a subfloatrow, as well as fixing a problem in my example (I haven't checked the docs, but I think that my caption was in the wrong place), led to this MWE that solves the problems I posed:

\documentclass[11pt]{article}
\usepackage{subfig}
\usepackage[heightadjust=all,valign=t]{floatrow}
\usepackage{fr-subfig}
\begin{document}

\begin{table}
\floatbox{table}[\textwidth]
{\begin{subfloatrow*}
\subfloat[t1]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d \\
            e & f
    \end{tabular}}
\subfloat[t2]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d
    \end{tabular}}
\subfloat[t3]{
    \begin{tabular}{cc}
            abasdfsaabasdfsaabasdfsa & babasdfsa \\ 
            cabasdfsa & dabasdfsa
    \end{tabular}}

\end{subfloatrow*}

\begin{subfloatrow*}
\subfloat[t4]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d 
    \end{tabular}}
\subfloat[t5]{
    \begin{tabular}{cc}
            a & b \\ 
            c & d \\
            e & f \\
            g & h
    \end{tabular}}
{\caption{Here's a caption}}
\end{subfloatrow*}}

\end{table}

\end{document}

which works:

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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