3

I want to make the title all the way to the left side of the table but keep the whole table centered but have no idea how to do this. Can any expert help me with this? Thanks so much!

\documentclass{article}
\usepackage{booktabs,caption}
\usepackage[flushleft]{threeparttable}

\begin{document}
\begin{table}[htbp]

\footnotesize
\caption{Summary Statistic}
\label{Summary_statistic}
\topmargin=-25pt
\begin{center}
\scriptsize
\textbf{Table \ref{summary}: Descriptive Statistic}\\
\begin{tabular}{lccccc}
\toprule
                    &           N&        Mean&          SD&         Min&         Max\\
\midrule
\multicolumn{1}{l}{\textbf{\textit{Panel A: Internet Use Frequency:}}}&            &            &            &            &            \\
Heavy Usage         &      77,895&       0.249&       0.433&           0&           1\\
\\ \multicolumn{1}{l}{\textbf{\textit{Panel B: Individual Characteristics:}}}&            &            &            &            &            \\
Foreigner           &      77,895&       0.032&       0.176&           0&           1\\
Female              &      77,895&       0.550&       0.498&           0&           1\\
Parental Status     &      77,895&       0.402&       0.490&           0&           1\\
Household Size      &      77,895&       2.598&       1.359&           1&          10\\
Employed            &      77,895&       0.479&       0.500&           0&           1\\
Unemployed          &      77,895&       0.146&       0.353&           0&           1\\
Not in labor force  &      77,895&       0.375&       0.484&           0&           1\\
Divorced/Seperated  &      77,895&       0.084&       0.277&           0&           1\\
Married             &      77,895&       0.638&       0.480&           0&           1\\
Single              &      77,895&       0.176&       0.381&           0&           1\\
Widow               &      77,895&       0.101&       0.302&           0&           1\\
Age                 &      77,895&      49.817&      18.113&          15&          99\\
\\ \multicolumn{1}{l}{\textbf{\textit{Panel C: LTE Availability:}}}&            &            &            &            &            \\
Urban LTE Availability&      77,895&       0.604&       0.334&           0&           1\\
Rural LTE Availability&      77,895&       0.222&       0.309&           0&           1\\
Urban               &      77,895&       0.664&       0.472&           0&           1\\
Overall LTE availability &      77,895&       0.478&       0.378&           0&           1\\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\end{document}

enter image description here

2
  • I don't understand what effect you want? Can you describe it in more detail?
    – Clara
    Mar 12 at 0:05
  • Sure. I want to make the three titles all the way to the left and keep the table to be centered
    – Snow
    Mar 12 at 1:04

4 Answers 4

4

Remove the tabular column separation for the \multicolumn panel headings using @{}, that is,

\multicolumn{1}{@{}l}{...}

enter image description here

\documentclass{article}

\usepackage{booktabs,siunitx}
\newcommand{\panelfont}{\bfseries\itshape}

\begin{document}

