2

enter image description hereI have used the following code to create a large table with vertical column names. However, the table overlapped on my text. I need to have a table on the whole page. I appreciate any help about this as I am working on my paper.

\documentclass[compsoc]{IEEEtran}
\usepackage{array}
\usepackage{booktabs}
\usepackage{rotating}

\newcolumntype{P}[2]{%
  >{\begin{turn}{#1}\begin{minipage}{#2}\small\raggedright\hspace{0pt}}l%
  <{\end{minipage}\end{turn}}%
}
\begin{document}
    \begin{table}
    %   \centering
      \caption{Some properties}
      \label{tab:test1}
      \begin{tabular}{@{}rcccccccccccccccccc@{}}
       \toprule
      & \multicolumn{1}{P{90}{1.6cm}}{Feedback} &
        \multicolumn{1}{P{90}{1.6cm}}{Adaptation} &
        \multicolumn{1}{P{90}{1.6cm}@{}}{Previous Knowledge Construction}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Challenging Assessment Methods}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Collaborative Learning}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Authentic \& Challenging Goals}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Inquiry-Based LEarning}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Use of Multimedia}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Multi vs. Single users}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Visibilitiy of System Status}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Sense of Presence}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Matching with Real-world}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{User Control \& Freedom}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Consistency \& Standards}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Error Prevention}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Previous Knowledge Construction}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Recognition Rather than Recall}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Flexible and ease of use}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{High Representational Fidelity}\\
         \midrule
        Babich et al.\cite{Babich2004} & N & N & N & N & N & N& N & X & X & N & N & N & N& X & N & N & N & N\\
    %   System 2 & X & X & X \\
    %   System 3 & X &    & X \\
      \bottomrule
      \end{tabular}
    \end{table}

