Page LayoutCentering captions and fixing Stata's automatic table #s.

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
scranney
Posts: 5
Joined: Mon Sep 03, 2012 10:08 pm

Centering captions and fixing Stata's automatic table #s.

Post by scranney »

Hi all,

I very new to Latex, so apologies in advance if this question is simple. I've been using commands in Stata that automatically create latex-code for statistical regression tables. I've been able to figure out everything except for two things: centering the captions, and fixing Stata's automatic table numbers.

According to what I've read, captions should be automatically centered in the middle of the table, but mine are skewed left (they look as if they are centering on only the first three columns, but I'm using six). I've tried using \centering but to no avail. Also, the Stata command has made it so that the table is automatically labelled "table 1" before the caption heading. That's fine, but I want to change the number and can't seem to find where in the code I can do that. My syntax is below; thanks in advance.

Code: Select all

\documentclass{article}
\begin{document}
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Logistic Regression Tables\label{tab1}}
\begin{tabular}{l*{6}{c}}
\hline\hline \\
[1em]
            &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}&\multicolumn{1}{c}{(5)}&\multicolumn{1}{c}{(6)}\\
            &\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}\\
\hline \\
[1em]
....Table-specific data below this point.
Last edited by cgnieder on Mon Sep 03, 2012 10:52 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: Centering captions and fixing Stata's automatic table #s

Post by cgnieder »

Hi scranney,

Welcome to the LaTeX community.

Would you mind completing your example so we could compile it? Besides the fact that neither table nor document do end right now there are also necessary packages missing.

Best regards
site moderator & package author
scranney
Posts: 5
Joined: Mon Sep 03, 2012 10:08 pm

Centering captions and fixing Stata's automatic table #s.

Post by scranney »

Apologies. The whole text is below. To reiterate: the "Logistic Regression Tables" is skewed left, and the table is labelled "table 1," and I can't figure out how to change the number.

Code: Select all

\documentclass{article}
\begin{document}
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Logistic Regression Tables\label{tab1}}
\begin{tabular}{l*{6}{c}}
\hline\hline \\
[1em]
            &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}&\multicolumn{1}{c}{(5)}&\multicolumn{1}{c}{(6)}\\
            &\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}\\
\hline \\
[1em]
No Belief    &      -0.378\sym{**} &      -0.367\sym{**} &      -0.657\sym{***}&      -0.341\sym{+}  &      -0.371\sym{+}  &      -0.398\sym{*}  \\
            &     (-2.96)         &     (-2.81)         &     (-4.66)         &     (-1.78)         &     (-1.93)         &     (-2.05)         \\
[1em]
Believe-Doubts&      -0.601\sym{***}&      -0.637\sym{***}&      -0.687\sym{***}&      -0.533\sym{***}&      -0.540\sym{***}&      -0.528\sym{***}\\
            &     (-7.21)         &     (-7.48)         &     (-7.54)         &     (-4.44)         &     (-4.47)         &     (-4.33)         \\
[1em]
Higher Power &      -0.532\sym{***}&      -0.549\sym{***}&      -0.676\sym{***}&      -0.359\sym{*}  &      -0.372\sym{*}  &      -0.403\sym{*}  \\
            &     (-4.51)         &     (-4.56)         &     (-5.22)         &     (-2.18)         &     (-2.24)         &     (-2.42)         \\
[1em]

Age(/10)       &                     &     -0.0580\sym{**} &     -0.0240         &     -0.0287         &     -0.0301         &     -0.0388         \\
            &                     &     (-2.89)         &     (-1.08)         &     (-1.01)         &     (-1.05)         &     (-1.35)         \\
[1em]
Male        &                     &      -0.250\sym{***}&      -0.309\sym{***}&      -0.342\sym{***}&      -0.342\sym{***}&      -0.344\sym{***}\\
            &                     &     (-3.62)         &     (-4.15)         &     (-3.72)         &     (-3.69)         &     (-3.70)         \\
