使表格适合我的 IEEE 论文的页面并最小化空间

使表格适合我的 IEEE 论文的页面并最小化空间

我的表格目前在我的论文中是这样的,它不适合我的 IEEE 论文的页面。这篇论文的给定格式浪费了很多空间。

我怎样才能让它适合我的 IEEE 论文页面?这是我使用的代码,我希望表格的右侧部分适合页面

 \documentclass[conference]{IEEEtran}
 \IEEEoverridecommandlockouts

\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
 \usepackage{algorithmic}
   \usepackage{graphicx}
 \usepackage{algorithm}
\usepackage{textcomp}
\usepackage{xcolor}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\usepackage{booktabs, makecell, multirow, tabularx}

\newcommand\mytab[1]{\begin{tabular}[t]{@{}c@{}} #1 \end{tabular}}
\newcommand\mc[2]{\multicolumn{#1}{c}{#2}}
 \renewcommand{\algorithmiccomment}[1]{//#1}


 \begin{document}




\begin{table*}[]
 \caption{Matrix for Requirement-to-Code Validation/Auto-Completion}
  \label{tab:matrix}
  \begin{tabular}{|l|l|l|l|l|l|l|l|l|}
  \hline
    \multicolumn{2}{|l|}{\multirow{2}{*}{}} & \multicolumn{7}{l|} 
  {Callees/CallersCallers/CalleesCallees} \\ \cline{3-9} 
\multicolumn{2}{|l|}{} & T & N & U & NT & UT & UN & UNT \\ \hline
  \multirow{21}{*}{\begin{tabular}[c]{@{}l@{}}Callers/\\ Callers/\\ 
   Callees\end{tabular}} & \multirow{3}{*}{T} & \multirow{3}{*}{T} & 
    \multirow{3}{*}{U} & \multirow{3}{*}{Tinner/ULeaf/Troot} & \multirow{3} 
    {*}{T} & \multirow{3}{*}{T} & \multirow{3}{*}{U} & \multirow{3}{*}{T} \\
     &  &  &  &  &  &  &  &  \\ \cline{2-9} 
     & \multirow{3}{*}{N} & \multirow{3}{*}{Uinner/Uleaf/Nroot} & 
      \multirow{3}{*}{N} & \multirow{3}{*}{Ninner/Uleaf/Nroot} & 
    \multirow{3}{*}{Uinner/Nleaf/Nroot} & \multirow{3}{*} 
    {Uinner/Uleaf/Nroot} & \multirow{3}{*}{N} & \multirow{3}{*} 
     {Uinner/Uleaf/Nroot} \\
      &  &  &  &  &  &  &  &  \\ \cline{2-9} 
        & \multirow{3}{*}{U} & \multirow{3}{*}{Uinner/Tleaf/Uroot} & 
     \multirow{3}{*}{Ninner/Nleaf/Uroot} & \multirow{3}{*}{U} & \multirow{3} 
     {*}{U} & \multirow{3}{*}{U} & \multirow{3}{*}{U} & \multirow{3}{*}{U} 
   \\
     &  &  &  &  &  &  &  &  \\ \cline{2-9} 
       & \multirow{3}{*}{NT} & \multirow{3}{*}{Tinner/Tleaf/Uroot} & 
   \multirow{3}{*}{Ninner/Uleaf/Uroot} & \multirow{3}{*}{U} & \multirow{3} 
     {*}{Tinner/Uleaf/Uroot} & \multirow{3}{*}{Tinner/Uleaf/Uroot} & 
     \multirow{3}{*}{U} & \multirow{3}{*}{Tinner/Uleaf/Uroot} \\
        &  &  &  &  &  &  &  &  \\ \cline{2-9} 
      & \multirow{3}{*}{UT} & \multirow{3}{*}{T} & \multirow{3}{*}{U} & 
        \multirow{3}{*}{Tinner/Uleaf/Troot} & \multirow{3}{*} 
  {Tinner/Uleaf/Troot} & \multirow{3}{*}{T} & \multirow{3}{*}{U} & 
     \multirow{3}{*}{Tinner/Uleaf/Troot} \\
   &  &  &  &  &  &  &  &  \\ \cline{2-9} 
    & \multirow{3}{*}{UN} & \multirow{3}{*}{U} & \multirow{3}{*} 
     {Ninner/Nleaf/Uroot} & \multirow{3}{*}{U} & \multirow{3}{*}{U} & 
   \multirow{3}{*}{U} & \multirow{3}{*}{Uinner/Nleaf/Nroot} & \multirow{3} 
    {*}{U} \\
     &  &  &  &  &  &  &  &  \\ \cline{2-9} 
     & \multirow{3}{*}{UNT} & \multirow{3}{*}{Tinner/Tleaf/Uroot} & 
     \multirow{3}{*}{Ninner/Uleaf/Uroot} & \multirow{3}{*}{U} & \multirow{3} 
     {*}{Tinner/Uleaf/Uroot} & \multirow{3}{*}{Tinner/Uleaf/Uroot} & 
      \multirow{3}{*}{U} & \multirow{3}{*}{Tinner/Uleaf/Uroot} \\
      &  &  &  &  &  &  &  &  \\ \hline
    \end{tabular}
  \end{table*}

 \end{document}

在此处输入图片描述

答案1

我已将主表设置从 更改tabulartabularx,以确保七个数据列的宽度相等。我还选择删除大量极其复杂的包装器代码,这些代码几乎应用于所有单元格,除了妨碍代码正常工作外,没有任何作用tabularx

在此处输入图片描述

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts

\usepackage{cite}
\usepackage{amsmath,amssymb}
 \usepackage{algorithmic,algorithm}
 \renewcommand{\algorithmiccomment}[1]{//#1}
\usepackage{graphicx,textcomp,xcolor}
\usepackage{multirow, tabularx, ragged2e}
\newcolumntype{C}{>{\Centering\arraybackslash}X}

\newcommand\mytab[1]{\begingroup%
    \renewcommand\arraystretch{1}%
    \begin{tabular}[t]{@{}c@{}}#1\end{tabular}%
    \endgroup}

\begin{document}

\begin{table*}
\renewcommand{\arraystretch}{2}
\setlength{\tabcolsep}{3pt} % default: 6pt
\scriptsize 
\caption{Matrix for Requirement-to-Code Validation/Auto-Completion}
\label{tab:matrix}
\begin{tabularx}{\textwidth}{|l|c|*{7}{C|}}
\hline
\multicolumn{2}{|c|}{} & \multicolumn{7}{c|}{Callees/Callers Callers/Callees Callees} \\ 
\cline{3-9} 
\multicolumn{2}{|c|}{} & T & N & U & NT & UT & UN & UNT \\ 
\hline
\multirow{7}{*}{\mytab{Callers/ \\ Callers/ \\ Callees}}
& T & T & U & Tinner/ULeaf/Troot & T & T & U & T \\ 
\cline{2-9} 
& N & Uinner/Uleaf/Nroot & N & Ninner/Uleaf/Nroot & Uinner/Nleaf/Nroot
& Uinner/Uleaf/Nroot & N & Uinner/Uleaf/Nroot \\ 
\cline{2-9} 
& U & Uinner/Tleaf/Uroot & Ninner/Nleaf/Uroot & U  & U & U & U & U  \\ 
\cline{2-9} 
& NT & Tinner/Tleaf/Uroot & Ninner/Uleaf/Uroot & U & Tinner/Uleaf/Uroot & Tinner/Uleaf/Uroot & U & Tinner/Uleaf/Uroot \\ 
\cline{2-9} 
& UT & T & U & Tinner/Uleaf/Troot & Tinner/Uleaf/Troot & T & U & Tinner/Uleaf/Troot \\  
\cline{2-9} 
& UN & U & Ninner/Nleaf/Uroot & U & U & U & Uinner/Nleaf/Nroot & U \\ 
\cline{2-9} 
& UNT & Tinner/Tleaf/Uroot & Ninner/Uleaf/Uroot & U & Tinner/Uleaf/Uroot & Tinner/Uleaf/Uroot & U & Tinner/Uleaf/Uroot \\
\hline
\end{tabularx}
\end{table*}

\end{document}

答案2

我建议采用这种布局,简化代码并使用\makecell,允许使用标准列说明符的多行单元格:

    \documentclass[conference]{IEEEtran}
     \IEEEoverridecommandlockouts
     \usepackage{showframe}

    \usepackage{cite}
    \usepackage{amsmath,amssymb}
     \usepackage{algorithmic}
       \usepackage{graphicx}
     \usepackage{algorithm}
    \usepackage{textcomp}
    \usepackage{xcolor}
    \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
    \usepackage{booktabs, makecell, multirow, tabularx}

    \newcommand\mytab[1]{\begin{tabular}[t]{@{}c@{}} #1 \end{tabular}}
    \newcommand\mc[2]{\multicolumn{#1}{c}{#2}}
     \renewcommand{\algorithmiccomment}[1]{//#1}
    \usepackage{lipsum}

     \begin{document}

    \begin{table*}
    \setcellgapes{1.5ex}\makegapedcells
    \centering
     \caption{Matrix for Requirement-to-Code Validation/Auto-Completion}
     \label{tab:matrix}
    \begin{tabular}{|l|*{8}{c|}}
    \hline
    \multicolumn{2}{|l|}{} & \multicolumn{7}{l}
      {Callees/CallersCallers/CalleesCallees} \\ \cline{3-9}
     \multicolumn{2}{|l|}{} & T & N & U & NT & UT & UN & UNT \\ \hline
    \multirowcell{20.2}{Callers/\\ Callers/\\ Callees} & T & T & U & \makecell{Tinner/ULeaf/\\ Troot} & T & T & U & T \\ %
    \cline{2-9}
      & N & \makecell{Uinner/Uleaf/\\ Nroot} & N & \makecell{Ninner/Uleaf/\\ Nroot} & \makecell{Uinner/Nleaf/\\ Nroot} & \makecell{Uinner/Uleaf/\\ Nroot} & N & \makecell{Uinner/Uleaf/\\ Nroot} \\ %
      \cline{2-9}
       & U & \makecell{Uinner/Tleaf/\\ Uroot} & \makecell{Ninner/Nleaf/\\ Uroot} & U & U & U & U & U \\%
        \cline{2-9}
    & NT & \makecell{Tinner/Tleaf/\\ Uroot} & \makecell{Ninner/Uleaf/\\ Uroot} & U & \makecell{Tinner/Uleaf/\\ Uroot} & \makecell{Tinner/Uleaf/\\ Uroot} & U & \makecell{Tinner/Uleaf/\\ Uroot} \\ %
       \cline{2-9}
         & UT & T & U & \makecell{Tinner/Uleaf/\\T root} & \makecell{Tinner/Uleaf/\\ Troot} & T &
        U & \makecell{Tinner/Uleaf/\\ Troot} \\ %
        \cline{2-9}
         & UN & U & \makecell{Ninner/Nleaf/\\ Uroot} & U & U & U & \makecell{Uinner/Nleaf/\\ Nroot} & U \\ %
         \cline{2-9}
       & UNT & \makecell{Tinner/Tleaf/\\ Uroot} & \makecell{Ninner/Uleaf/\\ Uroot} & U & \makecell{Tinner/Uleaf/\\ Uroot} & \makecell{Tinner/Uleaf/\\ Uroot} & U & \makecell{Tinner/Uleaf/\\ Uroot} \\ \hline
    \end{tabular}
    \end{table*}

    \lipsum[1-15]

     \end{document} 

在此处输入图片描述

相关内容