\begin{table}
  \centering
  \textbf{Table 6: Descriptive Statistic}

  \begin{tabular}{
      l %
      S[table-format=5,group-separator={,}] % N
      S[table-format=2.3] % Mean
      S[table-format=2.3] % SD
      S[table-format=2] % Min
      S[table-format=2] %Max
  }
    \toprule
                             &  {N}  & {Mean} &  {SD}  & {Min} & {Max} \\
    \midrule
    \multicolumn{1}{@{}l}{\panelfont Panel A: Internet Use Frequency:}    \\
    Heavy Usage              & 77895 &  0.249 &  0.433 &   0   &   1   \\
    \addlinespace
    \multicolumn{1}{@{}l}{\panelfont Panel B: Individual Characteristics:}\\
    Foreigner                & 77895 &  0.032 &  0.176 &   0   &   1   \\
    Female                   & 77895 &  0.550 &  0.498 &   0   &   1   \\
    Parental Status          & 77895 &  0.402 &  0.490 &   0   &   1   \\
    Household Size           & 77895 &  2.598 &  1.359 &   1   &  10   \\
    Employed                 & 77895 &  0.479 &  0.500 &   0   &   1   \\
    Unemployed               & 77895 &  0.146 &  0.353 &   0   &   1   \\
    Not in labor force       & 77895 &  0.375 &  0.484 &   0   &   1   \\
    Divorced/Seperated       & 77895 &  0.084 &  0.277 &   0   &   1   \\
    Married                  & 77895 &  0.638 &  0.480 &   0   &   1   \\
    Single                   & 77895 &  0.176 &  0.381 &   0   &   1   \\
    Widow                    & 77895 &  0.101 &  0.302 &   0   &   1   \\
    Age                      & 77895 & 49.817 & 18.113 &  15   &  99   \\
    \addlinespace
    \multicolumn{1}{@{}l}{\panelfont Panel C: LTE Availability:}          \\
    Urban LTE Availability   & 77895 &  0.604 &  0.334 &   0   &   1   \\
    Rural LTE Availability   & 77895 &  0.222 &  0.309 &   0   &   1   \\
    Urban                    & 77895 &  0.664 &  0.472 &   0   &   1   \\
    Overall LTE availability & 77895 &  0.478 &  0.378 &   0   &   1   \\
    \bottomrule
  \end{tabular}
\end{table}

\end{document}
2
  • 1
    +1. Wouldn't @{} be simpler than @{\hspace{0pt}}?
    – Mico
    Mar 12 at 3:55
  • @Mico: Yes! Thanks!
    – Werner
    Mar 12 at 4:11
3

I am puzzled about your design and wonder why you don't put the description in the caption. I used tabularray to complete the layout of the table and did some beautification. I don't know if it meets your expectations.

\documentclass{article}
\usepackage{xcolor}
\usepackage{tabularray}
\begin{document}
\begin{table}
\caption{Summary Statistic}
\label{Summary_statistic}
This table reports summary statistics of the analytical sample during the period from 2012 to 2014. Panel A shows heavy Internet user status based on people's Internet usage. Panel B shows individual characteristics. Panel C shows the summary statistics of residential LTE broadband availability.\\
\begin{center}
\textbf{\tablename~\ref{Summary_statistic}\\Continued\\Internet use and cybercrimes: OLS analysis}\\
\begin{tblr}
{
colspec         = {Q[c,m]Q[c,m]Q[c,m]Q[c,m]Q[c,m]Q[c,m]},
hline{1,Z}      = {wd=.08em},
hline{2}        = {wd=.05em},
cell{2,4,17}{1} = {c=6}{font=\bfseries\itshape,halign=l,bg=gray9!50},
}
                                     & N      & Mean   & SD     & Min & Max \\
Panel A: Internet Use Frequency:     &        &        &        &     &     \\
Heavy Usage                          & 77,895 & 0.249  & 0.433  & 0   & 1   \\
Panel B: Individual Characteristics: &        &        &        &     &     \\
Foreigner                            & 77,895 & 0.032  & 0.176  & 0   & 1   \\
Female                               & 77,895 & 0.550  & 0.498  & 0   & 1   \\
Parental Status                      & 77,895 & 0.402  & 0.490  & 0   & 1   \\
Household Size                       & 77,895 & 2.598  & 1.359  & 1   & 10  \\
Employed                             & 77,895 & 0.479  & 0.500  & 0   & 1   \\
Unemployed                           & 77,895 & 0.146  & 0.353  & 0   & 1   \\
Not in labor force                   & 77,895 & 0.375  & 0.484  & 0   & 1   \\
Divorced/Seperated                   & 77,895 & 0.084  & 0.277  & 0   & 1   \\
Married                              & 77,895 & 0.638  & 0.480  & 0   & 1   \\
Single                               & 77,895 & 0.176  & 0.381  & 0   & 1   \\
Widow                                & 77,895 & 0.101  & 0.302  & 0   & 1   \\
Age                                  & 77,895 & 49.817 & 18.113 & 15  & 99  \\
Panel C: LTE Availability:           &        &        &        &     &     \\
Urban LTE Availability               & 77,895 & 0.604  & 0.334  & 0   & 1   \\
Rural LTE Availability               & 77,895 & 0.222  & 0.309  & 0   & 1   \\
Urban                                & 77,895 & 0.664  & 0.472  & 0   & 1   \\
Overall LTE availability             & 77,895 & 0.478  & 0.378  & 0   & 1   \\
\end{tblr}
\end{center}
\end{table}
\end{document}