[1em]
Black       &                     &      -0.315\sym{**} &      -0.164         &      -0.179         &      -0.214         &      -0.170         \\
            &                     &     (-3.07)         &     (-1.45)         &     (-1.31)         &     (-1.53)         &     (-1.20)         \\
[1em]
Other Race   &                     &      -0.596\sym{***}&      -0.465\sym{**} &      -0.453\sym{**} &      -0.472\sym{**} &      -0.428\sym{*}  \\
            &                     &     (-4.22)         &     (-3.04)         &     (-2.67)         &     (-2.74)         &     (-2.46)         \\
[1em]
Income      &                     &                     &      0.0309\sym{*}  &      0.0432\sym{*}  &      0.0425\sym{*}  &      0.0332         \\
            &                     &                     &      (2.00)         &      (2.16)         &      (2.11)         &      (1.63)         \\
[1em]
Years Education     &                     &                     &       0.134\sym{***}&       0.144\sym{***}&       0.143\sym{***}&       0.135\sym{***}\\
            &                     &                     &      (9.77)         &      (8.57)         &      (8.42)         &      (7.89)         \\
[1em]
Religious Person&                     &                     &                     &       0.261\sym{***}&       0.263\sym{***}&       0.235\sym{***}\\
            &                     &                     &                     &      (4.48)         &      (4.48)         &      (3.95)         \\
[1em]
Happy       &                     &                     &                     &                     &                     &      -0.272\sym{***}\\
            &                     &                     &                     &                     &                     &     (-3.77)         \\
[1em]
Year-fixed effects?       &                     Yes&                     Yes&                     Yes&                     Yes&                     Yes&      Yes\\
[1em]
Region-fixed effects?       &                     No&                     No&                     No&                     No&                     Yes&      Yes\\
[1em]
Constant      &       0.457\sym{***}&       0.952\sym{***}&      -1.277\sym{***}&      -2.534\sym{***}&      -2.502\sym{***}&      -1.629\sym{***}\\
            &      (7.37)         &      (7.49)         &     (-4.90)         &     (-6.62)         &     (-6.30)         &     (-3.61)         \\
[1em]
\hline\\
\(N\)       &        3708         &        3699         &        3339         &        2213         &        2213         &        2204         \\
\textit{BIC}&      5062.7         &      5042.9         &      4438.2         &      2937.4         &      2984.9         &      2965.7         \\
Chi-squared &       67.72         &       108.5         &       223.6         &       190.1         &       204.2         &       217.7         \\
Log-likelihood          &     -2506.7         &     -2480.4         &     -2170.4         &     -1422.5         &     -1415.4         &     -1402.0         \\
 &                     &                     &                     &                     &                     &                     \\
\hline\hline
\multicolumn{7}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\multicolumn{7}{l}{\footnotesize \sym{+} \(p<.10\), \sym{*} \(p<.05\), \sym{**} \(p<.01\), \sym{***} \(p<.001\)}\\
\end{tabular}
\end{table}
\end{document}
Last edited by Stefan Kottwitz on Tue Sep 04, 2012 8:08 am, edited 1 time in total.
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Centering captions and fixing Stata's automatic table #s.

Post by sommerfee »

scranney wrote:the "Logistic Regression Tables" is skewed left
It is centered, but since your table is too wide it just look like it isn't:

Code: Select all

Overfull \hbox (62.68123pt too wide) in paragraph at lines 6--64
I can't figure out how to change the number.

Code: Select all

\setcounter{table}{<whatever>}
, for example

Code: Select all

\setcounter{table}{12}
scranney
Posts: 5
Joined: Mon Sep 03, 2012 10:08 pm

Re: Centering captions and fixing Stata's automatic table #s

Post by scranney »

Thank you! The numbering works just the way I want it to now.

In regards to the other issue: I understand the "overfull" warning means that there's a justification problem. Does that mean that I can't just bump it a little bit to the right to make it look more centered? There has to be some way to do so.
Post Reply