1

I’m sure this has been addressed somewhere before, but I’m having difficulty finding the answer and would greatly appreciate some help. I’ve tried inserting \centering or using the center environment in various places and can’t seem to figure it out.

I’m trying to center the table within the page, but it seems like the use of threeparttable pushes the table to the left - causing it to start immediately after the left margin. I want the distance from the table to the left edge of the page to be equal to the distance from the table to the right edge of the page. Here’s an example of my current setup:

\documentclass[authoryear, review, 12pt, times]{elsarticle}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{setspace}  % has commands for singlespacing, onehalfspacing, and doublespacing
\usepackage{mathrsfs}
\usepackage{IEEEtrantools}
%\usepackage{multirow}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{tabu}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}  % These 3 lines define new column types mainly to allow for centered column of user defined width
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
%\pagenumbering{gobble}      % Supresses page number 

\begin{document}

\begin{table}[ht!]
\begin{threeparttable}
\bfseries{\footnotesize{Table 1. Test Table.}} \\ [2mm]
\scriptsize
\normalfont
\begin{tabular}[pos]{L{7.0cm} R{2.0cm}} 
\toprule
\multicolumn{2}{c}{Dependent Variable: Outcome Var} \\ 
\midrule
$Variable 1$ & 0.123 \\
& (1.00) \\ [1.5mm]
$Variable 2$ & 0.456 \\
& (1.65) \\ [1.5mm]
$Variable 3$ & 0.789 \\
& (1.96) \\ [1.5mm]
$Variable 4$ & 1.123 \\
& (2.59) \\ [1.5mm]
$Variable 5$ & 1.456 \\
& (3.00) \\ [1.5mm]
$Variable 6$ & 1.789 \\
& (3.20) \\ [1.5mm]
$Variable 7$ & 2.000 \\
& (3.50) \\ [10.0mm]

Some Info & Yes \\ [0.5mm]
Other Info & No \\ [0.5mm]
Observations & Ample \\ [0.5mm]
Random Statistic & 1,505.37 \\ [0.5mm]
Last Piece of Info & 100.00 \\
\bottomrule
\end{tabular}
\centering
\caption{
\normalfont{\textnormal{This table displays information. It is just being used to see if I can actually center this thing, which has proved more difficult than anticipated. }}}
\label{tab:Test}
\end{threeparttable}
\end{table}
\end{document}
  • 1
    Welcome to TeX SX! Why do you use threeparttable, since you have no tablenotes? – Bernard Sep 4 '19 at 22:40
  • What is [pos] in \begin{tabular}[pos]{L{7.0cm} R{2.0cm}} supposed to do? – Mico Sep 4 '19 at 23:27
  • I had used the threeparttable, because it seemed to be an easier way to ensure the table caption is the same width as the table. I think I forgot to delete the [pos] from code that was copied from another example. – SteveK Sep 5 '19 at 15:13
2

There are two issues with your code:

  • There's no \centering instruction between \begin{table} and \begin{threeparttable}.

  • A threeparttable environment has three [surprise!] formal components: a caption, a tabular (or tabular*, or tabularx, etc) environment, and a tablenotes environment. With this in mind, the instruction

    \bfseries{\footnotesize{Table 1. Test Table.}} \\ [2mm]
    

    is out of place. You should either remove it or incorporate it in the tabular environment.

With these two adjustments, your formatting objective will be achieved immediately.

  • Thanks, I could have sworn I had tried placing the centering command there before, but maybe I had other issues at the time that prevented everything from compiling the way I wanted it. Also, good point on the the placement of the Table 1 heading. I moved it to within the tabular environment, which seems appropriate. – SteveK Sep 5 '19 at 15:00

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.