1

I'm new to Latex. The following is my latex code. The emnlp2017 package in the example can be downloaded from here.

%\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}

the result is enter image description here

it is out of boundary right side, How to solve it? I want to make this table in the center of the whole page so that avoid overflow, how to make it?

Also, i want to add horizontal line separating mean and var from column "data" to the end, how to do it?

Thank you!

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
Alex
  • 603

2 Answers2

3

Use the starred version of table* and add \cline{2-8} to make the separators.

\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*}%

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
2

If you want a table not necessarily at the top of the page, you can use the strip environment from cuted.

I simplified your table code for column heads, using the \thead command, from makecell. Also, note times is obsolete, as it does not have support for maths. So I replaced it with the newtx package, based on the Times clone TeX Gyre Termes. The subfigure package is obsolete too, and no more developed. I replaced it with the subcaption package, which defines a subfigure environment.

Last point, I gave a more professional look to your table, using the rules from booktabs and no vertical rules. I differentiated the mean and var rows using colour, instead of a separating rule.

%\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} 

enter image description here

Bernard
  • 271,350