如何将表格放入一页?

如何将表格放入一页?

我对 LaTeX 的了解非常基础,并且一直在使用 LibreOffice 的 Word2LaTeX 转换软件来转换表格。但是,当我将代码放入 Scientific Wordplace 时,似乎无法将表格放入一页。它总是需要两页。有什么办法可以将其放入一页吗?

以下是代码:

\documentclass[letterpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb,amsfonts,textcomp}
\usepackage{color}
\usepackage{array}
\usepackage{supertabular}
\usepackage{hhline}
\usepackage{hyperref}
\hypersetup{pdftex, colorlinks=true, linkcolor=blue, citecolor=blue, filecolor=blue, urlcolor=blue, pdftitle=, pdfauthor=, pdfsubject=, pdfkeywords=}
\makeatletter
\newcommand\arraybslash{\let\\\@arraycr}
\makeatother
% Page layout (geometry)
\setlength\voffset{-1in} 
\setlength\hoffset{-1in}
\setlength\topmargin{0.7874in}
\setlength\oddsidemargin{0.7874in}
\setlength\textheight{9.4251995in}
\setlength\textwidth{6.9251995in}
\setlength\footskip{0.0cm}
\setlength\headheight{0cm}
\setlength\headsep{0cm}
% Footnote rule
\setlength{\skip\footins}{0.0469in}
\renewcommand\footnoterule{\vspace*{-0.0071in}\setlength\leftskip{0pt}\setlength\rightskip{0pt plus 1fil}\noindent\textcolor{black}{\rule{0.25\columnwidth}{0.0071in}}\vspace*{0.0398in}}
% Pages styles
\makeatletter
\newcommand\ps@Standard{
\renewcommand\@oddhead{}
\renewcommand\@evenhead{}
\renewcommand\@oddfoot{}
\renewcommand\@evenfoot{}
\renewcommand\thepage{\arabic{page}}
}
\makeatother
\pagestyle{Standard}
\setlength\tabcolsep{1mm}
\renewcommand\arraystretch{1.3}


\bigskip

{\color{black}
\foreignlanguage{english}{\textbf{Table A2: }}\foreignlanguage{english}{List    of countries included in the estimations
(by legal origin)}~ \foreignlanguage{english}{\textbf{[R2]}}}

\begin{flushleft}
\tablefirsthead{}
\tablehead{}
\tabletail{}
\tablelasttail{}
\begin{supertabular}    {m{1.3275598in}m{0.7858598in}m{1.5775598in}m{0.7233598in}m{1.2858598in}m{0.7858598in}}
.
.
.
.
.

\end{supertabular}
    \end{flushleft}
    {\color{black}
    ~\textit{Notes}: The estimations include up to 78 countries listed in the table above. Figures in the table indicate
statehood experience accumulated over the period 1-1800 AD.}


\bigskip
\end{document}

答案1

在 LaTeX 文档中设置表格时,不进行或只进行很少的视觉格式化至关重要。请研究以下代码并得出一些关于如何以 LaTeX 方式编码表格材料的推论。

当然,如果您不想在表格材料中间允许分页,请不要使用诸如 之类的supertabular旨在允许分页的环境。

在此处输入图片描述

\documentclass[letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[textwidth=6.925in,textheight=9.425in]{geometry}
\usepackage{array} % for '\newcolumntype' macro 
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{caption,booktabs}

\begin{document}

\begin{table}[p]                        % place the table on a page by itself
\setlength\tabcolsep{1mm}
\captionsetup{labelfont=bf}
\renewcommand\thetable{A\arabic{table}} % just for this example
\setcounter{table}{1}                   % just for this example

\caption{List of countries included in the estimations (by legal origin) \textbf{[R2]}}

\begin{tabular}{@{}p{1.32756in}C{0.78in}p{1.57756in}C{0.78in}p{1.28586in}C{0.78in}@{}}
\toprule
Common Law LO & avg = 0.243 & Armenia    & 0.561   & Senegal & 0.448 \\
Australia     & 0.000       & Azerbaijan & 0.462   &         &       \\
\dots \\
\bottomrule
\end{tabular}

\medskip
\textit{Notes}: The estimations include up to 78 countries listed in the table above. Figures in the table indicate
statehood experience accumulated over the period 1--1800 AD.
\end{table}

\end{document}

答案2

这是对你另一个问题的回答,在我正要发布它时你删除了它。虽然我猜你现在不想要答案,但经过努力,我希望它能对某些人有用。从本质上讲,这个问题与这个问题非常相似,所以发布在这里似乎是合理的。如果不是,我可以稍后删除它,那时我就不会那么意识到自己刚刚把时间花在了不再需要的东西上。


代码没有给出错误但它更接近公认的最佳实践。

考虑以下重写,但请注意,我并不完全清楚什么代表什么,例如什么实际上是数学变量,什么又是文本。此外,如果这些是统计数据,您可能应该使用siunitx

关键点:

  1. Atable漂浮。它被设计为自动移动到其他地方。因此,任何对该表至关重要的东西都需要浮动:标题,注释,等等。

  2. 永远不要对枚举的事物进行编号。始终让 TeX 为您计数:列表、表格、图形、章节、参考文献、页面、公式、段落中的项目。无论它是什么,如果它需要编号,请让 TeX 进行计数。当您决定在完成第 404 个项目后添加第二个项目时,TeX 不会介意重新计数,如果您将第三个数字移到第五个数字之后,它也不会忘记更改数字。

  3. 用于booktabs规则。

  4. 用于caption帮助格式化标题。

  5. \label{<key>}在 a 中,table除非 a 位于其前面,否则它是无用的。如果你写的是 而不是\caption,则 it 没有任何可引用的内容。Table 1\caption{...}

\documentclass{article}
\usepackage{caption,tabularx,array,booktabs}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}

\begin{table}[htbp]
  % everything that must remain with the table needs to go in the table environment, because it may move
  % use \caption to create the caption - never hard-code numbered items
  \caption{Descriptive statistics and correlation coefficients of key variables}\label{tab:tab1}
  % it's a switch - personally, I think it is better to use it as one
  \scriptsize
  % don't add extra vertical space with the center environment
  {% limit the effect with a group
    \centering
    \begin{tabularx}{\linewidth}{lccccC}% make the tabular as wide as the line, using all the available space in the last column, which is the only multiline one anyway

      \toprule
      Variable &
      Mean&
      Std. Dev.&
      Min.&
      Max.&
      Correlation coefficient with $FinDev$\\
      \midrule
%       $State\, x\, German\, LO$ & % should this really all be presented as maths variables?
      State $x$ German $LO$ &
      0.086&
      0.224&
      0&
      0.938&
      0.24 \\

%       $State\, x\, Scandinavian\, LO$ & % ditto
      State $x$ Scandinavian $LO$ & % ditto
      0.019&
      0.105&
      0&
      0.771&
      0.30 \\
      \bottomrule

    \end{tabularx}

  }% end of centring
  \smallskip

  % if the notes should stay with the table, they need to be in the table
  \emph{Notes}: The descriptive statistics provided in the table include the 127 countries used in the baseline regressions.
  Sources and definition of data are described in the text and Appendix 1.
\end{table}

\end{document}

重新格式化的表格

相关内容