组合 Landscape + ThreepartTable + TabularX 时的格式问题

组合 Landscape + ThreepartTable + TabularX 时的格式问题
  1. 我希望附加的表格(threeparttable)横跨整个页面(横向),并且第 2 列至第 33 列的宽度相同(tabularx)。
  2. 我希望第 1 列前两行的标题格式像本图所示的那样。

在此处输入图片描述

我知道表格设计并不理想,但我需要在一个页面上显示所有信息,对我来说这是唯一可行的方法。任何帮助都非常感谢!

\documentclass[authoryear,11pt]{elsarticle}

%Packages
\usepackage[utf8]{inputenc}
%\usepackage[latin1]{inputenc}
%\usepackage[ansinew]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, eurosym}
\usepackage{lscape}
\usepackage[showframe]{geometry}
\usepackage{ragged2e}
\usepackage{setspace}
\usepackage{graphicx, rotating}
\usepackage{amsmath}
\usepackage{natbib}
\usepackage[table]{xcolor}
\usepackage{booktabs, makecell, longtable, tabularx, threeparttable}
\usepackage[font=small]{caption}
\usepackage{soul}
\usepackage{endnotes}
\usepackage{siunitx}
%\usepackage{endfloat} %package puts tables and figures to the end
\usepackage[breaklinks=true,hidelinks,colorlinks=true,linkcolor=blauelsevier,urlcolor=blauelsevier, citecolor=blauelsevier]{hyperref}
\usepackage{etoolbox}
\usepackage{lipsum}
\usepackage{tabu}
\usepackage{pdflscape}
\usepackage{scrhack} 
\usepackage{selinput}

\robustify{\bfseries}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newenvironment{mytable}{\begin{center}\begin{footnotesize}\begin{onehalfspacing}}{\end{onehalfspacing}\end{footnotesize}\end{center}}

%Settings
\makeatletter
\def\ps@pprintTitle{%
  \let\@oddhead\@empty
  \let\@evenhead\@empty
  \def\@oddfoot{\leftline{\footnotesize \textit{\today}}}%
  \let\@evenfoot\@empty
}
\makeatother
%\DeclareDelayedFloatFlavor{sidewaysfigure}{figure}
%\DeclareDelayedFloatFlavor{sidewaystable}{table}
%\DeclareDelayedFloatFlavour{threeparttable}{table}
%\DeclareDelayedFloatFlavour{longtable}{table}


%11pt
\setlength\textheight{215mm}
\setlength\textwidth{140mm}
\setlength\marginparwidth{00mm}
\setlength\oddsidemargin{12.5mm}
\setlength\topmargin{-10mm}
\addtolength{\footnotesep}{0.5mm}

%12pt
%\setlength\textheight{225mm}
%\setlength\textwidth{140mm}
%\setlength\marginparwidth{00mm}
%\setlength\oddsidemargin{15mm}
%\setlength\topmargin{-10mm}
%\addtolength{\footnotesep}{0.5mm}


%Cover page
\begin{document}

%\vspace*{\fill}

%\begin{sidewaystable}
\begin{landscape}

%\setlength\tabcolsep{4pt} % default: 6pt
\tiny
\singlespacing
%\centering
\sisetup{detect-weight}

\renewcommand\theadfont{\tiny}
\settowidth{\rotheadsize}{\tiny\bfseries Totall}
\renewcommand{\theadalign}{bc}

\begin{threeparttable}

\caption{\label{tab:tab_reformdata} tbd}

