1

I am trying to get a regression table and a histogram graph next to each other on a page and am struggling to do so. I think there must be something wrong with my code but I can't see it. Any help would be amazing - you'd be a life saver!

I think it may be because of the white space in the table, which I am not sure of how to get rid of.

\begin{table}[ht]
\centering
    \begin{tabularx}{\linewidth}{*{2}{>{\centering\arraybackslash}X}}
\caption{Linear Regression of Wellbeing on EF.}
\label{calculatingEWEB}
    &   \captionof{figure}{Distribution of EWEB.}
        \label{fig:EWEBdis}

\begin{tabular}{lrr}
    \toprule
    Ecological Footprint & 0.139*** & 0.123*** \\
          & (0.035) & (0.035) \\
    Income (linear) && -0.072 \\
          &&(0.122) \\
    Income (quadratic) && 0.016 \\
          &&(0.013) \\
    Income (cubic) &&-0.000 \\
          && (0.000) \\
    Constant & 5.561*** &5.364*** \\
          & (0.265) & (0.337) \\
    \midrule
    R-squared & 0.041 & 0.084  \\
    \midrule
    *** p<0.01, ** p<0.05, * p<0.1 &       &  \\
    \end{tabular} &   \includegraphics[width=\linewidth,valign=c]{Figures/EWEB distrubtion.pdf} \\
\end{tabularx}
\end{table}
2
  • You can't place the caption command inside of tabularx. Instead of tabularx use two side by side minipages to position image and table side by side.
    – leandriis
    Jun 4, 2020 at 14:18
  • To get rid of the extra white space in the table use multicolumn for the "*** p<0.01, ** p<0.05..." cell.
    – leandriis
    Jun 4, 2020 at 15:26

2 Answers 2

1

Expanding on the comments of @leandriis, the following uses minipages, multicolumn, siunitx and subcaption to obtain what you seem to be looking for:

\documentclass{article}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry} % page margins
\usepackage{graphicx} % \multicolumn and \includegraphics
\usepackage{booktabs} % \toprule
\usepackage{subcaption} % subcaption
\usepackage{siunitx} % S column type (align by decimal)
\sisetup{parse-numbers=false} % allow parentheses in number column

\begin{document}
\setlength{\tabcolsep}{0.2em} % reduce separation between table columns

\begin{figure}
\caption{Linear Regression of Wellbeing on EF.} \label{calculatingEWEB}
\begin{minipage}{0.55\textwidth}
        \begin{tabular}{p{4cm} S
 S} % p{4cm} makes the table narrower; S treats entries as numbers (i.e. math mode) and centres on decimal point
        \toprule
        Ecological Footprint & 0.139^{\mathit{***}} & 0.123^{\mathit{***}} \\
        & (0.035) & (0.035) \\
        Income (linear) && -0.072 \\
        &&(0.122) \\
        Income (quadratic) && 0.016 \\
        &&(0.013) \\
        Income (cubic) &&-0.000 \\
        && (0.000) \\
        Constant & 5.561^{\mathit{***}} &5.364^{\mathit{***}} \\
        & (0.265) & (0.337) \\
        \midrule
        R-squared & 0.041 & 0.084  \\
        \midrule
        \multicolumn{3}{l}{*** p$ < $0.01, ** p$ < $0.05, * p$ < $0.1}\\ 
        % ensures the p-value row can straddle multiple columns 
        \end{tabular}
\end{minipage}
\hfill
\begin{minipage}{0.45\textwidth}
    \subcaption*{Distribution of EWEB.}
    \label{fig:EWEBdis}
    \includegraphics[width=\textwidth]{"<histogram>"}
\end{minipage}
\end{figure}

\end{document}

enter image description here

1

Here are three different options under the assumption that figure and table should each get their own caption:

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}

\usepackage{tabularx}
\usepackage{caption}
\usepackage[demo]{graphicx}
\usepackage[export]{adjustbox}

\usepackage{geometry}
\begin{document}

