2

I am trying to have this table done neat and nice, but I cannot manage to make the variable names fit into the lenght of the table itself. Here is the code:

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{tabularx}
\begin{document}

% -------Begin LaTeX code -------%

{
%\begin{adjustbox}

\begin{table}[htbp]\centering
 \caption{GMM Estimates of First-Differenced Investment Equations
\label{GMM Estimates of First-Differenced Investment Equations}}


\begin{adjustbox}{width=1\textwidth}

\begin{tabular}{p{2cm} p{1cm} p{1cm}p{2cm}p{2cm}p{1cm}p{1cm}p{1cm}}\hline\hline 
\multicolumn{1}{c}
{\textbf{Variable}}
 & {\textbf{Full Sample (1)}}  & \textbf{{Rated Sample (2)}} & {\textbf{Unrated Sample (3)}} & {\textbf{Variable}}
 & {\textbf{Full Sample (4)}}  & \textbf{{Rated Sample (5)}} & {\textbf{Unrated Sample (6)}}\\ \hline

    &   &   &   &   &   &   &\\

\hline
\multicolumn{1}{c}
{\textbf{Variable}}
 & {\textbf{Full Sample (7)}}  & \textbf{{Rated Sample (8)}} & {\textbf{Unrated Sample (9)}} & {\textbf{Variable}}
 & {\textbf{Full Sample (10)}}  & \textbf{{Rated Sample (11)}} & {\textbf{Unrated Sample(12)}} \\
\hline
&   &   &   &   &   &   &\\

\hline
\end{tabular}
\end{adjustbox}

\end{table}

}


%------- End LaTeX code -------%
%\end{adjustbox}
\end{document}

Could you please help me understand what is it that I am missing that I cannot make the text fit well? Thank you very much in advance for your time and help!

1

You might try something like this. I've simplified the example a little to reduce distractions:

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{tabularx}

\begin{document}

\begin{table}[htbp]\centering
  \caption{GMM Estimates of First-Differenced Investment Equations%
    \label{GMM Estimates of First-Differenced Investment Equations}}
  \small
  \begin{tabularx}{\textwidth}{*{8}{X}}\toprule
    \centering\sffamily Variable
     & \sffamily Full Sample (1)  & \sffamily Rated Sample (2) & \sffamily Unrated Sample (3) & \sffamily Variable
     & \sffamily Full Sample (4)  & \sffamily Rated Sample (5) & \sffamily Unrated Sample (6)\\\midrule

    \centering\sffamily Variable
     & \sffamily Full Sample (7)  & \sffamily Rated Sample (8) & \sffamily Unrated Sample (9) & \sffamily Variable
     & \sffamily Full Sample (10)  & \sffamily Rated Sample (11) & \sffamily Unrated Sample (12) \\\bottomrule
  \end{tabularx}

\end{table}

\end{document}

Tabular

2

Ideally, font sizes should be smaller for this table, but I will allow someone else to propose how to accomplish that. What I do here is merely introduce hyphenation points (\-) in your offending column to allow it to hyphenate within the column boundary.

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{tabularx}
\begin{document}

% -------Begin LaTeX code -------%

{
%\begin{adjustbox}

\begin{table}[htbp]\centering
 \caption{GMM Estimates of First-Differenced Investment Equations
\label{GMM Estimates of First-Differenced Investment Equations}}
\begin{adjustbox}{width=1\textwidth}


\begin{tabular}{p{2cm} p{1cm} p{1cm}p{2cm}p{2cm}p{1cm}p{1cm}p{1cm}}\hline\hline 
\multicolumn{1}{c}
{\textbf{Variable}}
 & {\textbf{Full Sample (1)}}  & \textbf{{Rated Sample (2)}} & {\textbf{Unrated Sample (3)}} & {\textbf{Variable}}
 & {\textbf{Full Sample (4)}}  & \textbf{{Rated Sample (5)}} & {\textbf{Un\-rated Sam\-ple (6)}}\\ \hline

    &   &   &   &   &   &   &\\

\hline
\multicolumn{1}{c}
{\textbf{Variable}}
 & {\textbf{Full Sample (7)}}  & \textbf{{Rated Sample (8)}} & {\textbf{Unrated Sample (9)}} & {\textbf{Variable}}
 & {\textbf{Full Sample (10)}}  & \textbf{{Rated Sample (11)}} & {\textbf{Un\-rated Sam\-ple (12)}} \\
\hline
&   &   &   &   &   &   &\\

\hline
\end{tabular}
\end{adjustbox}

\end{table}

}


%------- End LaTeX code -------%
%\end{adjustbox}
\end{document}

enter image description here

1

Adjusting some of the column widths, reducing the value of \tabcolsep (which governs the amount of intercolumn whitespace) by 25%, removing the whitespace to the left of the first column and to the right of the final column, and getting rid of some of the unneeded double curly braces lets the table fit into the text block without resorting to \adjustbox or reducing the font size:

enter image description here

\documentclass[12pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\setlength\tabcolsep{4.5pt} % default value: 6pt
\centering
\caption{GMM Estimates of First-Differenced Investment Equations}
\label{tab:GMMEstimates}    
\smallskip % provide a bit of separation between caption and tabular material

\begin{tabular}{@{} p{1.75cm}p{1cm}p{1.1cm}p{2cm} p{1.75cm}p{1cm}p{1.1cm}p{1.75cm} @{}}
\toprule 
\textbf{Variable} & \textbf{Full Sample (1)}  
& \textbf{Rated Sample (2)} & \textbf{Unrated Sample (3)} 
& \textbf{Variable} & \textbf{Full Sample (4)}  
& \textbf{Rated Sample (5)} & \textbf{Unrated Sample (6)}\\ 
\midrule
\\
\toprule
\textbf{Variable} & \textbf{Full Sample (7)}  
& \textbf{Rated Sample (8)} & \textbf{Unrated Sample (9)} 
& \textbf{Variable} & \textbf{Full Sample (10)}  
& \textbf{Rated Sample (11)} & \textbf{Unrated Sample (12)} \\
\midrule
\end{tabular}
\end{table}
\end{document}

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.