横向和表格格式

横向和表格格式

在此处输入图片描述我写了一个 latex 代码,但是表格看起来很奇怪。请帮忙。谢谢!

\documentclass[11pt]{article}
\usepackage{setspace,amssymb,amsmath}
\usepackage[tablename=TABLE,labelsep=newline,
aboveskip=0pt,font=bf,justification=centering]{caption}
\usepackage{booktabs,tabularx}
\usepackage[margin=1in]{geometry}
\usepackage[autostyle]{csquotes}
\usepackage[table]{xcolor}
\usepackage{pdflscape,threeparttablex}
 \usepackage{everypage}

\newcommand{\Lpagenumber}{\ifdim\textwidth=\linewidth\else\bgroup
\dimendef\margin=0
\ifodd\value{page}\margin=\oddsidemargin
\else\margin=\evensidemargin
\fi
\raisebox{\dimexpr -\topmargin-\headheight-\headsep-0.5\linewidth}[0pt][0pt]{%
    \rlap{\hspace{\dimexpr \margin+\textheight+\footskip}%
        \llap{\rotatebox{90}{\thepage}}}}%
\egroup\fi}
\AddEverypageHook{\Lpagenumber}%


\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcommand{\gmc}[3]{\multicolumn{#1}{@{}#2@{}}{#3}}

\begin{document}

\begingroup % keep any font size changes local to group
%\setlength\tabcolsep{2pt} % default value: 6pt

\begin{landscape}
    \thispagestyle{empty}   
    \captionof{table}{U.S. Corporate Employees and the Supply of Real Estate Properties Available for Sale}
    \singlespacing
    \small
    \setlength\tabcolsep{6pt} %default
    %\renewcommand{\arraystretch}{0.95}

    \begin{tabularx}{\textwidth}{@{}l*{18}{Y}@{}}
        \toprule
    \gmc{19}{c}{Total Across All Regions} \\\midrule
     Begi. of Year & \gmc{3}{c}{2010} & \gmc{3}{c}{2011} & \gmc{3}{c}{2012} & \gmc{3}{c}{2013} & \gmc{3}{c}{2014} & \gmc{3}{c}{2015} \\\cmidrule(l){2-19}
     & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} \\

     & Employees & Supply & Ratio & Employees & Supply & Ratio & Employees & Supply & Ratio & Employees & Supply & Ratio & Employees & Supply & Ratio & Employees & Supply & Ratio \\\hline
     All Regions&   32,634,908& 1,632,728&  20&     33,092,790& 1,720,278&  19  &   33,829,341& 1,585,138&  21  &   34,505,039& 1,166,609&  30  &   35,333,058& 1,123,050&  31&     35,932,126& 1,123,834&  32 \\\hline\\\hline
    \gmc{19}{c}{Analysis at the Metropolitan Level} \\\hline
     Begi. of Year & \gmc{3}{c}{2010} & \gmc{3}{c}{2011} & \gmc{3}{c}{2012}               & \gmc{3}{c}{2013} & \gmc{3}{c}{2014} & \gmc{3}{c}{2015} \\\cline{2-19}
    & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} \\
    & Employees & Supply & Ratio & Employees & Supply & Ratio & Employees & Supply & Ratio & Employees & Supply & Ratio & Employees & Supply & Ratio & Employees & Supply & Ratio \\\hline
    Phoenix&    367,499&    54,788& 7&      394,999&    62,654& 6&      407,725 &51,918&    8&      375,802&    35,952& 10  &   360,115&    40,973& 9&      378,757 &40,269&    9 \\
    Los Angeles&    1,003,169&  59,889& 17  &   1,056,392&  59,025& 18&     1,012,073&  52,726& 19&     1,018,180&  25,563& 40&     924,787&    25,493& 36&     900,258&    29,195& 31\\
    San Diego&  180,285&    19,940& 9   &   172,393 &24,345&    7   &   172,272&    23,137& 7   &   171,815&    12,607& 14&     161,064 &11,844&    14&     157,810&    13,440& 12\\
    San Francisco&  2,268,842&  29,832& 76&     2,347,845&  31,880& 74  &   2,461,445&  27,843& 88  &   2,545,909&  14,817& 172 &   2,602,896&  14,979& 174&        2,550,790&  16,163& 158\\
    Denver& 475,575&    50,967& 9&      492,016&    52,426& 9   &   537,333&    43,835& 12  &   607,872&    32,378& 19&     615,280&    31,683& 19  &   639,383&    27,716& 23\\
    Washington& 2,540,156&  93,419& 27&     2,486,800&  99,547& 25&     2,471,481&  91,452& 27  &   2,458,657&  68,954& 36  &   2,534,375&  68,775& 37  &   2,530,747&  76,055& 33\\
    Miami&  477,658&    80,343& 6&      507,007&    91,758& 6&      365,279&    81,908& 4&      376,885&    54,883& 7&      376,250&    50,283& 7&      395,997 &50,333 &8\\
    Tampa&  689,823&    123,427 &6&     730,273&    132,552&    6&      884,770&    107,814&    8&      954,829&    75,111& 13  &   1,004,677&  78,760& 13&     930,456&    78,590& 12\\
    Atlanta &2,836,287& 173,254&    16&     2,825,611&  175,955&    16  &   2,917,257&  165,493&    18&     2,937,585&  121,428 &24&        3,083,928&  119,230&    26&     3,140,758&  120,336&    26\\
    Chicago &4,244,670& 173,213&    25&     4,364,844&  179,824&    24&     4,572,732&  168,134&    27&     4,672,606&  127,218&    37&     4,717,841&  115,975&    41&     4,771,327&  118,183 &40\\
    Boston& 1,406,473&  57,299& 25  &   1,417,301&  58,438& 24&     1,392,619&  65,126& 21  &   1,468,621&  51,300& 29  &   1,478,784&  46,418& 32&     1,557,034&  46,873& 33\\
    Detroit&    1,300,213&  64,128& 20&     1,356,644&  55,783& 24  &   1,378,934&  46,452& 30&     1,427,418&  37,303& 38  &   1,446,164&  35,845  &40 &   1,512,823&  37,522& 40\\
    Minneapolis&    1,665,563&  44,115& 38&     1,684,094&  48,546& 35  &   1,714,084&  44,109& 39&     1,627,984&  32,231& 51  &   1,665,597&  32,053& 52&     1,651,004&  32,406& 51\\
    Charlotte&  1,005,165&  125,320&    8&      1,017,866&  130,024&    8&      1,047,660&  124,601&    8&      1,045,522&  103,693 &10 &   1,096,008&  103,404&    11  &   1,135,282&  96,547& 12\\
    Las Vegas&  298,798&    21,624& 14&     307,775&    22,605& 14&     314,001&    20,021& 16&     322,573&    10,092& 32&     324,823&    12,433& 26  &   330,772&    13,048& 25\\
    New York&   5,662,806&  159,197&    36&     5,754,068&  166,138&    35&     5,844,228&  181,279&    32&     5,962,398&  138,905&    43  &   6,032,939&  127,497&    47&     6,098,428&  130,815&    47\\
    Cleveland&  2,080,563&  60,757& 34  &   2,156,766&  70,892& 30  &   2,147,721&  67,481& 32&     2,183,454&  55,386& 39&     2,122,614&  52,631& 40  &   2,161,265&  50,718& 43\\
    Portland&   162,390&    34,946& 5&      180,935&    34,058& 5&      197,258&    30,306& 7&      218,717&    20,653& 11  &   363,575&    20,881& 17&     531,026&    20,351& 26\\
    Dallas& 3,349,506&  167,786&    20&     3,205,328&  181,931&    18&     3,296,765&  152,138&    22&     3,331,824&  122,333 &27&        3,521,591&  107,722&    33  &   3,585,203&  101,505 &35\\
    Seattle&    619,467&    38,484& 16  &   633,834&    41,897& 15&     693,705&    39,365& 18  &   796,388 &25,802&    31&     899,751&    26,171& 34  &   973,008&    23,769& 41\\
        \bottomrule
    \end{tabularx}   

    \thispagestyle{empty} \small \hrule \medskip 
    Notes: The table reports the sum of corporate employees for firms headquartered across the United States and the supply of residential real estate properties available for sale. Data on number of employees (Compustat: EMP) are from the Compustat North America Fundamentals Annual File (WRDS: FUNDA) available from WRDS, where I sum number of employees by fiscal year (Compustat: FYEAR). Housing supply data are from Zillow. To classify firms' corporate employees and Zillow's real estate supply into Case-Shiller regions, I follow the same sort procedure used for developing the regional accounting profitability indices. That is, based on firms' headquarters location or the Zillow's zip code, respectively, using: (a) a zip-code-coordinates mapping from the Census Gazetteer File, (b) regional coordinates from Google searches, and (c) the spherical distance of a firm's headquarters to its closest Case-Shiller region. Using firms in each region, I construct annual sums of corporate employees. Both corporate employees and properties supply refer to the beginning of each year, and thus the Compustat data are as of Dec. 31, 2009 through Dec. 31, 2014, and the Zillow data are from beginning of Jan. 2010 through beginning of Jan. 2015. The series begin in Jan. 2010, the first month with available housing supply data.

    \medskip
    \hrule