enter image description here

2
  • I appreciate your comments and help. Please only help me with my questions instead of changing almost everything and creating a new table that is undesirable for me...
    – Snow
    Mar 12 at 2:02
  • 2
    @Snow Often enough changing the layout of a table is a valuable proposal on this site. Mar 12 at 3:48
2

I'm not sure if I've understood your formatting objective, viz.

I want to make the title all the way to the left side of the table but keep the whole table centered

I've interpreted this objective as requiring a combination of (a) a threeparttable environment to encase both the \caption directive and the tabular environment and (b) a \captionsetup directive with the options justification=raggedright and singlelinecheck=false.

I can't help but observe that the \multicolumn{1}{l}{...} wrappers for the three subtitles are redundant. Either omit these wrappers entirely or replace them with \multicolumn{6}{l}{...} wrappers -- as I've done in the code below.

The framelines at the edges of the following screenshot are drawn because the showframe package is loaded for this test document. You needn't load this package in your real document.

enter image description here

\documentclass{article}
\usepackage{booktabs,caption}
\usepackage[flushleft]{threeparttable}

\usepackage{showframe} % just for this example

\begin{document}
\null % just for this example

\begin{table}[htbp]
\captionsetup{font={bf,footnotesize}, % not sure about "bf"
              justification=raggedright,
              singlelinecheck=false,
              skip=0.25\baselineskip}
\centering
\footnotesize

\begin{threeparttable}
\caption{Summary Statistics}
\label{Summary_statistic}

%\scriptsize % why so many font size changes, and why \scriptsize?
%\textbf{Table \thetable: Descriptive Statistics}\\ % redundant, no?

\begin{tabular}{@{} l ccccc @{}}
\toprule
                    &           N&        Mean&          SD&         Min& Max\\
\midrule
\multicolumn{6}{@{}l}{\textbf{\textit{Panel A: Internet Use Frequency}}} \\
Heavy Usage         &      77,895&       0.249&       0.433&           0& 1 \\
\addlinespace
\multicolumn{6}{@{}l}{\textbf{\textit{Panel B: Individual Characteristics}}} \\
Foreigner           &      77,895&       0.032&       0.176&           0& 1 \\
Female              &      77,895&       0.550&       0.498&           0& 1 \\
Parental Status     &      77,895&       0.402&       0.490&           0& 1 \\
Household Size      &      77,895&       2.598&       1.359&           1& 10\\
Employed            &      77,895&       0.479&       0.500&           0& 1 \\
Unemployed          &      77,895&       0.146&       0.353&           0& 1 \\
Not in labor force  &      77,895&       0.375&       0.484&           0& 1 \\
Divorced/Seperated  &      77,895&       0.084&       0.277&           0& 1 \\
Married             &      77,895&       0.638&       0.480&           0& 1 \\
Single              &      77,895&       0.176&       0.381&           0& 1 \\
Widow               &      77,895&       0.101&       0.302&           0& 1 \\
Age                 &      77,895&      49.817&      18.113&          15& 99\\
\addlinespace
\multicolumn{6}{@{}l}{\textbf{\textit{Panel C: LTE Availability}}} \\
Urban LTE Availability&    77,895&       0.604&       0.334&           0& 1 \\
Rural LTE Availability&    77,895&       0.222&       0.309&           0& 1 \\
Urban                 &    77,895&       0.664&       0.472&           0& 1 \\
Overall LTE availability & 77,895&       0.478&       0.378&           0& 1 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}

