2

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

  • 2
    1. What is SAS? 2. Code? Any effort you made until now? Which exercises should the template solve? What does the input data look like? If it's just about how to draw pretty tables in LaTeX, there are tons of examples on TeX.SX. – Skillmon May 4 '18 at 18:15
  • @Skillmon i'll add what I have so far to the original post. – texmex May 4 '18 at 19:02
  • 1
    but this table content is very different from what you show in images? and this code was some days ago shown here from another user, see tex.stackexchange.com/questions/427244/… – Zarko May 4 '18 at 19:16
  • @Zarko probably me! I changed my name recently. And that's the point -- that's why im asking for suggestions for summary statistics templates instead of trying to adapt the regression table – texmex May 4 '18 at 19:19
  • 1
    @texmex, how we can know, what is in your table? show us, what you try so far, not a table already used in your previous question. we cant help you if we not know what should be in table. please, provide table content. as base for this you can use by you accepted answer. – Zarko May 4 '18 at 19:25
4

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

  • Zarko, how come there are question marks where the reference numbers once were? – texmex May 4 '18 at 21:01
  • because the labels for this reference is not presented in this mwe. when those equation will added to this document, the question mark will be replaced by equations numbers. – Zarko May 4 '18 at 21:51
  • Sam Carter, / Zarko, /why isnt the @ sign working? I want to shift the title caption back to the left (not centered) how can I do this? I used \raggedright again but it only moved 2 out of the 3 pieces. I can put a MWE in the original post if you'd like – texmex May 5 '18 at 0:51
  • @texmex, see my edited answer. – Zarko May 5 '18 at 7:18
3

To centre the second text line, replace \raggedright by \centering.

Off-topic: you should not use \bf, see Does it matter if I use \textit or \it, \bfseries or \bf, etc

\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 \textbf{ECON 425 Term Paper}}

\begin{document}

%TABLE:
    \begin{table}[H]
\caption{Difference in Means}
\label{tab:table1}
%    \raggedright
\centering
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

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.