\begin{table}[ht]
\begin{minipage}[t]{0.5\textwidth}
\caption{Linear Regression of Wellbeing on EF.}
\label{calculatingEWEB}
\begin{tabular}{lrr}
    \toprule
    Ecological Footprint & 0.139*** & 0.123*** \\
          & (0.035) & (0.035) \\
    Income (linear) && -0.072 \\
          &&(0.122) \\
    Income (quadratic) && 0.016 \\
          &&(0.013) \\
    Income (cubic) &&-0.000 \\
          && (0.000) \\
    Constant & 5.561*** &5.364*** \\
          & (0.265) & (0.337) \\
    \midrule
    R-squared & 0.041 & 0.084  \\
    \midrule
    \multicolumn{3}{l}{*** p<0.01, ** p<0.05, * p<0.1}\\
    \end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{0.45\textwidth}
\captionof{figure}{Distribution of EWEB.}
\label{fig:EWEBdis}
\includegraphics[width=\linewidth,valign=c]{Figures/EWEB distrubtion.pdf}
\end{minipage}
\end{table}

\begin{table}[ht]
\begin{minipage}[t]{0.5\textwidth}
\caption{Linear Regression of Wellbeing on EF.}
\label{calculatingEWEB}
\sisetup{
    input-open-uncertainty   = ,
    input-close-uncertainty  = ,
    table-space-text-post = ***,
    table-space-text-pre = ),
    table-align-text-post=false, 
    table-align-text-pre=false
%    
}
\begin{tabular}{l*{2}{S[table-format=1.4]}}
    \toprule
    Ecological Footprint & 0.139*** & 0.123*** \\
          & (0.035) & (0.035) \\
    Income (linear) && -0.072 \\
          &&(0.122) \\
    Income (quadratic) && 0.016 \\
          &&(0.013) \\
    Income (cubic) &&-0.000 \\
          && (0.000) \\
    Constant & 5.561*** &5.364*** \\
          & (0.265) & (0.337) \\
    \midrule
    R-squared & 0.041 & 0.084  \\
    \midrule
    \multicolumn{3}{l}{*** p<0.01, ** p<0.05, * p<0.1}\\
    \end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{0.45\textwidth}
\captionof{figure}{Distribution of EWEB.}
\label{fig:EWEBdis}
\includegraphics[width=\linewidth,valign=c]{Figures/EWEB distrubtion.pdf}
\end{minipage}
\end{table}

\begin{table}[ht]
\begin{minipage}[t]{0.5\textwidth}
\centering
\caption{Linear Regression of Wellbeing on EF.}
\label{calculatingEWEB}
\sisetup{
    input-open-uncertainty   = ,
    input-close-uncertainty  = ,
    table-space-text-post = ***,
    table-space-text-pre = ),
    table-align-text-post=false, 
    table-align-text-pre=false
%    
}
\begin{tabular}{l*{2}{S[table-format=1.4]}}
    \toprule
    Ecological  & 0.139*** & 0.123*** \\
      Footprint     & (0.035) & (0.035) \\
    \addlinespace
    Income  && -0.072 \\
      (linear)    &&(0.122) \\
    \addlinespace
    Income  && 0.016 \\
      (quadratic)      &&(0.013) \\
    \addlinespace
    Income  &&-0.000 \\
      (cubic)     && (0.000) \\
    \addlinespace
    Constant & 5.561*** &5.364*** \\
          & (0.265) & (0.337) \\
    \midrule
    R-squared & 0.041 & 0.084  \\
    \midrule
    \multicolumn{3}{l}{*** p<0.01, ** p<0.05, * p<0.1}\\
    \end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{0.45\textwidth}
\captionof{figure}{Distribution of EWEB.}
\label{fig:EWEBdis}
\includegraphics[width=\linewidth,valign=c]{Figures/EWEB distrubtion.pdf}
\end{minipage}
\end{table}

\end{document}

You must log in to answer this question.

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