3

I have a table with multiple panels. I use the subtable package for to get the panels. My question is how could I place the caption for the overall table (the description of the entire table) on top? And then notes at the bottom? The sample code is below. The other packages I use are

   \documentclass[12pt]{article}
   \usepackage{rotating}
   \usepackage{longtable}
   \usepackage{float}
   \restylefloat{table}
   \usepackage{subcaption}
   \usepackage{tabularx} % for better tables
   \usepackage{booktabs}



    \begin{document}

     \begin{table}
     \centering
     \caption{This table shows the details}
     \begin{subtable}[t]{\linewidth}
     \centering
     \vspace{0pt}
     \begin{tabular}{@{\extracolsep{5pt}} lccc} 
     \toprule 
     \toprule
          Year & $2002$ & $2003$ & $2004$ \\ 
          \midrule
           model1 & $1.703$ & $1.339$ & $1.238$  \\ 
           model2 & $2.104$ & $1.920$ & $1.774$  \\ 
        \bottomrule
     \end{tabular} 
     \caption{Panel A: One year ahead}
     \vspace{0.7cm}

     \begin{tabular}{@{\extracolsep{5pt}} lccc} 
     \toprule 
     \toprule
           Year & $2002$ & $2003$ & $2004$ \\ 
           \midrule
            model1 & $1.703$ & $1.339$ & $1.238$  \\ 
            model2 & $2.104$ & $1.920$ & $1.774$  \\ 
           \bottomrule
       \end{tabular} 
      \caption{Panel B: Two year ahead}
    \end{subtable}\hfill
 \end{table}

      \end{document}
4
  • Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. A MWE should compile and be as small as possible to demonstrate your problem. it's much easier to help you if we have full working code to start from.
    – user30471
    Oct 16 '16 at 21:51
  • @Andrew Edited the code now.
    – rajvijay
    Oct 16 '16 at 22:10
  • Shouldn't you have 2 subtable environments rather than just one?
    – cfr
    Oct 16 '16 at 22:52
  • \restylefloat{table} moves the caption below the table. Just delete it to restore the default.
    – cfr
    Oct 16 '16 at 23:01
0

\restylefloat{table} causes the caption to be moved below the tables. Simply remove it to prevent this.

Double rules are really neither necessary nor appropriate: \toprule is already heavy to mark the boundary and doubling it just looks cluttered.

Also, you surely want a subtable environment per panel and not one containing both. At least, I assume.

I've removed some packages irrelevant to your example as they don't belong in an MWE, but you can obviously restore them if you need them in your real document.

I've left float just to show that it is not the package itself which causes the change.

\documentclass[12pt]{article}
\usepackage{float}
\usepackage{subcaption}
\usepackage{booktabs}

\begin{document}    
\begin{table}
  \centering
  \caption{This table shows the details}
  \begin{subtable}[t]{\linewidth}
    \centering
    \vspace{0pt}
    \begin{tabular}{@{\extracolsep{5pt}} lccc}
      \toprule
      Year & $2002$ & $2003$ & $2004$ \\
      \midrule
      model1 & $1.703$ & $1.339$ & $1.238$  \\
      model2 & $2.104$ & $1.920$ & $1.774$  \\
      \bottomrule
    \end{tabular}
    \caption{Panel A: One year ahead}
  \end{subtable}
  \begin{subtable}[t]{\linewidth}
    \centering
    \begin{tabular}{@{\extracolsep{5pt}} lccc}
      \toprule
      Year & $2002$ & $2003$ & $2004$ \\
      \midrule
      model1 & $1.703$ & $1.339$ & $1.238$  \\
      model2 & $2.104$ & $1.920$ & $1.774$  \\
      \bottomrule
    \end{tabular}
    \caption{Panel B: Two year ahead}
  \end{subtable}
\end{table}
\end{document}

2 subtables with caption above

2
  • Works great. How about the other part of my question -- notes on the bottom of the table? Is that a possibility?
    – rajvijay
    Oct 16 '16 at 23:33
  • @rajvijay To be honest, I don't really know what you mean. Which table needs the notes? I'd use threeparttable or threeparttablex. But it is hard to tell without more information.
    – cfr
    Oct 16 '16 at 23:39

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.