[Tex/LaTex] Table template efficient table

tables

How do I center the second line of the title?

\documentclass[twocolumn]{article}

\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{caption}
\usepackage{textcomp}
\usepackage{graphicx}
\raggedbottom
\usepackage{amsmath,geometry}
\usepackage{rotating}
\usepackage{booktabs, makecell}
\usepackage[referable]{threeparttablex}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}
\usepackage{upquote}
\usepackage{balance}
\usepackage[lite]{mtpro2} % Times Roman math font
\usepackage{float}
\usepackage{wasysym}
\usepackage{footmisc}
\title{\LARGE \bf ECON 425 Term Paper}

\begin{document}

%TABLE:
    \begin{table}[H]
\caption{Difference in Means}
\label{tab:table1}
    \raggedright
Male and Female CEOs, 2010-2017

    \medskip
    \setlength\tabcolsep{4pt}
    \small
    \makegapedcells
\begin{tabularx}{\columnwidth}{@{}Lll @{}}
    \toprule
\thead[l]{\\} 
            &  \thead[l]{Male} 
                                & \thead[l]{Female\\} \\
    \midrule
N   &  528        & 13150          \\
Mean salary (thousands)
            & 873.5 (14.244)   & 824.4 (3.7423)       \\
    \addlinespace
Standard deviation   & 327.3             & 429.1             \\
t Value & 2.60$^{*}$   & 3.33   $^{*}$    \\

    \bottomrule
\end{tabularx}

\smallskip
$^{*}$ Significant at the 1\% level.
    \end{table}

\end{document}

enter image description here

SamCarter, could you help me with this table as well? For consistency. I can't manage to get the first line of the title, where it says "table 2: etc" using the \centering command.

\documentclass[twocolumn]{article}

\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{caption}
\usepackage{textcomp}
\usepackage{graphicx}
\raggedbottom
\usepackage{amsmath,geometry}
\usepackage{rotating}
\usepackage{booktabs, makecell}
\usepackage[referable]{threeparttablex}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}
\usepackage{upquote}
\usepackage{balance}
\usepackage[lite]{mtpro2} % Times Roman math font
\usepackage{float}
\usepackage{wasysym}
\usepackage{footmisc}
\title{\LARGE \bf ECON 425 Term Paper}

\begin{document}

%TABLE:
    \begin{table}[H]
     \centering
\caption{Estimates of pay-performance sensitivity}
\label{tab:table1}
OLS regressions of CEO salary and CEO total compensation on change in shareholder wealth. Standard errors in parentheses.

    \medskip
    \setlength\tabcolsep{4pt}
    \small
    \makegapedcells
\begin{tabularx}{\columnwidth}{@{}Lll @{}}
    \toprule
\thead[l]{Dependent\\ variable} 
            &  \thead[l]{CEO\\salary (\ref{eqn:first})} 
                                & \thead[l]{CEO total\\compensation (\ref{eqn:second})} \\
    \midrule
Intercept   &  434.319        & 6250.899          \\
Change in Shareholder Wealth (\%~Change)
            & -0.304 (.083)   & -2.638 (1.551)       \\
    \addlinespace
Adj R-squared   & 0.255             & 0.062             \\
F-statistic & 142.13$^{*}$   & 34.10$^{*}$    \\
Sample Size & 11537         & 11529          \\
    \bottomrule
\end{tabularx}

\smallskip
$^{*}$ Significant at the 1\% level.
    \end{table} 

\end{document}

enter image description here

Best Answer

for your second question (added later at editing first one) is not clear what is the problem. with your code with very small changes i obtain the following result:

enter image description here

\documentclass[twocolumn]{article}

\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{caption}

\title{\LARGE \textbf{ECON 425 Term Paper}}

\begin{document}

%TABLE:
    \begin{table}[htb]
\caption{Estimates of pay-performance sensitivity}
\label{tab:table1}
OLS regressions of CEO salary and CEO total compensation on change in shareholder wealth. Standard errors in parentheses.

    \medskip
    \setlength\tabcolsep{4pt}
    \small
    \makegapedcells
