2016-09-15 129 views
10

我想正確對齊最後一列。最後還有額外的空間。請讓我知道如何做到這一點。謝謝。列表中的對齊列

\documentclass[11pt]{article} 
\usepackage{setspace}         %double spacing and spacing in tables       
\usepackage{amsmath}         %equations etc. in latex 
\usepackage[capposition=top]{floatrow}     %so that the caption for figures appear at the top 
\usepackage[tablename=TABLE,figurename = FIGURE,labelsep=newline,aboveskip=0pt,font=bf,justification=centering]{caption} %so that caption looks cool 
\usepackage{booktabs}         %midrule etc. which adds space around lines. Make tables look good. 
\usepackage{tabularx}         %use tabularx environment for creating one page tables 
\usepackage[margin=1in]{geometry}      %defining the margin for the page 
\usepackage[autostyle]{csquotes}      %for quotes. alternative would be " and " 
\usepackage[table]{xcolor}        %rowcolor, cellcolor, color for references 
\usepackage{pdflscape}         %landscape and keep the pages straight 
\usepackage{everypage}         %For AddEveryHookPage 
\usepackage{hanging}         %For references 
\usepackage{longtable}         %For multiple pages 
\usepackage{multirow}         %Valuable package as can be seen from table 5,8, and 10 
\usepackage{graphicx}         %created line using this package 
\usepackage{bm}           %bold and italics in the math enviornment at the same time 
\usepackage{dcolumn} % a package actually used in this example 

\def\hang{\par\noindent\makebox[1.5em][l]{ }\hangindent1.5em} %hanging indent 

\makeatletter 
\setlength{\@fptop}{0pt}        %to make tables and figures start at the top of the page 
\makeatother 

\newcommand{\Lpagenumber}{\ifdim\textwidth=\linewidth\else\bgroup  %to correct the page numbering for landscape pages 
    \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}% 
      stabu   \llap{\rotatebox{90}{\thepage}}}}% 
    \egroup\fi} 
\AddEverypageHook{\Lpagenumber}%      %to correct the page numbering for landscape pages 


\newcolumntype{Y}{>{\centering\arraybackslash}X}  %to center the columns for tabularx environment 
\newcolumntype{Z}{>{\centering\arraybackslash}p{0.75in}} %to center the columns for tabularx environment 
\newcolumntype{K}{>{\centering\arraybackslash}p{0.3in}} %to center the columns for tabularx environment 
\newcommand{\gmc}[3]{\multicolumn{#1}{@{}#[email protected]{}}{#3}} %short form for multicolumn 
\doublespacing           %make lines double spaced 



\begin{document} 
    \setcounter{page}{-1} %start numbering at page 3 (2 - n where n = -1) 
    \thispagestyle{empty} %suppress page number 

    \begingroup % keep any font size changes local to group 
    \captionof{table}{\textbf{Descriptive Statistics}} 
    \singlespacing 
    \footnotesize 
    \centering 
    \setlength\tabcolsep{3pt} %default 
    \renewcommand{\arraystretch}{1} 


    \begin{tabularx}{\textwidth}{@{\extracolsep{\fill}}l*{2}{c}} 
     \gmc{3}{l}{\textbf{Panel A: Sample Representation across Economic Sectors}} \\\midrule 
     \textbf{Sector} & \textbf{N} & \textbf{\% Frequency} \\\midrule 
     Energy & 524 & 1.65\%      \\ 
     Materials & 2,648 & 8.34\%     \\ 
     Industrials & 5,905 &  18.60\%    \\ 
     Consumer Discretionary & 5,549 & 17.48\%  \\ 
     Consumer Staples & 2,174 & 6.85\%  \\ 
     Health Care & 5,167 & 16.28\%    \\ 
     Financials & 0 & 0.00\%    \\ 
     Information Technology & 9,774 & 30.79\%  \\ 
     Telecommunication Services & 0 & 0.00\% \\ 
     Utilities & 0 & 0.00\%    \\\midrule 
     Total & 31,741 & 100.00\%    \\\midrule 
    \end{tabularx} 
    \endgroup 

\end{document} 

回答

0

如果你只是希望它有最後一欄沒有空間可以 更換

\begin{tabularx}{\textwidth}{@{\extracolsep{\fill}}l*{2}{c}} 

有:

\begin{tabularx}{\textwidth}{l Y r} 
+0

@oretisis我想爲中心的列。但是還有額外的尾部空間,我想刪除它。 – Sumit