\end{document}
2
  • Thank you so much!
    – Snow
    Mar 19 at 7:08
  • @Snow - You're most welcome! Just curious: Was my interpretation of your formatting objective on target, or did you have something quite different in mind? Please advise.
    – Mico
    Mar 19 at 7:17
2
  • With tabularray package, where caption formatting is left to caption package.
  • Used is talltblr table, a tabularray equivalent for threeparttable.

Edit:

  • For panel titles is defined new command (by \NewTableComman), which collect setting for this row: \setCell[c=6]{...}, font shape and face
  • Since \SetCell doesn't enable (as far as I know) to change cell column separation with use of @{} indent (hang) of the panel titles texts, to \panel command is introduced `\SetRow{...} for adding space above title (where needed) and shift row content to the left:
\documentclass{article}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document

\usepackage[skip=1ex,
            font={bf,small},
            singlelinecheck=false]{caption}

\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
    \DefTblrTemplate{caption}{default}{\addtocounter{table}{-1}%
                                       \captionsetup{aboveskip=-1ex, belowskip=1ex}%
                                       \captionof{table}{\InsertTblrText{caption}}}
    \SetTblrStyle{remark}{font=\footnotesize}
\NewTableCommand\panel[1][2ex]{%
        \SetRow{abovesep+=#1, preto=\hspace{-1em}}
        \SetCell[c=6]{font=\bfseries\itshape}
                              }
\sisetup{group-separator={,}}

\begin{document}
\lipsum[66]

\begin{talltblr}[
caption = {Summary Statistic},
  label = {Summary_statistic},
remark{Note} = {N: Number of sample, SD: Standard Deviation}
                ]{colspec = {Q[l,leftsep=1em]
                            Q[c, si={table-format=5.0}]
                            *{2}{Q[c, si={table-format=2.3}]}
                            *{2}{Q[c, si={table-format=2.0}]}
                            },
                 rowsep  = 1pt,
                 row{1}  = {guard},
                 }
    \toprule
                                & N     & Mean      & SD        & Min   & Max   \\
    \midrule
\panel[0pt]
Panel A: Internet Use Frequency:
                                &       &           &           &       &       \\
    Heavy Usage                 & 77895 &  0.249    &  0.433    &  0    &   1   \\
\panel  Panel B: Individual Characteristics:
                                &       &           &           &       &       \\
    Foreigner                   & 77895 &  0.032    &  0.176    &   0   &   1   \\
    Female                      & 77895 &  0.550    &  0.498    &   0   &   1   \\
    Parental Status             & 77895 &  0.402    &  0.490    &   0   &   1   \\
    Household Size              & 77895 &  2.598    &  1.359    &   1   &  10   \\
    Employed                    & 77895 &  0.479    &  0.500    &   0   &   1   \\
    Unemployed                  & 77895 &  0.146    &  0.353    &   0   &   1   \\
    Not in labor force          & 77895 &  0.375    &  0.484    &   0   &   1   \\
    Divorced/Separated          & 77895 &  0.084    &  0.277    &   0   &   1   \\
    Married                     & 77895 &  0.638    &  0.480    &   0   &   1   \\
    Single                      & 77895 &  0.176    &  0.381    &   0   &   1   \\
    Widow                       & 77895 &  0.101    &  0.302    &   0   &   1   \\
    Age                         & 77895 & 49.817    & 18.113    &  15   &  99   \\
\panel  Panel C: LTE Availability:
                                &       &           &           &       &       \\
    Urban LTE Availability      & 77895 &  0.604    &  0.334    &   0   &   1   \\
    Rural LTE Availability      & 77895 &  0.222    &  0.309    &   0   &   1   \\
    Urban                       & 77895 &  0.664    &  0.472    &   0   &   1   \\
    Overall LTE availability    & 77895 &  0.478    &  0.378    &   0   &   1   \\
    \bottomrule
  \end{talltblr}\medskip

\lipsum[11]
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .