Graphics, Figures & Tablesthreeparttable | Center the Table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mariaXY
Posts: 9
Joined: Wed Jul 06, 2011 11:00 am

threeparttable | Center the Table

Post by mariaXY »

Hi everybody!!!

I've been looking for the solution for centering a table... Anything hasn't been useful so far, so I hope somebody can help me.

I want to put a footnote in a table. Here is the code:

Code: Select all

\begin{table}[t!]
\centering
\begin{threeparttable}
\captionsetup{font=small, labelfont=bf, labelsep=period}
\caption[Table]{Text\tnote{a}.}
\label{table1}
{\small
\begin{tabular}{l c c}

%\hline%
X & Y & Z \\
  & y & z \\
\hline
X & Y & Z \\
X & Y & Z \\
\hline
\end{tabular}
}
\vspace*{-0.7cm}
\begin{tablenotes}
\item[a] {\footnotesize Footnote}
\end{tablenotes}
\end{threeparttable}
\end{table}
I obtain the footnote in a proper way. My problem is that I got the table left aligned... It doesn't matter where I put the \centering or \begin{center}-\end{center}... I want to center that table... Please somebody help me!!!

Thanks in advance,

Maria
Last edited by mariaXY on Wed Sep 14, 2011 9:32 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

threeparttable | Center the Table

Post by localghost »

Please get used to always providing a minimal example that shows the undesired behaviour clearly and is compilable out of the box. This is essential especially when a problems is more complicated. People are rarely motivated to build a complete example just to test possible solutions for you.

The below example centers the table as desired. Note the booktabs package to enhance the appearance of the table.

Code: Select all

\documentclass[11pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{caption}
\usepackage{booktabs,threeparttable}

\captionsetup{font=small,labelfont=bf,labelsep=period}

\begin{document}
  \begin{table}[!ht]
    \caption[Table]{Text\tnote{a}.}\label{table1}
    \centering
    \begin{threeparttable}
      \small
      \begin{tabular}{lcc}\toprule
        X & Y & Z \\
          & y & z \\ \midrule
        X & Y & Z \\
        X & Y & Z \\ \bottomrule
      \end{tabular}
      \begin{tablenotes}
        \footnotesize
        \item[a] Footnote
      \end{tablenotes}
    \end{threeparttable}
  \end{table}
\end{document}

Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
mariaXY
Posts: 9
Joined: Wed Jul 06, 2011 11:00 am

threeparttable | Center the Table

Post by mariaXY »

Hi localghost!

Thanks a lot for your help. It works now, and I have a beautiful table in my thesis. Consider this post solved. Just a few comments and my final code to obtain the table.

I think the booktabs was the solution, and since my footmark is in the caption, you can not put the threeparttable below the caption. In any case, here is my final code:

Code: Select all

\documentclass[a4paper,11pt]{book}
\usepackage{caption}
\usepackage{booktabs,threeparttable}

\begin{document}
  \begin{table}[!ht]
    \centering
    \begin{threeparttable}
    \captionsetup{font=small,labelfont=bf,labelsep=period}
    \caption[Table]{Text\tnote{a}.}\label{table1}
      \small
      \begin{tabular}{lcc}
        X & Y & Z \\
          & y & z \\
      \hline
        X & Y & Z \\
        X & Y & Z \\
      \hline
      \end{tabular}
      \vspace*{-0.7cm} % small space between table and footnote
      \begin{tablenotes}
        \footnotesize
        \item[a] Footnote
      \end{tablenotes}
    \end{threeparttable}
  \end{table}
\end{document}
Post Reply