\begin{tabularx}{\textheight}{@{}
                       lCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC@{}}
    \toprule

        \thead{(1)} & \thead{(2)} & \thead{(3)} & \thead{(4)} & \thead{(5)} & \thead{(6)} & \thead{(7)}  & \thead{(8)}  & \thead{(9)}  & \thead{(10)}  & \thead{(11)}  & \thead{(12)}  & \thead{(13)}  & \thead{(14)}  & \thead{(15)}  & \thead{(16)} & \thead{(17)}  & \thead{(18)}  & \thead{(19)}  & \thead{(20)}  & \thead{(21)}  & \thead{(22)}  & \thead{(23)}  & \thead{(24)}  & \thead{(25)}  & \thead{(26)} & \thead{(27)} & \thead{(28)} & \thead{(29)} & \thead{(30)} & \thead{(31)} & \thead{(32)} & \thead{(33)}\\

        \cmidrule{1-33} 

    \thead[lb]{\bfseries Country}
    & \rothead{\bfseries 1985} 
        & \rothead{\bfseries 1986}
    & \rothead{\bfseries 1987}
    & \rothead{\bfseries 1988}
    & \rothead{\bfseries 1989}
    & \rothead{\bfseries 1990}
    & \rothead{\bfseries 1991}
    & \rothead{\bfseries 1992}
    & \rothead{\bfseries 1993}
    & \rothead{\bfseries 1994}
    & \rothead{\bfseries 1995}
    & \rothead{\bfseries 1996}
    & \rothead{\bfseries 1997}
    & \rothead{\bfseries 1998}
    & \rothead{\bfseries 1999}
    & \rothead{\bfseries 2000}
    & \rothead{\bfseries 2001}
    & \rothead{\bfseries 2002}
    & \rothead{\bfseries 2003}
    & \rothead{\bfseries 2004}
    & \rothead{\bfseries 2005}
    & \rothead{\bfseries 2006}
    & \rothead{\bfseries 2007}
    & \rothead{\bfseries 2008}
    & \rothead{\bfseries 2009}
    & \rothead{\bfseries 2010}
    & \rothead{\bfseries 2011}
    & \rothead{\bfseries 2012}
    & \rothead{\bfseries 2013}
    & \rothead{\bfseries 2014}
    & \rothead{\bfseries 2015}
    & \rothead{\bfseries Total}\\

\midrule
Austria &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       & \textbf{2} \\
Belgium &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       & \textbf{2} \\
Denmark &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       & \textbf{2} \\
Finland &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       &       &       &       &       & \textbf{2} \\
France & \multicolumn{1}{c}{D} &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       &       &       &       &       &       & \textbf{2} \\
Germany &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       & \textbf{2} \\
Greece &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       & \multicolumn{1}{c}{D} &       &       &       & \multicolumn{1}{c}{D} & \textbf{4} \\
Ireland &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       & \textbf{2} \\
Italy &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       & \multicolumn{1}{c}{D} & \multicolumn{1}{c}{C} &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       & \textbf{4} \\
Luxembourg &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       &       &       & \textbf{1} \\
Netherlands &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \textbf{0} \\
Portugal &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{N} &       &       &       & \textbf{2} \\
Spain &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       & \multicolumn{1}{c}{N} &       &       & \multicolumn{1}{c}{D} &       & \textbf{3} \\
Sweden &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \textbf{2} \\
UK    &       & \multicolumn{1}{c}{D} &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       &       &       &       &       &       & \textbf{3} \\
\textbf{EU15 total} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{2} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{2} & \textbf{2} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{1} & \textbf{2} & \textbf{0} & \textbf{3} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{1} & \textbf{3} & \textbf{3} & \textbf{3} & \textbf{0} & \textbf{2} & \textbf{1} & \textbf{33} \\
      &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &  \\
Brazil &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       &       &       &       &       & \textbf{1} \\
China &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       &       & \textbf{1} \\
India &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \textbf{0} \\
Russia &       &       &       &       &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       & \multicolumn{1}{c}{D} &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       & \multicolumn{1}{c}{C} &       & \textbf{5} \\
\textbf{BRIC total} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{7} \\
      &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &  \\
USA   &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{c}{C} &       &       &       &       &       &       &       &       &       &       & \textbf{1} \\
      &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &       &  \\
