3

enter image description hereI made a table, but the column width is not even. I tried many methods, but still could not make the column width even. Strange things is that I have many other tables with the same style and their columns have the same width. I am really puzzled here. I appreciate any help on this issue. Thanks.

\documentclass[english,authoryear,12pt]{article} \usepackage{caption} \captionsetup[table]{justification=centering, labelsep=newline, font=bf, skip=1ex} \usepackage{tabularx,booktabs} \usepackage{tabularray} \usepackage{array} \usepackage{longtable} \usepackage[english]{babel} \usepackage{epstopdf} \usepackage{epsfig} %\usepackage{geometry} \usepackage{lscape} \usepackage{pdflscape} \usepackage{rotating} \usepackage{rotate} \usepackage{multirow} \usepackage{parskip} \usepackage[capposition=top]{floatrow} \usepackage{placeins} \usepackage{booktabs} \newcommand{\tabitem}{~~\llap{\textbullet}~~} \usepackage{adjustbox} \usepackage{url} \usepackage{subfigure} \usepackage{threeparttable} \usepackage{setspace} \usepackage{mathrsfs} \usepackage{authblk} \usepackage[authoryear,round]{natbib} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{mathtools} \usepackage{float} \usepackage{floatrow} \usepackage{siunitx} \usepackage{caption} \usepackage[colorlinks,citecolor=red,urlcolor=blue,bookmarks=false,hypertexnames=true]{hyperref} \usepackage{soul} \usepackage[toc,page]{appendix} \bibpunct{(}{)}{;}{a}{,}{,} \bibliographystyle{econ} \renewcommand\Authfont{\small} \renewcommand\Affilfont{\itshape\footnotesize} \renewcommand{\baselinestretch}{1} \sloppy \setcounter{MaxMatrixCols}{10} \setlength{\textheight}{215mm} \setlength{\textwidth}{160mm} \setlength{\oddsidemargin}{0pt} \setlength{\topmargin}{-20pt} \setlength{\headsep}{35pt} \setlength{\textwidth}{160mm} \setlength{\evensidemargin}{0pt} \setlength{\headheight}{12pt} \setlength{\parindent}{0.5cm} \setlength\parskip{0.1in} \providecommand{\lessgtr}{\stackrel{<}{>}} \IfFileExists{pslatex.sty}{ \usepackage{pslatex} }{} %\input{tcilatex} \DeclareUnicodeCharacter{2212}{-} \begin{document} \title{Title A} \pagebreak{} \clearpage \newpage \begin{table}[H]\footnotesize\setlength{\tabcolsep}{3pt} \caption{\textbf{Optimism} \label{tab:optimism}} \begin{tablenotes}[flushleft] \footnotesize \item We report the t-statistics in the parenthesis. *, **, and *** represent significance at the 10\%, 5\% and 1\% levels, respectively. \end{tablenotes} \smallskip \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}l*{3}{c}} \toprule &\multicolumn{3}{c}{ Hold/Underperform/Sell Recommendation} \\ \cmidrule (lr){2-4} \noalign{\smallskip} &\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\ \midrule & & & \\ X1 & -0.022*** & -0.021*** & -0.019*** \\ & (-3.274) & (-3.257) & (-3.042) \\ X2 & 0.007*** & 0.007*** & 0.008*** \\ & (3.005) & (3.161) & (5.149) \\ X3 & 0.008 & 0.016 & 0.017 \\ & (0.123) & (0.250) & (0.299) \\ X4 & 0.039* & 0.039* & 0.034* \\ & (1.830) & (1.823) & (1.803) \\ X5 & 0.004 & 0.005 & 0.004 \\ & (0.826) & (1.058) & (1.056) \\ & & & \\ Year Fixed Effects & YES & YES & YES \\ Firm Fixed Effects & YES & YES & YES \\ & & & \\ Observations & 71,060 & 71,060 & 71,060 \\ \bottomrule \end{tabular*} \end{table} \pagebreak{} \clearpage \newpage \end{document} 
7
  • Welcome to TeX.SE. Commented Oct 2, 2022 at 8:11
  • 1
    Did you try with tabularx? Commented Oct 2, 2022 at 8:24
  • Off-topic: Since your code runs \captionsetup[table]{justification=centering, labelsep=newline, font=bf, skip=1ex}, there's no need for \textbf in \caption{\textbf{Optimism}}. \caption{Optimism} will do. Commented Oct 2, 2022 at 8:52
  • 1
    forcing the table full width makes it much harder to read, are you sure you want that layout? Commented Oct 2, 2022 at 8:53
  • 1
    \IfFileExists{pslatex.sty}{\usepackage{pslatex} really?? I wrote pslatex around 1990 to match the fonts on a Sun (rebadged apple) laserwriter, I don't think I ever used it after we brought out latex2e in 1993. Odd to see it still being used. Commented Oct 2, 2022 at 8:57

2 Answers 2

2

Some suggestions:

  • Align the numbers in the three data columns on their respective decimal markers. This may be done with the D column type provided by the dcolumn package. Adopting this method automatically makes the column widths equal.

  • Impose more visual structure on the header material.

  • Use the macro \addlinespace (provided by the booktabs package) instead of all-blank lines to increase vertical spacing where needed.

enter image description here

\documentclass{article} % or some other suitable document class \usepackage{caption} \captionsetup[table]{justification=centering, labelsep=newline, font=bf, skip=1ex} \usepackage{booktabs,threeparttable} \usepackage[T1]{fontenc} %new code: \usepackage{dcolumn} \newcolumntype{d}[1]{D..{#1}} \newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macros \newcommand\mcx[1]{\multicolumn{1}{c@{}}{#1}} % for use in final column \begin{document} \begin{table}[ht] \centering \begin{threeparttable} \footnotesize % why? \caption{Optimism} \label{tab:optimism} \begin{tabular}{@{} l *{3}{d{4.6}} @{}} \toprule &\multicolumn{3}{c@{}}{Recommendation} \\ \cmidrule(l){2-4} & \mc{Hold} & \mc{Underperform} & \mcx{Sell} \\ & \mc{(1)} & \mc{(2)} & \mcx{(3)} \\ \midrule X1 & -0.022^{***} & -0.021^{***} & -0.019^{***} \\ & (-3.274) & (-3.257) & (-3.042) \\ \addlinespace X2 & 0.007^{***} & 0.007^{***} & 0.008^{***} \\ & (3.005) & (3.161) & (5.149) \\ \addlinespace X3 & 0.008 & 0.016 & 0.017 \\ & (0.123) & (0.250) & (0.299) \\ \addlinespace X4 & 0.039^{*} & 0.039^{*} & 0.034^{*} \\ & (1.830) & (1.823) & (1.803) \\ \addlinespace X5 & 0.004 & 0.005 & 0.004 \\ & (0.826) & (1.058) & (1.056) \\ \addlinespace Year FEs & \mc{Y} & \mc{Y} & \mcx{Y}\\ Firm FEs & \mc{Y} & \mc{Y} & \mcx{Y}\\ No.\ of Obs. & \mc{71,060} & \mc{71,060} & \mcx{71,060} \\ \bottomrule \end{tabular} \smallskip We report $t$-statistics in parentheses. *, **, and *** denote significance at the 10\%, 5\%, and 1\% levels, respectively. \end{threeparttable} \end{table} \end{document} 
1

As supplement to nice @mico answer (+1), with use of the tabularray package. It has longer table preamble, but shorter table body:

\documentclass{article} \usepackage{tabularray} \UseTblrLibrary{booktabs,siunitx} \ExplSyntaxOn \NewChildSelector{eachtwo} { \int_step_inline:nnnn {5}{2}{\l_tblr_childs_total_tl} { \clist_put_right:Nn \l_tblr_childs_clist {##1} } } \ExplSyntaxOff \usepackage{caption} \captionsetup[table]{justification=centering, labelsep=newline, font=bf, } \begin{document} \begin{table}[ht] \centering \NewTblrTheme{captionof}% { \DefTblrTemplate{caption}{default}% {\addtocounter{table}{-1}% \captionof{table}{\InsertTblrText{caption}}} } \SetTblrStyle{remark}{font=\footnotesize} \captionsetup[table]{skip=-0.5ex} \sisetup{ input-open-uncertainty =, input-close-uncertainty=, table-align-text-before=false, table-format={(}-1.3{***} } \begin{talltblr}[ theme = captionof, caption = {Optimism}, label = {tab:optimism}, remark{Note} = {We report $t$-statistics in parentheses. *, **, and *** denote significance at the \qty{10}{\%}, \qty{5}{\%}, and \qty{1}{\%} levels, respectively.} ]{colspec = {@{} l *{3}{Q[c, si]} @{}}, row{1-2}= {guard}, row{4-Z}= {rowsep=0 pt}, row{eachtwo} = {abovesep=1ex}, } \toprule &\SetCell[c=3]{c} Recommendation \\ \cmidrule{2-4} & {Hold\\ (1)} & {Underperform\\ (2)} & {Sell\\ (3)} \\ \midrule X1 & -0.022\TblrNote{***} & -0.021\TblrNote{***} & -0.019\TblrNote{***} \\ & (-3.274) & (-3.257) & (-3.042) \\ X2 & 0.007\TblrNote{***} & 0.007\TblrNote{***} & 0.008\TblrNote{***} \\ & (3.005) & (3.161) & (5.149) \\ X3 & 0.008 & 0.016 & 0.017 \\ & (0.123) & (0.250) & (0.299) \\ X4 & 0.039\TblrNote{*} & 0.039\TblrNote{*} & 0.034\TblrNote{*} \\ & (1.830) & (1.823) & (1.803) \\ X5 & 0.004 & 0.005 & 0.004 \\ & (0.826) & (1.058) & (1.056) \\ Year FEs & {Y} & {Y} & {Y} \\ Firm FEs & {Y} & {Y} & {Y} \\ No. of Obs. & {71,060} & {71,060} & {71,060} \\ \bottomrule \end{talltblr} \end{table} \end{document} 

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.