\end{landscape}
\endgroup

 \end{document}

答案1

它实际上仍然太大,但是它可以帮助您入门,但tabularx在这里没有任何用处,所以我将其删除了。

在此处输入图片描述

\documentclass[11pt]{article}
\usepackage{setspace,amssymb,amsmath}
\usepackage[tablename=TABLE,labelsep=newline,
aboveskip=0pt,font=bf,justification=centering]{caption}
\usepackage{booktabs,tabularx}
\usepackage[margin=1in]{geometry}
\usepackage[autostyle]{csquotes}
\usepackage[table]{xcolor}
\usepackage{pdflscape,threeparttablex}
 \usepackage{everypage}

\newcommand{\Lpagenumber}{\ifdim\textwidth=\linewidth\else\bgroup
\dimendef\margin=0
\ifodd\value{page}\margin=\oddsidemargin
\else\margin=\evensidemargin
\fi
\raisebox{\dimexpr -\topmargin-\headheight-\headsep-0.5\linewidth}[0pt][0pt]{%
    \rlap{\hspace{\dimexpr \margin+\textheight+\footskip}%
        \llap{\rotatebox{90}{\thepage}}}}%
\egroup\fi}
\AddEverypageHook{\Lpagenumber}%


%\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcommand{\gmc}[3]{\multicolumn{#1}{@{}#2@{}}{\makebox[0pt][#2]{#3}}}

\begin{document}

% not needed \begingroup % keep any font size changes local to group
%\setlength\tabcolsep{2pt} % default value: 6pt

\begin{landscape}
    \thispagestyle{empty}   
    \captionof{table}{U.S. Corporate Employees and the Supply of Real Estate Properties Available for Sale}
    \singlespacing
    \footnotesize
     \def\Ratio{\makebox[0pt][r]{R.}}
    \setlength\tabcolsep{2pt} %default

    %\renewcommand{\arraystretch}{0.95}

    \hspace*{-15pt}%
     \begin{tabular}{@{}l*{18}{r}@{}}
        \toprule
    \gmc{19}{c}{Total Across All Regions} \\\midrule
     Begi. of Year & \gmc{3}{c}{2010} & \gmc{3}{c}{2011} & \gmc{3}{c}{2012} & \gmc{3}{c}{2013} & \gmc{3}{c}{2014} & \gmc{3}{c}{2015} \\\cmidrule(l){2-19}
     & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} \\

     & Employees & Supply & \Ratio & Employees & Supply & \Ratio & Employees & Supply & \Ratio & Employees & Supply & \Ratio & Employees & Supply & \Ratio & Employees & Supply & \Ratio \\\hline
     All Regions&   32,634,908& 1,632,728&  20&     33,092,790& 1,720,278&  19  &   33,829,341& 1,585,138&  21  &   34,505,039& 1,166,609&  30  &   35,333,058& 1,123,050&  31&     35,932,126& 1,123,834&  32 \\\hline\\\hline
    \gmc{19}{c}{Analysis at the Metropolitan Level} \\\hline
     Begi. of Year & \gmc{3}{c}{2010} & \gmc{3}{c}{2011} & \gmc{3}{c}{2012}               & \gmc{3}{c}{2013} & \gmc{3}{c}{2014} & \gmc{3}{c}{2015} \\\cline{2-19}
    & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} & \gmc{3}{c}{Corporate Properties} \\
    & Employees & Supply & \Ratio & Employees & Supply & \Ratio & Employees & Supply & \Ratio & Employees & Supply & \Ratio & Employees & Supply & \Ratio & Employees & Supply & \Ratio \\\hline
    Phoenix&    367,499&    54,788& 7&      394,999&    62,654& 6&      407,725 &51,918&    8&      375,802&    35,952& 10  &   360,115&    40,973& 9&      378,757 &40,269&    9 \\
    Los Angeles&    1,003,169&  59,889& 17  &   1,056,392&  59,025& 18&     1,012,073&  52,726& 19&     1,018,180&  25,563& 40&     924,787&    25,493& 36&     900,258&    29,195& 31\\
    San Diego&  180,285&    19,940& 9   &   172,393 &24,345&    7   &   172,272&    23,137& 7   &   171,815&    12,607& 14&     161,064 &11,844&    14&     157,810&    13,440& 12\\
    San Francisco&  2,268,842&  29,832& 76&     2,347,845&  31,880& 74  &   2,461,445&  27,843& 88  &   2,545,909&  14,817& 172 &   2,602,896&  14,979& 174&        2,550,790&  16,163& 158\\
    Denver& 475,575&    50,967& 9&      492,016&    52,426& 9   &   537,333&    43,835& 12  &   607,872&    32,378& 19&     615,280&    31,683& 19  &   639,383&    27,716& 23\\
    Washington& 2,540,156&  93,419& 27&     2,486,800&  99,547& 25&     2,471,481&  91,452& 27  &   2,458,657&  68,954& 36  &   2,534,375&  68,775& 37  &   2,530,747&  76,055& 33\\
    Miami&  477,658&    80,343& 6&      507,007&    91,758& 6&      365,279&    81,908& 4&      376,885&    54,883& 7&      376,250&    50,283& 7&      395,997 &50,333 &8\\