\begin{tabularx}{\columnwidth}{@{}L ll@{}}
    \toprule
\thead[l]{Dependent\\ variable}
            &  \thead[l]{CEO\\
                         salary\\
                         (\ref{eqn:first})}
                                    & \thead[l]{CEO total\\
                                            compensation\\
                                            (\ref{eqn:second})} \\
    \midrule
Intercept       &  434.319        & 6250.899                    \\
Change in Shareholder Wealth (\%~Change)
                & $-0.304$ (.083)   & $-2.638$ (1.551)          \\
    \addlinespace
Adj R-squared   & 0.255         & 0.062                         \\
F-statistic     & $142.13^*$    & $34.10^*$                     \\
Sample Size     & 11537         & 11529                         \\
    \bottomrule
\end{tabularx}

\smallskip
$^{*}$ Significant at the 1\% level.
    \end{table}
\end{document}

note: it is sufficient to load packages only once -:)

edit: formatting/appearance of cation is independent to positioning of figure/table. with the package caption is controlled by \captionsetup.

  • default settings is the following:
    • if the caption's text is narrower than column width (at two column document) or text width (at one column document) than it is centered
    • if the text is wider, than it is formatted as standard paragraph
  • in case, that you like to have left aligned also the single caption's text, then you should do the following:

    • in cases that this should be at all caption in your document, than load caption as:

    \usepackage[singlelinecheck=false]{caption}

    • in the case if this is desired only at one table/figure than after \begin{table} or `begin{figure} add

    \captionsetup{singlelinecheck=false}

    • in the case, that this settings should valid only for all tables (and not for figures), you should ad in document's preable

    \captionsetup[table]{singlelinecheck=false}

  • in the both aforementioned cases the caption text, if it is longer than column/text width is formatted as standard paragraph.

  • if you like to have in this cases centered last line of caption's text, than you need add to caption optionscenterlast`

  • for all possibilities of caption settings you should read package documentation. it is part of your latex installation

assuming that you like to have at all captions (i) size of the caption font small, (ii) caption label font bold, (iii) only one line text aligned left and longer caption's text formatted as standard paragraph, then you load caption as:

\usepackage[font=small,
            labelfont=bf,
            singlelinecheck=no]{caption}

and your caption will looks as:

enter image description here

and at longer caption text:

enter image description here

revised mwe consider above description can be:

\documentclass[twocolumn]{article}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{caption}
\captionsetup[table]{font=small,
                     labelfont=bf,
                     singlelinecheck=no}

\begin{document}
    \begin{equation}\label{eqn:first}
2+2=4
    \end{equation}
and
    \begin{equation}\label{eqn:second}
2-2\ne4
    \end{equation}
%TABLE:
    \begin{table}[htb]
\caption{Estimates of pay-performance sensitivity.}
\label{tab:table1}
OLS regressions of CEO salary and CEO total compensation on change in shareholder wealth. Standard errors in parentheses.

    \medskip
    \setlength\tabcolsep{4pt}
    \small
    \makegapedcells
\begin{tabularx}{\columnwidth}{@{}L ll@{}}
    \toprule
\thead[l]{Dependent\\ variable}
            &  \thead[l]{CEO\\
                         salary\\
                         (eq. \ref{eqn:first})}
                                    & \thead[l]{CEO total\\
                                            compensation\\
                                            (eq. \ref{eqn:second})} \\
    \midrule
Intercept       &  434.319        & 6250.899                    \\
Change in Shareholder Wealth (\%~Change)
                & $-0.304$ (.083)   & $-2.638$ (1.551)          \\
    \addlinespace
Adj R-squared   & 0.255         & 0.062                         \\
F-statistic     & $142.13^*$    & $34.10^*$                     \\
Sample Size     & 11537         & 11529                         \\
    \bottomrule
\end{tabularx}

\smallskip
$^{*}$ Significant at the 1\% level.
    \end{table}
\end{document}

enter image description here