我是 Latex 的新手。以下是我的 latex 代码。emnlp2017
示例中的包可以从以下位置下载这里。
%\title{emnlp 2017 instructions}
% File emnlp2017.tex
\documentclass[11pt,letterpaper]{article}
\usepackage{emnlp2017}
\usepackage{times}
\usepackage{latexsym}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{booktabs}
\usepackage{tabularx} % in the preamble
\usepackage{amsmath}
\usepackage{url}
\usepackage{subfigure}
\usepackage{makecell}
\usepackage{subfigure}
\usepackage{multirow}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage{siunitx}
\theoremstyle{definition}
%\newtheorem{exmp}{Example}[section]
% Uncomment this line for the final submission:
%\emnlpfinalcopy
% Enter the EMNLP Paper ID here:
\def\emnlppaperid{***}
% To expand the titlebox for more authors, uncomment
% below and set accordingly.
% \addtolength\titlebox{.5in}
\newcommand\BibTeX{B{\sc ib}\TeX}
\title{}
% Author information can be set in various styles:
% For several authors from the same institution:
% \author{Author 1 \and ... \and Author n \\
% Address line \\ ... \\ Address line}
% if the names do not fit well on one line use
% Author 1 \\ {\bf Author 2} \\ ... \\ {\bf Author n} \\
% For authors from different institutions:
% \author{Author 1 \\ Address line \\ ... \\ Address line
% \And ... \And
% Author n \\ Address line \\ ... \\ Address line}
% To start a seperate ``row'' of authors use \AND, as in
% \author{Author 1 \\ Address line \\ ... \\ Address line
% \AND
% Author 2 \\ Address line \\ ... \\ Address line \And
% Author 3 \\ Address line \\ ... \\ Address line}
% If the title and author information does not fit in the area allocated,
% place \setlength\titlebox{<new height>} right after
% at the top, where <new height> can be something larger than 2.25in
\author{}
\date{2017-03-07}
\begin{document}
\maketitle
\begin{abstract}
\end{abstract}
\section{Introduction}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
\centering
\caption{AUC Result}
\begin{tabular}{|c|c|r|r|r|r|r|r|}
\hline
& & \multicolumn{3}{c}{\textbf{twitter}} \vline & \multicolumn{3}{c}{\textbf{blog}} \\\hline
\textbf{classifier} & \textbf{data} & \multicolumn{1}{c}{\textbf{BOW}} \vline& \multicolumn{1}{c}{\textbf{CBOW}} \vline& \multicolumn{1}{c}{\textbf{SG}} \vline& \multicolumn{1}{c}{\textbf{BOW}} \vline& \multicolumn{1}{c}{\textbf{CBOW}} \vline& \multicolumn{1}{c}{\textbf{SG}} \\\hline
\multirow{2}[0]{*}{NB} & mean & & & & & & \\
& var & & & & & & \\\hline
\multirow{2}[0]{*}{RF} & mean & & & & & & \\
& var & & & & & & \\\hline
\multirow{2}[0]{*}{KNN} & mean & & & & & & \\
& var & & & & & & \\\hline
\multirow{2}[0]{*}{RBFSVM} & mean & & & & & & \\
& var & & & & & & \\\hline
\multirow{2}[0]{*}{LinearSVM} & mean & & & & & & \\
& var & & & & & & \\\hline
\multirow{2}[0]{*}{SigmoidSVM} & mean & & & & & & \\
& var & & & & & & \\\hline
\multirow{2}[0]{*}{LR} & mean & & & & & & \\
& var & & & & & & \\\hline
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
\section{Conclusion and Future work}
\bibliography{emnlp2017}
\bibliographystyle{emnlp_natbib}
\end{document}
它超出了右侧边界,如何解决?我想让这个表格位于整个页面的中心以避免溢出,如何实现?
另外,我想添加水平线,将平均值和变量从“数据”列分隔到末尾,该怎么做?
谢谢你!
答案1
如果您想要的表格不一定位于页面顶部,则可以使用strip
来自的环境cuted
。
\thead
我使用命令简化了表格中列标题的代码makecell
。另外,注意times
,它已经过时了,因为它不支持数学。所以我用newtx
基于 Times 克隆的包替换了它TeX Gyre Termes
。这个subfigure
包也过时了,而且不再开发了。我用subcaption
定义subfigure
环境的包替换了它。
booktabs
最后一点,我使用来自的规则,没有使用垂直规则,使您的表格看起来更专业。我使用颜色而不是分隔规则来区分和行mean
。var
%\title{emnlp 2017 instructions}
% File emnlp2017.tex
\documentclass[11pt, letterpaper, svgnames, table]{article}
\usepackage{emnlp2017}
\usepackage{amsthm}
\usepackage{newtxmath, newtxtext}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tabularx} % in the preamble
\usepackage{amsmath}
\usepackage{url}
\usepackage{subcaption}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{cuted, caption}
\theoremstyle{definition}
%\newtheorem{exmp}{Example}[section]
% Uncomment this line for the final submission:
%\emnlpfinalcopy
% Enter the EMNLP Paper ID here:
\def\emnlppaperid{***}
% To expand the titlebox for more authors, uncomment
% below and set accordingly.
% \addtolength\titlebox{.5in}
\newcommand\BibTeX{B{\sc ib}\TeX}
\title{}
\author{}
\date{2017-03-07}
\usepackage{lipsum}
\setlength{\stripsep}{8pt}
\setlength{\abovecaptionskip}{0pt}
\renewcommand\theadfont{\normalsize\bfseries}
\begin{document}
\lipsum[1-2]
%
\begin{strip}
\centering\setlength\defaultaddspace{1.5ex}%
\captionof{table}{Result}\label{tab:addlabel}%
\rowcolors{3}{Gainsboro!50! Lavender!40! }{}
\begin{tabular}{ cc*{6}{r}}
\hline
& & \multicolumn{3}{c}{\textbf{twitter}} & \multicolumn{3}{c}{\textbf{blog}} \\
\cmidrule(lr){3-5}\cmidrule(lr){6-8}
\textbf{classifier} & \textbf{data} & \thead{BOW} & \thead{CBOW} & \thead{SG} & \thead{BOW} & \thead{CBOW} & \thead{SG} \\\midrule
\cellcolor{white}\multirow{2}[0]{*}{NB} & mean & & & & & & \\
& var & & & & & & \\\addlinespace
\cellcolor{white}\multirow{2}[0]{*}{RF} & mean & & & & & & \\
& var & & & & & & \\\addlinespace
\cellcolor{white}\multirow{2}[0]{*}{KNN} & mean & & & & & & \\
& var & & & & & & \\\addlinespace
\cellcolor{white}\multirow{2}[0]{*}{RBFSVM} & mean & & & & & & \\
& var & & & & & & \\\addlinespace
\cellcolor{white}\multirow{2}[0]{*}{LinearSVM} & mean & & & & & & \\
& var & & & & & & \\\addlinespace
\cellcolor{white}\multirow{2}[0]{*}{SigmoidSVM} & mean & & & & & & \\
& var & & & & & & \\\addlinespace
\cellcolor{white}\multirow{2}[0]{*}{LR} & mean & & & & & & \\
& var & & & & & & \\\bottomrule
\end{tabular}%
\end{strip}
%
\lipsum[3-4]
\end{document}
答案2
使用带星号的版本table*
并添加\cline{2-8}
以制作分隔符。
\begin{table*}[htbp]
\centering
\caption{AUC Result}
\begin{tabular}{|c|c|r|r|r|r|r|r|}
\hline
& & \multicolumn{3}{c|}{\textbf{twitter}} & \multicolumn{3}{c|}{\textbf{blog}} \\\hline
\textbf{classifier} & \textbf{data} & \multicolumn{1}{c|}{\textbf{BOW}} & \multicolumn{1}{c|}{\textbf{CBOW}} & \multicolumn{1}{c|}{\textbf{SG}} & \multicolumn{1}{c|}{\textbf{BOW}} & \multicolumn{1}{c|}{\textbf{CBOW}} & \multicolumn{1}{c|}{\textbf{SG}} \\\hline
\multirow{2}{*}{NB} & mean & & & & & & \\ \cline{2-8}
& var & & & & & & \\\hline
\multirow{2}{*}{RF} & mean & & & & & & \\ \cline{2-8}
& var & & & & & & \\\hline
\multirow{2}{*}{KNN} & mean & & & & & & \\ \cline{2-8}
& var & & & & & & \\\hline
\multirow{2}{*}{RBFSVM} & mean & & & & & & \\ \cline{2-8}
& var & & & & & & \\\hline
\multirow{2}{*}{LinearSVM} & mean & & & & & & \\ \cline{2-8}
& var & & & & & & \\\hline
\multirow{2}{*}{SigmoidSVM} & mean & & & & & & \\ \cline{2-8}
& var & & & & & & \\\hline
\multirow{2}{*}{LR} & mean & & & & & & \\ \cline{2-8}
& var & & & & & & \\\hline
\end{tabular}%
\label{tab:addlabel}%
\end{table*}%