p    Tampa&  689,823&    123,427 &6&     730,273&    132,552&    6&      884,770&    107,814&    8&      954,829&    75,111& 13  &   1,004,677&  78,760& 13&     930,456&    78,590& 12\\
    Atlanta &2,836,287& 173,254&    16&     2,825,611&  175,955&    16  &   2,917,257&  165,493&    18&     2,937,585&  121,428 &24&        3,083,928&  119,230&    26&     3,140,758&  120,336&    26\\
    Chicago &4,244,670& 173,213&    25&     4,364,844&  179,824&    24&     4,572,732&  168,134&    27&     4,672,606&  127,218&    37&     4,717,841&  115,975&    41&     4,771,327&  118,183 &40\\
    Boston& 1,406,473&  57,299& 25  &   1,417,301&  58,438& 24&     1,392,619&  65,126& 21  &   1,468,621&  51,300& 29  &   1,478,784&  46,418& 32&     1,557,034&  46,873& 33\\
    Detroit&    1,300,213&  64,128& 20&     1,356,644&  55,783& 24  &   1,378,934&  46,452& 30&     1,427,418&  37,303& 38  &   1,446,164&  35,845  &40 &   1,512,823&  37,522& 40\\
    Minneapolis&    1,665,563&  44,115& 38&     1,684,094&  48,546& 35  &   1,714,084&  44,109& 39&     1,627,984&  32,231& 51  &   1,665,597&  32,053& 52&     1,651,004&  32,406& 51\\
    Charlotte&  1,005,165&  125,320&    8&      1,017,866&  130,024&    8&      1,047,660&  124,601&    8&      1,045,522&  103,693 &10 &   1,096,008&  103,404&    11  &   1,135,282&  96,547& 12\\
    Las Vegas&  298,798&    21,624& 14&     307,775&    22,605& 14&     314,001&    20,021& 16&     322,573&    10,092& 32&     324,823&    12,433& 26  &   330,772&    13,048& 25\\
    New York&   5,662,806&  159,197&    36&     5,754,068&  166,138&    35&     5,844,228&  181,279&    32&     5,962,398&  138,905&    43  &   6,032,939&  127,497&    47&     6,098,428&  130,815&    47\\
    Cleveland&  2,080,563&  60,757& 34  &   2,156,766&  70,892& 30  &   2,147,721&  67,481& 32&     2,183,454&  55,386& 39&     2,122,614&  52,631& 40  &   2,161,265&  50,718& 43\\
    Portland&   162,390&    34,946& 5&      180,935&    34,058& 5&      197,258&    30,306& 7&      218,717&    20,653& 11  &   363,575&    20,881& 17&     531,026&    20,351& 26\\
    Dallas& 3,349,506&  167,786&    20&     3,205,328&  181,931&    18&     3,296,765&  152,138&    22&     3,331,824&  122,333 &27&        3,521,591&  107,722&    33  &   3,585,203&  101,505 &35\\
    Seattle&    619,467&    38,484& 16  &   633,834&    41,897& 15&     693,705&    39,365& 18  &   796,388 &25,802&    31&     899,751&    26,171& 34  &   973,008&    23,769& 41\\
        \bottomrule
    \end{tabular}%  
    \hspace*{-15pt}%

    \thispagestyle{empty} \small \hrule \medskip 
    Notes: The table reports the sum of corporate employees for firms headquartered across the United States and the supply of residential real estate properties available for sale. Data on number of employees (Compustat: EMP) are from the Compustat North America Fundamentals Annual File (WRDS: FUNDA) available from WRDS, where I sum number of employees by fiscal year (Compustat: FYEAR). Housing supply data are from Zillow. To classify firms' corporate employees and Zillow's real estate supply into Case-Shiller regions, I follow the same sort procedure used for developing the regional accounting profitability indices. That is, based on firms' headquarters location or the Zillow's zip code, respectively, using: (a) a zip-code-coordinates mapping from the Census Gazetteer File, (b) regional coordinates from Google searches, and (c) the spherical distance of a firm's headquarters to its closest Case-Shiller region. Using firms in each region, I construct annual sums of corporate employees. Both corporate employees and properties supply refer to the beginning of each year, and thus the Compustat data are as of Dec. 31, 2009 through Dec. 31, 2014, and the Zillow data are from beginning of Jan. 2010 through beginning of Jan. 2015. The series begin in Jan. 2010, the first month with available housing supply data.

    \medskip
    \hrule
\end{landscape}
% no \endgroup

 \end{document}

相关内容