\textbf{Total} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{2} & \textbf{0} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{2} & \textbf{2} & \textbf{1} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{2} & \textbf{3} & \textbf{0} & \textbf{4} & \textbf{2} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{3} & \textbf{3} & \textbf{3} & \textbf{0} & \textbf{3} & \textbf{1} & \textbf{41} \\
\bottomrule

\end{tabularx}%

\begin{tablenotes}[flushleft]\labelsep0.0em
\item \footnotesize Notes: tbd
\end{tablenotes}

\end{threeparttable}
\par

\end{landscape}
%\end{sidewaystable}

%\vspace*{\fill}

\end{document}

在此处输入图片描述

答案1

  • 由于某种原因,tabularx如果它包含超过 20 列,则不起作用,因此我将其替换为tabular*
  • 表格很大...为了适合页面我放大了(使用\newgeometry页面宽度
  • 姆韦下面我省略了所有与表无关的包
  • 还删除了所有不必要的“\multicolumn{1}{c{...}˙
  • 的定义\theadfont改为\newcommand\theadfont{\bfseries\scriptsize}。因此的使用thead{...}更简单

考虑到上述情况,表格如下:

在此处输入图片描述

\documentclass[authoryear,11pt]{elsarticle}

\usepackage[a4paper,
            hmargin={30mm,20mm},
            vmargin={30mm,30mm}
            ]{geometry}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, eurosym}

\usepackage{pdflscape}

\usepackage{rotating}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, tabularx, threeparttable}
\newcolumntype{C}[1]{>{\Centering}p{#1}}
\usepackage{siunitx}

\usepackage[font=small]{caption}

\usepackage{lipsum}

\begin{document}

\newgeometry{showframe,
             hmargin={30mm,30mm},
             vmargin={7mm,13mm}
             }
\begin{landscape}
    \centering
    \scriptsize
\renewcommand\theadfont{\scriptsize\bfseries}
\settowidth{\rotheadsize}{\theadfont Total}
\setlength\tabcolsep{1pt}
%
\begin{threeparttable}
    \caption{tbd}
\label{tab:tab_reformdata}
%
\begin{tabular*}{\hsize}{l@{\extracolsep{\fill}}
                    *{31}{C{6ex}}
              >{\bfseries}S[table-format=2.0,
                            detect-weight]
                         }
    \toprule
\thead{(1)}
              & \thead{(2)}  & \thead{(3)}  & \thead{(4)}   & \thead{(5)}   &
\thead{(6)}   & \thead{(7)}  & \thead{(8)}  & \thead{(9)}   & \thead{(10)}  &
\thead{(11)}  & \thead{(12)} & \thead{(13)} & \thead{(14)}  & \thead{(15)}  &
\thead{(16)}  & \thead{(17)} & \thead{(18)} & \thead{(19)}  & \thead{(20)}  &
\thead{(21)}  & \thead{(22)} & \thead{(23)} & \thead{(24)}  & \thead{(25)}  &
\thead{(26)}  & \thead{(27)} & \thead{(28)} & \thead{(29)}  & \thead{(30)}  &
\thead{(31)}  & \thead{(32)} & {\thead{(33)}}
                    \\  \midrule
\thead[lb]{Country}
    & \rothead{1985}    & \rothead{1986}    & \rothead{1987}    & \rothead{1988}
    & \rothead{1989}    & \rothead{1990}    & \rothead{1991}    & \rothead{1992}
    & \rothead{1993}    & \rothead{1994}    & \rothead{1995}    & \rothead{1996}
    & \rothead{1997}    & \rothead{1998}    & \rothead{1999}    & \rothead{2000}
    & \rothead{2001}    & \rothead{2002}    & \rothead{2003}    & \rothead{2004}
    & \rothead{2005}    & \rothead{2006}    & \rothead{2007}    & \rothead{2008}
    & \rothead{2009}    & \rothead{2010}    & \rothead{2011}    & \rothead{2012}
    & \rothead{2013}    & \rothead{2014}    & \rothead{2015}    & {\rothead{Total}}
                    \\  \midrule
Austria &   &   &   &   &   &   &   &   &   &
        &   &   & D &   &   &   &   &   &   &
        &   &   &   &   &   & D &   &   &   &
        &   & 2     \\
Austria &   &   &   &   &   &   &   &   &   &
        &   &   & D &   &   &   &   &   &   &
        &   &   &   &   &   & D &   &   &   &
        &   & 2     \\
Belgium &   &   &   &   &   &   &   &   &   &
        &   &   & D &   &   &   &   &   &   &
        &   &   &   &   &   & D &   &   &   &
        &   & 2     \\
Denmark &   &   &   &   &   &   &   &   &   &
        &   & C &   &   &   &   &   &   &   &
        &   &   &   &   &   & C &   &   &   &
        &   & 2     \\
Finland &   &   &   &   &   &   &   &   & D &
        &   &   &   &   &   &   &   &   & C &
        &   &   &   &   &   &   &   &   &   &
        &   & 2     \\
France  & D &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        & D &   &   &   &   &   &   &   &   &
        &   & 2     \\
Germany &   &   &   &   &   &   &   &   &   & C
        &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   & C &   &
        &   & 2     \\
Greece  &   &   &   &   &   & D &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   &   & D &   &   &   & D &   &   &
        & D & 4     \\
Ireland &   &   &   &   &   & D &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   & D
        &   & 2     \\
Italy   &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   & D &
        & D & C &   &   &   &   &   & D &   &
        &   & 4     \\
Luxembourg
        &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        & C &   &   &   &   &   &   &   &   &
        &   & 1     \\
Netherlands
        &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   & 0     \\
Portugal&   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   & N &   &
        &   & 2     \\
Spain   &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   &   &   &   & C &   & N &   &   & D
        &   & 3     \\
Sweden  &   &   & C &   &   &   &   &   &   &
        &   & C &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   & 2     \\
UK      &   & D &   &   &   &   &   &   &   &
        &   &   &   &   &   & D &   & C &   &
        &   &   &   &   &   &   &   &   &   &
        &   & 3     \\
\textbf{EU15 total}
    & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{2} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{2} & \textbf{2} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{1} & \textbf{2} & \textbf{0} & \textbf{3} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{1} & \textbf{3} & \textbf{3} & \textbf{3} & \textbf{0} & \textbf{2} & \textbf{1} & {\textbf{33}} \\
    \addlinespace
Brazil  &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   & C &
        &   &   &   &   &   &   &   &   &   &
        &   & 1     \\
China   &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   & C &   &   &   &   &   &   &   &
        &   & 1     \\
India   &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        &   & 0     \\
Russia  &   &   &   &   &   &   &   & D &   &
        &   &   &   & C &   &   &   & D &   &
        &   &   &   & C &   &   &   &   &   & C
        &   & 5     \\
\textbf{BRIC total}
    & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{0} & \textbf{1} & \textbf{0} & {\textbf{7}} \\
    \addlinespace
USA     &   &   &   &   &   &   &   &   &   &
        &   &   &   &   &   &   &   &   &   &
        & C &   &   &   &   &   &   &   &   &
        &   & 1     \\
    \addlinespace
\textbf{Total}
    & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{0} & \textbf{2} & \textbf{0} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{0} & \textbf{2} & \textbf{2} & \textbf{1} & \textbf{0} & \textbf{1} & \textbf{0} & \textbf{2} & \textbf{3} & \textbf{0} & \textbf{4} & \textbf{2} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{3} & \textbf{3} & \textbf{3} & \textbf{0} & \textbf{3} & \textbf{1} & {\textbf{41}} \\
\bottomrule
    \end{tabular*}
\begin{tablenotes}[para,flushleft]
Notes: \lipsum*[22]
\end{tablenotes}
    \end{threeparttable}
    \end{landscape}
\restoregeometry

\end{document}

相关内容