2

I am new to \LaTeX and consequently to the forum. However, I can promise I have gone through several different posts that dealt with this subject in one way or another, yet, I could not find a solution for the problem I am currently struggling with.

I have a big table that I want to fit in landscape environment. So far so good. However, no matter how hard I try, I am unable to centralize it on the page. It is always aligned in the left-hand side. There might be something to do with \multicolumn in a landscape environment but I am not quite sure. I also tried to abandon \begin{landscape} and use \usepackage{rotating} and \begin{sidewaystable} instead. Still failed. I have defined the table the way I did because I want decimals to be aligned and I do not want the stars to change the position of the numbers.

The code below is a rough example of what I am trying to do (numbers and table size are just fictive. There might be redundant packages or useless ones for the purposes of this question).

\documentclass[11pt]{article} 
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{pdflscape}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{float}
\usepackage[utf8]{inputenc}
\usepackage{setspace} 
\usepackage[pdftex]{graphicx}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage[flushleft]{threeparttable}
\usepackage[letterpaper, portrait, margin=1.30in]{geometry}
\usepackage{graphicx}
\usepackage{marvosym} 
\usepackage[maxcitenames=2, maxbibnames=5, date=year, doi=false, backend=bibtex, url=false, isbn=false, style=authoryear, uniquename=init,giveninits]{biblatex}
\usepackage{rotating}
\titlespacing\section{0pt}{11pt}{10pt}
\setlength{\topmargin}{0in}

\begin{document}

\begin{landscape}
\newcolumntype{d}{D{.}{.}{2.5}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\begin{table}[h]
\centering
\footnotesize
\captionsetup{font=footnotesize}
\caption{Regression output}
\label{output1st}
\begin{tabular}{l d d d d d d d d}
\toprule
\textbf{Variable} & \mc{\textbf{(1)}} & \mc{\textbf{(2)}} & \mc{\textbf{(3)}} & \mc{\textbf{(4)}} & \mc{\textbf{(5)}} & \mc{\textbf{(6)}} & \mc{\textbf{(7)}} & \mc{\textbf{(8)}} \\
\bottomrule
\hspace{3mm} \vspace{3mm} X & 0.001^{***} & 0.002 &  &  & &  &  & \\
\hspace{3mm} A & & \mc{ref} & \mc{$-$} & \mc{$-$} & \mc{$-$} & \mc{$-$} & \mc{$-$} & \mc{$-$}\\
\hspace{3mm} B & & -0.121^{***} & \mc{ref} & \mc{ref} & \mc{ref} & \mc{ref} & \mc{ref} & \mc{ref} \\
\hspace{3mm} C & & 0.017^{*} & -0.895^{**} & -0.944^{*} & 0.194^{***} & 0.67^{**} & 0.978 & -0.630^{**} \\
\hspace{3mm} \vspace{3mm} D & & -0.719^{***} & -0.741 &  0.046^{**} & 0.005^{***} & -0.501^{***} & 0.320^{***} & 0.574 \\
\hspace{3mm} Observations & \mc{6587} & \mc{1023} & \mc{131} & \mc{698} & \mc{452} & \mc{4155} & \mc{100} & \mc{354}\\
\hspace{3mm} Some Information & \mc{no} & \mc{yes} & \mc{yes} & \mc{yes} & \mc{yes} & \mc{yes} & \mc{yes} & \mc{yes}\\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item   {[Notes] Notes from the table.}
\end{tablenotes}
\end{table}
\end{landscape}
\pagebreak

\end{document}

What I could do in order to get is in the center of the page? Am I using any of the commands wrong? I have a feeling I am just overlooking something that could be obvious...

I would like to thank in advance for any further input!

IgB.
  • 23

1 Answers1

2

Adding the threeparttable environment and vfill helps. Note you don't have to load lscapeif you load pdflscape. Also the option [pdftex] option of graphicxis not necessary, and needless to load it twice:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{marvosym}
\usepackage[letterpaper, portrait, margin=1.30in, showframe]{geometry}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{pdflscape}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{float}
\usepackage{setspace}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{threeparttable}
\usepackage[maxcitenames=2, maxbibnames=5, date=year, doi=false, backend=bibtex, url=false, isbn=false, style=authoryear, uniquename=init,giveninits]{biblatex}
\titlespacing\section{0pt}{11pt}{10pt}
\setlength{\topmargin}{0in}

\begin{document}

\begin{landscape}
\newcolumntype{d}{D{.}{.}{2.5}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\setlength{\extrarowheight}{2pt}
\null\vfill
\begin{table}[h]
\centering\footnotesize
\begin{threeparttable}
\captionsetup{font=footnotesize}
\caption{Regression output}
\label{output1st}
\begin{tabular}{!{\hspace*{3mm}}l *{8}{d} }
\toprule
\multicolumn{1}{l}{\textbf{Variable}} & \mc{\textbf{(1)}} & \mc{\textbf{(2)}} & \mc{\textbf{(3)}} & \mc{\textbf{(4)}} & \mc{\textbf{(5)}} & \mc{\textbf{(6)}} & \mc{\textbf{(7)}} & \mc{\textbf{(8)}} \\
\midrule
\addlinespace
 X & 0.001^{***} & 0.002 \\
 A & & \mc{ref} & \mc{$-$} & \mc{$-$} & \mc{$-$} & \mc{$-$} & \mc{$-$} & \mc{$-$}\\
 B & & -0.121^{***} & \mc{ref} & \mc{ref} & \mc{ref} & \mc{ref} & \mc{ref} & \mc{ref} \\
 C & & 0.017^{*} & -0.895^{**} & -0.944^{*} & 0.194^{***} & 0.67^{**} & 0.978 & -0.630^{**} \\
 \addlinespace
 D & & -0.719^{***} & -0.741 & 0.046^{**} & 0.005^{***} & -0.501^{***} & 0.320^{***} & 0.574 \\
 Observations & \mc{6587} & \mc{1023} & \mc{131} & \mc{698} & \mc{452} & \mc{4155} & \mc{100} & \mc{354}\\
 Some Information & \mc{no} & \mc{yes} & \mc{yes} & \mc{yes} & \mc{yes} & \mc{yes} & \mc{yes} & \mc{yes}\\
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft, online]
\item[{[Notes]}] Notes from the table.
\end{tablenotes}
\end{threeparttable}
\end{table}
\vfill
\end{landscape}
\pagebreak

\end{document} 

enter image description here

Bernard
  • 271,350