如何在 LaTeX 中使用全宽表格?

如何在 LaTeX 中使用全宽表格?

我正在尝试在 LaTeX 中使用全宽表格。

我的乳胶代码如下所示:

 \documentclass[12pt,journal,compsoc]{IEEEtran}
%\usepackage{ifpdf}
\usepackage{cite}
\ifCLASSINFOpdf
  \usepackage[pdftex]{graphicx}
  % \graphicspath{{../pdf/}{../jpeg/}}
  % \DeclareGraphicsExtensions{.pdf,.jpeg,.png}
\else
  \usepackage[dvips]{graphicx}
  % \graphicspath{{../eps/}}
  % \DeclareGraphicsExtensions{.eps}
\fi
%\usepackage[cmex10]{amsmath}
%\usepackage{algorithmic}
\usepackage{amsfonts}
%\usepackage{subfig}
\usepackage{amsmath}

\usepackage{caption}
\usepackage{subcaption}
\usepackage{multirow}
 \usepackage[table,xcdraw]{xcolor}
% \usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{listings}
%\ifCLASSOPTIONcompsoc
%  \usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
%\else
%  \usepackage[caption=false,font=footnotesize]{subfig}
%\fi
%\usepackage{fixltx2e}
%\usepackage{stfloats}
% \usepackage{dblfloatfix}
%\ifCLASSOPTIONcaptionsoff
%  \usepackage[nomarkers]{endfloat}
% \let\MYoriglatexcaption\caption
% \renewcommand{\caption}[2][\relax]{\MYoriglatexcaption[#2]{#2}}
%\fi
\usepackage[hyphens]{url}



\begin{document}
\title{network design}
\author{Loren dorem}
\markboth{nreis, May~2016}%
{Shell \MakeLowercase{\textit{et al.}}: Bare Demo of IEEEtran.cls for Computer Society Journals}
\date{\normalsize\today}

\begin{center}

\begin{tabular}{ |p{3cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}| }
 \hline
 \multicolumn{5}{|c|}{F1-accuracy} \\
 \hline
 \textbf{Methods}& \textbf{first dataset} &\textbf{second dataset} &\textbf{third dataset} & \textbf{forth dataset}\\
 \hline
 first   & 0.878    &0.648&   0.858 & 0.486\\
 second   & 0.879  & 0.654   &0.857 & 0.480\\
third & 0.863&  0.664 & 0.855 & - \\
forth & 0.855    &0.664 & 0.856&  -\\
fifth &0.858   & 0.691  & 0.868&0.528\\
\hline
 \textbf{sixth}& \textbf{0.899} &\textbf{0.686} &\textbf{0.873} & \textbf{0.565}\\
  \hline
\end{tabular}
\end{center}

\begin{figure}[!h]
 \begin{center}
 \includegraphics[width=1.0\linewidth]{final.png}
 \caption{F1-accuracy of reuters and slashdot dataset}
 \label{fig:FeatLearn}
 \end{center}
 \end{figure}

 \begin{figure}[!h]
 \begin{center}
 \includegraphics[width=0.95\linewidth]{final_rc3.png}
 \caption{F1-accuracy of rcv1 and aapd dataset}
 \label{fig:FeatLearn}
 \end{center}
 \end{figure}

For POS data set, we achieved state of the art tagging accuracy with or without the use of extra data
resource. POS data set has been extensively tested
and the past improvement can be realized in Table
4. Our test accuracy is 97.55 which is significantly better than others in the confidence level of
95. In addition, our BI-LSTM-CRF model already reaches a good accuracy without the use of
the Senna embedding

All chunking systems performance is shown in
table 5. Kudo et al. won the CoNLL 2000 challenge with a F1 score of 93.48 Their approach
was a SVM based classifier. They later improved
the results up to 93.91. Recent work include the
CRF based models (Sha and Pereira, 2003; Mcdonald et al., 2005; Sun et al., 2008). More recent is (Shen and Sarkar, 2005) which obtained
95.23 accuracy with a voting classifier scheme,
where each classifier is trained on different tag
representations (IOB, IOE, etc.). Our model outperforms all reported systems except (Shen and
Sarkar, 2005).
The performance of all systems for NER is
shown in table 6. (Florian et al., 2003) presented the best system at the NER CoNLL 2003
challenge, with 88.76 F1 score. They used a
combination of various machine-learning classifiers. The second best performer of CoNLL 2003
(Chieu., 2003) was 88.31 F1, also with the help
of an external gazetteer. Later, (Ando and Zhang.,
2005) reached 89.31 F1 with a semi-supervised
approach. The best F1 score of 90.90 was reported in (Passos et al., 2014) which employed a

\end{document}

但是当我添加两幅图像时,图像会像这样与表格重叠:

在此处输入图片描述

如何修复?

谢谢 !

答案1

您的代码中存在几个问题,例如

  1. 你可以简单地使用\usepackage graphicx你的

    \ifCLASSINFOpdf
      \usepackage[pdftex]{graphicx}
      % \graphicspath{{../pdf/}{../jpeg/}}
      % \DeclareGraphicsExtensions{.pdf,.jpeg,.png}
    \else
      \usepackage[dvips]{graphicx}
      % \graphicspath{{../eps/}}
      % \DeclareGraphicsExtensions{.eps}
    \fi
    

    因为该包能够评估所需的驱动程序pdftexdvips自行评估。

  2. 您使用了很多与此问题无关的软件包。我在接下来的 mwe 中将其删除。

  3. 在两列布局中,您必须使用环境table*来获取横跨两列的表格。请参阅以下 mwe。

  4. 使用内部figure命令\centering代替环境center(图形周围的空白较少)。

  5. 不要在文本中写“表格 6”,而是使用命令,\ref例如table~\ref{tab:methods}。请注意,我使用此处使用的以下标签为您的表格添加了标题。

  6. 使用\cite{}等将您引用的 bib 条目添加到您的文本中,不要手动编写它们,这只会在文本中产生错误......

修正后的 MWE

\documentclass[12pt,journal,compsoc]{IEEEtran}

\usepackage{caption}
\usepackage{subcaption}
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{graphicx} % <===============================================
\usepackage{booktabs}


\begin{document}

\title{network design}
\author{Loren dorem}
\markboth{nreis, May~2016}%
{Shell \MakeLowercase{\textit{et al.}}: Bare Demo of IEEEtran.cls for Computer Society Journals}
\date{\normalsize\today}

\maketitle % <==========================================================
\begin{table*} % <======================================================
  \caption{table caption}\label{tab:methods} % <========================
\begin{tabular}{ |p{3cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}| }
 \hline
 \multicolumn{5}{|c|}{F1-accuracy} \\
 \hline
 \textbf{Methods}& \textbf{first dataset} &\textbf{second dataset} &\textbf{third dataset} & \textbf{forth dataset}\\
 \hline
 first   & 0.878    &0.648&   0.858 & 0.486\\
 second   & 0.879  & 0.654   &0.857 & 0.480\\
third & 0.863&  0.664 & 0.855 & - \\
forth & 0.855    &0.664 & 0.856&  -\\
fifth &0.858   & 0.691  & 0.868&0.528\\
\hline
 \textbf{sixth}& \textbf{0.899} &\textbf{0.686} &\textbf{0.873} & \textbf{0.565}\\
  \hline
\end{tabular}
\end{table*}

\begin{figure}[!h]
  \centering % <========================================================
  \includegraphics[width=1.0\linewidth]{example-image-a} % final.png
  \caption{F1-accuracy of reuters and slashdot dataset}
  \label{fig:FeatLearn}
\end{figure}

\begin{figure}[!h]
  \centering % <========================================================
  \includegraphics[width=0.95\linewidth]{example-image-a} % final_rc3.png
  \caption{F1-accuracy of rcv1 and aapd dataset}
  \label{fig:FeatLearn}
\end{figure}

For POS data set, we achieved state of the art tagging accuracy with or without the use of extra data
resource. POS data set has been extensively tested
and the past improvement can be realized in Table
4. Our test accuracy is 97.55 which is significantly better than others in the confidence level of
95. In addition, our BI-LSTM-CRF model already reaches a good accuracy without the use of
the Senna embedding

All chunking systems performance is shown in
table 5. Kudo et al. won the CoNLL 2000 challenge with a F1 score of 93.48 Their approach
was a SVM based classifier. They later improved
the results up to 93.91. Recent work include the
CRF based models (Sha and Pereira, 2003; Mcdonald et al., 2005; Sun et al., 2008). More recent is (Shen and Sarkar, 2005) which obtained
95.23 accuracy with a voting classifier scheme,
where each classifier is trained on different tag
representations (IOB, IOE, etc.). Our model outperforms all reported systems except (Shen and
Sarkar, 2005).
The performance of all systems for NER is
shown in table~\ref{tab:methods}. (Florian et al., 2003) presented the best system at the NER CoNLL 2003
challenge, with 88.76 F1 score. They used a
combination of various machine-learning classifiers. The second best performer of CoNLL 2003
(Chieu., 2003) was 88.31 F1, also with the help
of an external gazetteer. Later, (Ando and Zhang.,
2005) reached 89.31 F1 with a semi-supervised
approach. The best F1 score of 90.90 was reported in (Passos et al., 2014) which employed a

\end{document}

及其结果:

生成的 pdf

请注意,表格已移至第二页,因为这样很容易开始单列部分!这是该模板的常见行为。如果您不想这样,则需要缩短表格,例如将标题分成两行以适合一列...

答案2

我会将列标题写成两行。在这种情况下,您的表格可以放在一列中:

在此处输入图片描述

在上表中,我使用tabularx表格环境、booktabs表格规则和siunitx带有数字的列(现在按小数点对齐)。

\documentclass[12pt,journal,compsoc]{IEEEtran}
\usepackage{booktabs,
            tabularx}
\newcommand\mcbf[1]{\multicolumn{1}{>{\centering\arraybackslash\bfseries}X}{#1}}
\usepackage{siunitx}
\usepackage{etoolbox}
\newrobustcmd{\B}{\fontseries{b}\selectfont} % non-extended bold font

\usepackage{lipsum}

\begin{document}
\lipsum[1]
    \begin{table}[htb]
\sisetup{table-format=1.3,
         detect-weight}

    \begin{tabularx}{\linewidth}{@{} l *{4}{S} @{}}
    \toprule
 \multicolumn{5}{c}{F1-accuracy} \\
    \midrule
\mcbf{Methods}
            &   \mcbf{first dataset}
                        &   \mcbf{second dataset}
                                    &   \mcbf{third dataset}
                                                &   \mcbf{forth dataset}\\
    \midrule
 first      & 0.878     & 0.648     & 0.858     & 0.486     \\
 second     & 0.879     & 0.654     & 0.857     & 0.480     \\
third       & 0.863     & 0.664     & 0.855     & {--}      \\
forth       & 0.855     & 0.664     & 0.856     & {--}      \\
fifth       & 0.858     & 0.691     & 0.868     & 0.528     \\
    \midrule
\textbf{sixth}
            & \B 0.89   & \B 0.686  & \B 0.873  & \B 0.565  \\
    \bottomrule
\end{tabularx}
    \end{table}\lipsum[2]
    \begin{figure}[htb]
\includegraphics[width=\linewidth]{final.png}
\caption{F1-accuracy of reuters and slashdot dataset}
\label{fig:FeatLearn}
    \end{figure}
 \lipsum[3]
    \begin{figure}[htb]
\includegraphics[width=\linewidth]{final_rc3.png}
\caption{F1-accuracy of rcv1 and aapd dataset}
\label{fig:FeatLearn}
    \end{figure}
\lipsum[4]

\end{document}

编辑: 使用上面的表格,您将不会遇到表格上图像重叠的问题(通过编译上面的 MWE(最小工作示例)您可以确认这一点)。此外,表格现在看起来更专业了。

相关内容