4

My table currently looks like this in my paper, it does not fit into the page of my IEEE paper. A lot of space is wasted in the given format of this paper.

How can I make it fit into the the page of my IEEE paper's page? Here is the code I am using, I want the right part of the table to fit into the page

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

enter image description here

15
  • 1
    Fit the column width or fit text width?
    – Bernard
    Oct 24, 2019 at 19:23
  • the right part of the table should appear on the page which is not the case since the right part of the table is cut Oct 24, 2019 at 19:31
  • 1
    With 9 columns? Split your table in two and write one above the other.
    – Bernard
    Oct 24, 2019 at 19:43
  • 2
    Please try to clean up your table code. I highly doubt, that all the occurences or \multicolumn{1}{c|} are really needed. Also, whyt't the purpose of \multirow{3}{*}?
    – leandriis
    Oct 24, 2019 at 20:40
  • 1
    can you please show me the modified code that would make it fit into the page, I simplified the code as much as I could Oct 24, 2019 at 20:57

2 Answers 2

1

I've changed the main table setup from tabular to tabularx, to assure that the seven data columns have equal widths. I also chose to remove a lot of the nightmarishly complex wrapper code which you applied to virtually all cells and which does nothing except inhibit the proper working of the tabularx code.

enter image description here

\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
  • the border of the table is overflowing on the right, this happens for the horizontal borders Oct 25, 2019 at 6:37
  • @user3406764 - The code I posted above does not produce an overflow. If what you're running on your system does, then it must be because your code differs in substance from mine. As I'm not blessed with any particular psychic powers, I'm afraid I can't speculate meaningfully on how the code you employ differs from mine.
    – Mico
    Oct 25, 2019 at 10:06
0

I propose this layout, simplifying the code and using \makecell,which allows for multiline cells with the standard column specifiers:

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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .