1

I have a table where I needed multirow and multicolumns as part of my data representation. I am facing 2 problems at this moment:

  1. My table does not fit within the predefined margin [picture attached]
  2. If I try to fit the table within margin, the texts does not wrap

enter image description here

As you can see, the width of the page should be 6.97 inches. But my table goes beyond that.

Here is my original code that I am trying.

\begin{table*}
   \centering
   \caption{Results of Real Experiment}
   %\hskip-4.0cm
   \begin{tabular}{|c|c|c|c|c|}
       \hline
       \multirow{2}{*}{Sent Data} &
       \multirow{2}{*}{Settings} &
       \multirow{2}{*}{Functional logic}  &
       \multicolumn{2}{c|}{Received data}  \\
       \cline{4-5}
        & & & Valid Receiver & Intruder \\
        \hline
        \multirow{6}{*}{00001111} & \multirow{3}{*}{Without Titanium      Coating} & Fixed & 11110000 or 10110111 & 1111000 or 10110111 \\
       \cline{3-5}
       & & Deterministic Function & 00101110 or 10110111 & 00101110 or       10110111 \\
       \cline{3-5}
       & & Non-deterministic Function & 11110101 & 10101010 \\
       \cline{2-5}
       & \multirow{3}{*}{With Titanium Coating} & Fixed & 10110111 &      11110000 \\
       \cline{3-5}
       & & Deterministic Function & 10110111 & 00101110 \\
       \cline{3-5}
       & & Non-deterministic Function & 10110111 & Undefined Sequence \\
       \hline
     \end{tabular}
   \label{tab_results}
\end{table*}

I have tried changing the width of certain columns, and that produced problem 2. The texts do not wrap. Here is what I tried.

\begin{tabular}{|c|p{2.5cm}|c|p{3cm}|p{3cm}|}

I have kept rest of the code unchanged. Here is how it looked. Although it fits within the margin, but the spacing is untidy and not within the standards. The texts of adjacent columns overlap and does not wrap within the column.

enter image description here

I am using TexStudio. Any help and suggestions are greatly appreciated. Thanks!

1 Answer 1

2

I suggest you the following measures: - use makecell packages for typing multirow cells content - make shorter text in the third column (to omit word "Function" (is it realy neccessary?) - if you still have problems width table width, use smaller font size, for example \small.

With this you can obtain:

enter image description here

Complete code:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{makecell,multirow}
\usepackage[margin=25mm]{geometry}

\usepackage[active,floats,tightpage]{preview}
\setlength\PreviewBorder{1em}

\begin{document}
\begin{table}[h]
   \centering
   \renewcommand{\arraystretch}{1.2}
 \caption{Results of Real Experiment}
   %\hskip-4.0cm
   \begin{tabular}{|c|c|c|c|c|}
       \hline
\multirowcell{2}{Sent Data} 
    &   \multirowcell{2}{Settings} 
        &   \multirowcell{2}{Functional logic}  
            &   \multicolumn{2}{c|}{Received data}  \\
            \cline{4-5}
    &   &   &   Valid Receiver  &   Intruder        \\
    \hline
\multirowcell{6}{00001111}
    &   \multirowcell{3}{Without\\ Titanium\\ Coating}
        &   Fixed   &   11110000 or 10110111    &   11110000 or 10110111    \\
    \cline{3-5}
    &   &   Deterministic
                    &   00101110 or 10110111    &   00101110 or 10110111    \\
    \cline{3-5}
    &   &    Non-deterministic
                    &   11110101                &   10101010                \\
    \cline{2-5}
    &   \multirowcell{3}{With\\ Titanium\\ Coating}
        &   Fixed   & 10110111                  &   11110000                \\
    \cline{3-5}
    &   &   Deterministic Function
                    &   10110111                &   00101110                \\
    \cline{3-5}
    &   &   Non-deterministic
                    &   10110111                &   Undefined Sequence      \\
    \hline
\end{tabular}
   \label{tab_results}
\end{table}
\end{document}

Since I use one column document, I omit figure*, which is necessary at two column document. Table width is 155mm. Check is this what you like to have.

4
  • Thanks for the solution. It works in a separate document. But when I put the code in the main paper work [with other contents], the compilation is terribly slow, hasn't compiled yet. Several failed attempts to get it compiled. I have pasted your packages in the main tex file. Any idea what's happening? These are the package declarations in the main tex file link Jan 20, 2016 at 12:57
  • I shouldn't be. Similar, even bigger and more complex tables in my documents doesn't slow compilation significantly. Without see your document, is difficult to say anything particular.
    – Zarko
    Jan 20, 2016 at 13:12
  • The compilation takes almost 10-15 minutes, and ends up with an error that says Log file is very large >168MB. I will have to see with my other packages about whats going wrong. Jan 21, 2016 at 10:24
  • You have something very wrong in your document! For comparison: one my text with 100 pages, 300 equations, 60 TikZ images, 20 mdframe style theorems, 30 tcolorbox-es 10 tables (one is your table for test), bibtex (15 units), has only 221 kB! Compilation time: ~7 sec (old Pentium with 2,2GHz clock, 8G RAM, SSD disks). Probably you have some loop in document. Try to found out by move \end{document} somewhere to the middle of document. If log file become of normal size, than the cause is in the second part of document ... then continue on this way. Good luck in searching for cause!
    – Zarko
    Jan 21, 2016 at 12:38

You must log in to answer this question.

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