将简单表格适合 IEEEtran 类中的列

将简单表格适合 IEEEtran 类中的列

我正在使用IEEEtran 它来准备会议手稿,但是只有 3 列的表格无法放入我的手稿的列中。

下面我给出了一个最简洁的代码来展示输出。在这个例子中,我只添加了一个包\usepackage{lipsum}来显示虚拟文本,没有添加其他内容。

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts

\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{lipsum}  % the only added package..!

\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}

\title{Conference Paper Title*\\
{\footnotesize \textsuperscript{*}Note: Sub-titles are not captured in Xplore and
should not be used}
\thanks{Identify applicable funding agency here. If none, delete this.}
}

\author{\IEEEauthorblockN{1\textsuperscript{st} Given Name Surname}
\IEEEauthorblockA{\textit{dept. name of organization (of Aff.)} \\
\textit{name of organization (of Aff.)}\\
City, Country \\
email address or ORCID}
\and
\IEEEauthorblockN{2\textsuperscript{nd} Given Name Surname}
\IEEEauthorblockA{\textit{dept. name of organization (of Aff.)} \\
\textit{name of organization (of Aff.)}\\
City, Country \\
email address or ORCID}
\and
\IEEEauthorblockN{3\textsuperscript{rd} Given Name Surname}
\IEEEauthorblockA{\textit{dept. name of organization (of Aff.)} \\
\textit{name of organization (of Aff.)}\\
City, Country \\
email address or ORCID}

}

\maketitle

\begin{abstract}
This document is a model and instructions for \LaTeX.
This and the IEEEtran.cls file define the components of your paper [title, text, heads, etc.]. *CRITICAL: Do Not Use Symbols, Special Characters, Footnotes, 
or Math in Paper Title or Abstract.
\end{abstract}

\begin{IEEEkeywords}
component, formatting, style, styling, insert
\end{IEEEkeywords}

\section{Introduction}

\lipsum[2-5]

\section{Data Description}

This table extends beyond the column margins....


   \begin{table}%[htbp]
        \caption{Datasets' properties}
        \begin{center}
        \begin{tabular}{l|c|c}
        \hline 
                     & Dataset 1    & Dataset 2  \\
        \hline
       Collected in:     &      July 2011                 &   April 2007 - August 2012 \\
       \hline
       Sampling rate:    &   1- second                     &    1-5 seconds  \\
       \hline
       Location data: &  <timestamp, lat, lon, alt, speed, bearing>      &      5 modes used             \\
       \hline %\hline
        \end{tabular}
        \label{tab:datasets}
        \end{center}
    \end{table}

\end{document}

输出:

在此处输入图片描述

答案1

我建议您从 环境切换tabular到环境,并对中间列tabularx采用居中版本的列类型,以允许在该列的单元格中自动换行。X

另一个建议:取消垂直规则。它们没有必要,而且不会被遗漏。

在此处输入图片描述

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage[T1]{fontenc} % <-- new
\usepackage{lipsum} % filler text

% also new:
\usepackage{tabularx,ragged2e}
\newcolumntype{C}{>{\Centering}X} % define centered version of 'X' col. type

\begin{document}

\section*{Data Description}

\lipsum[1][1-4] % filler text

The table no longer extends beyond the column margins:

   \begin{table}[ht]
   \setlength\extrarowheight{3pt}
      \caption{Dataset Properties} 
      \label{tab:datasets}
      \centering
      \begin{tabularx}{0.9\columnwidth}{@{} lCc @{}}
      \hline 
      & Dataset 1   & Dataset 2  \\
      \hline
      Collected in  &  July 2011           &   April 2007--August 2012 \\
      %\hline
      Sampling rate &  1- second           &    1-5 seconds  \\
      %\hline
      Location data & <timestamp, lat, lon, alt, speed, bearing> & 5 modes used \\
      \hline 
      \end{tabularx}
   \end{table}

\lipsum[2][1-4] % more filler text

\end{document}

相关内容