\end{document}
leandriis
  • 62,593
  • 1
    please edit your example so it is a complete document people can run, as it is we do not know what a P column is, or the size of your page so it is impossible to help – David Carlisle Jul 25 '19 at 19:27
  • 1
    Welcome to TeX.SE! Please extend your code fragment to complete small document, which we can test as it is. – Zarko Jul 25 '19 at 19:28
  • Hi David, thanks for your comment I edited my post. – kiana khademi Jul 25 '19 at 19:35
  • You declared a total of 19 columns but used 20. In order to get rid of the error message, you will have to add another column: \begin{tabular}{@{}rccccccccccccccccccc@{}} or shorter: \begin{tabular}{@{}r*{19}{c}@{}}. Nevertheless, I'd suggest to switch the page orientation to landscape as the table is now too wide for the page. – leandriis Jul 25 '19 at 19:36
  • @leandriis I applied your command but the table is still overlapping on the text. – kiana khademi Jul 25 '19 at 19:39
  • table* instead ot table should help. – leandriis Jul 25 '19 at 19:41
  • Yes, you can change the orientation of a specific page using the landscape environment. Other possibilities might be found here: How to rotate a table?. If you want to keep your table on a portrait page, you might want to allow the header row to be a bit taller (replace {1.6cm}by{3.25cm}` and your table's width will no longer exceed teh textwidth. – leandriis Jul 25 '19 at 19:45

3 Answers3

1

In the following example, I have added the missing column specifier, replaced table by table* to prevent the table from overlapping the text and used a taller header row in combination with a slightly decreased \tabcolsep in order to make the table narrow enough to fit into the page:

enter image description here

\documentclass[compsoc]{IEEEtran}
\usepackage{array}
\usepackage{booktabs}
\usepackage{rotating}

\usepackage{lipsum}

\newcolumntype{P}[2]{%
  >{\begin{turn}{90}\begin{minipage}{#2}\small\raggedright\hspace{0pt}}l%
  <{\end{minipage}\end{turn}}%
}

\newcommand{\myrothead}{\multicolumn{1}{P{90}{3.25cm}}}



\begin{document}
\lipsum\lipsum \lipsum
    \begin{table*}
      \setlength{\tabcolsep}{4.9pt}
      \caption{Some properties}
      \label{tab:test1}
      \begin{tabular}{@{}r*{19}{c}@{}}
       \toprule
      & \myrothead{Feedback} &
        \myrothead{Adaptation} &
        \myrothead{Previous Knowledge Construction}&
        \myrothead{Challenging Assessment Methods}&
        \myrothead{Collaborative Learning}&
        \myrothead{Authentic \& Challenging Goals}&
        \myrothead{Inquiry-Based LEarning}&
        \myrothead{Use of Multimedia}&
        \myrothead{Multi vs. Single users}&
        \myrothead{Visibilitiy of System Status}&
        \myrothead{Sense of Presence}&
        \myrothead{Matching with Real-world}&
        \myrothead{User Control \& Freedom}&
        \myrothead{Consistency \& Standards}&
        \myrothead{Error Prevention}&
        \myrothead{Previous Knowledge Construction}&
        \myrothead{Recognition Rather than Recall}&
        \myrothead{Flexible and ease of use}&
        \myrothead{High Representational Fidelity}\\
         \midrule
        Babich et al.\cite{Babich2004} & N & N & N & N & N & N& N & X & X & N & N & N & N& X & N & N & N & N\\
    %   System 2 & X & X & X \\
    %   System 3 & X &    & X \\
      \bottomrule
      \end{tabular}
    \end{table*}
\lipsum

\end{document}

enter image description here

Depending on how many entries (rows your final table will have, you could also consider transposing the table. This might make the quite long column headers more easily readable.

leandriis
  • 62,593
1

Your table will perfectly fit in portrait orientation provided you take a larger height for the column heads and a smaller value for \tabcolsep, and use the table* environment. I did so using the \rothead command from makecell for its much simpler syntax. Last, I used the tabularx environment, and the X type for the first column;

\documentclass[compsoc]{IEEEtran}
\usepackage{tabularx, makecell}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{lipsum}

\begin{document}

\begin{table*}
 \centering
\setlength{\tabcolsep}{3.5pt}
\setlength\rotheadsize{3.2cm}
\renewcommand{\theadfont}{\small}
  \caption{Some properties}
  \label{tab:test1}
  \begin{tabularx}{\linewidth}{@{}X*{19}{c}@{}}
   \toprule
  & \rothead{Feedback} &
    \rothead{Adaptation} &
    \rothead{Previous Knowledge Construction}&
    \rothead{Challenging Assessment Methods}&
    \rothead{Collaborative Learning}&
    \rothead{Authentic \& Challenging Goals}&
    \rothead{Inquiry-Based LEarning}&
    \rothead{Use of Multimedia}&
    \rothead{Multi vs. Single users}&
    \rothead{Visibilitiy of System Status}&
    \rothead{Sense of Presence}&
    \rothead{Matching with Real-world}&
    \rothead{User Control \& Freedom}&
    \rothead{Consistency \& Standards}&
    \rothead{Error Prevention}&
    \rothead{Previous Knowledge Construction}&
    \rothead{Recognition Rather than Recall}&
    \rothead{Flexible and ease\\ of use}&
    \rothead{High Representational Fidelity}\\
     \midrule
    Babich et al.\cite{Babich2004} & N & N & N & N & N & N& N & X & X & N & N & N & N& X & N & N & N & N\\
% System 2 & X & X & X \\
% System 3 & X & & X \\
  \bottomrule
  \end{tabularx}
\end{table*}

\lipsum[1-25]

\end{document} 

enter image description here

Bernard
  • 271,350
0

I have found the solution. As @leandriis mentioned in the comment, the width of the table is big so I needed to change the direction to landscape. At the end, code looks like this:

\documentclass[compsoc]{IEEEtran}
\usepackage{array}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{lscape}
\newcolumntype{P}[2]{%
  >{\begin{turn}{#1}\begin{minipage}{#2}\small\raggedright\hspace{0pt}}l%
  <{\end{minipage}\end{turn}}%
}
\begin{document}
\begin{landscape}
    \begin{table}
    %   \centering
      \caption{Some properties}
      \label{tab:test1}
      \begin{tabular}{@{}rcccccccccccccccccc@{}}
       \toprule
      & \multicolumn{1}{P{90}{1.6cm}}{Feedback} &
        \multicolumn{1}{P{90}{1.6cm}}{Adaptation} &
        \multicolumn{1}{P{90}{1.6cm}@{}}{Previous Knowledge Construction}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Challenging Assessment Methods}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Collaborative Learning}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Authentic \& Challenging Goals}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Inquiry-Based LEarning}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Use of Multimedia}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Multi vs. Single users}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Visibilitiy of System Status}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Sense of Presence}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Matching with Real-world}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{User Control \& Freedom}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Consistency \& Standards}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Error Prevention}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Previous Knowledge Construction}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Recognition Rather than Recall}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{Flexible and ease of use}&
        \multicolumn{1}{P{90}{1.6cm}@{}}{High Representational Fidelity}\\
         \midrule
        Babich et al.\cite{Babich2004} & N & N & N & N & N & N& N & X & X & N & N & N & N& X & N & N & N & N\\
    %   System 2 & X & X & X \\
    %   System 3 & X &    & X \\
      \bottomrule
      \end{tabular}
    \end{table}
\end{landscape}
\end{document}