3

This table can't compile (pdflatex) with \tabular, but it can with \tabularx

\begin{table}[h]
    \centering
    \caption{Comparison of two-sided market definitions}
    \label{tab:two-sided market definitions comparison}
    \begin{tabular}{\textwidth}{|l|m{0.2\textwidth}<{\centering}|m{0.2\textwidth}<{\centering}|m{0.2\textwidth}<{\centering}|}
        \toprule
         & \cite{rochet06two} & \cite{evans13} & \cite{rysman09} \\
        \midrule
        payment systems & Y & Y & Y \\
        \midrule
        video game consoles & Y & Y & Y \\
        \midrule
        operating systems & Y & Y & Y \\
        \midrule
        online recruitment & N & Y & Y \\
        \midrule
        shopping malls & N & Y & Y \\
        \midrule
        academic journals & Y & Y & Y \\
        \midrule
        industrial standards & Y & Y & Y \\
        \midrule
        automobile engines & N & N & Y \\
        \midrule
        airports & N & Y & Y \\
        \midrule
        supermarkets & Y & Y & Y/N \\
        \midrule
        conferences & Y & Y & Y \\
        \midrule
        franchising & N & Y/N & Y \\
        \midrule
        collecting societies & Y & Y & Y \\
        \midrule
        highways & N & N & Y \\
        \bottomrule
    \end{tabular}
\end{table} 

Shows this errors

./chapters/terminology_of_data.tex:178: Package array Error:  Illegal pream-token (\textwidth): `c' used.

See the array package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.178   \begin{tabular}{\textwidth}
                                  {|l|m{0.2pt\textwidth}<{\centering}|m{0.2p...
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

./chapters/terminology_of_data.tex:178: Missing number, treated as zero.
<to be read again> 
                   }
l.178 ...abular}{\textwidth}{|l|m{0.2pt\textwidth}
                                                  <{\centering}|m{0.2pt\text...
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

./chapters/terminology_of_data.tex:178: Illegal unit of measure (pt inserted).
<to be read again> 
                   }
l.178 ...abular}{\textwidth}{|l|m{0.2pt\textwidth}
                                                  <{\centering}|m{0.2pt\text...
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)

./chapters/terminology_of_data.tex:178: Missing number, treated as zero.
<to be read again> 
                   }
l.178 ...extwidth}<{\centering}|m{0.2pt\textwidth}
                                                  <{\centering}|m{0.2pt\text...
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
./chapters/terminology_of_data.tex:179: Misplaced \noalign.
\toprule ->\noalign 
                    {\ifnum 0=`}\fi \@aboverulesep =\abovetopsep \global \@b...
l.179       \toprule
                
I expect to see \noalign only after the \cr of
an alignment. Proceed, and I'll ignore this case.
./chapters/terminology_of_data.tex:180: Missing \cr inserted.
<inserted text> 
                \cr 
l.180        &
           \cite{rochet06two} & \cite{evans13} & \cite{rysman09} \\
I'm guessing that you meant to end an alignment here.

Also, why when compiled the table has this hanging horizontal lines?

2
  • 3
    tabular doesn't need {\textwidth} argument Mar 18 at 10:39
  • 1
    Regarding the gaps in the vertical lines around the intersections: Please note that horizontal lines from the booktabs package (such as \toprule, \midrule) are intended to be used without vertical lines.
    – leandriis
    Mar 18 at 11:03

1 Answer 1

8

Unlike the tabular* and tabularx environments, the tabular environment does not take a target width as one of its arguments.

And, while employing the line-drawing macros of the booktabs package, one should not employ any vertical rules. No exceptions. And, please don't overuse horizontal rules either. I'd delete all interior \midrule directives; to provide some visual rhythm to the table, I'd add a bit of extra vertical whitespace after every 5th line or so, with the help of an \addlinespace directive.

The first table in the following screenshot shows the result of using a tabular environment, with the three data columns using p-type columns with width equal to 0.2\textwidth. The second table employs the w column type for the three data columns as no line breaking would appear to be necessary in these columns; the widths of the data columns are set to the natural width of "Y/N". The second table also employs a threeparttable "wrapper" to limit the width of the caption to that of the associated tabular environment.

enter image description here

I suspect that most of your readers may prefer the look of the second, compactly designed table.

\documentclass{article}
\usepackage{booktabs,array}
\usepackage[flushleft]{threeparttable}
\newlength\mylen

\begin{document}
\begin{table}[h]
\centering

   \caption{Comparison of two-sided market definitions\strut}
   \label{tab:comparison}
   \begin{tabular}{@{} l *{3}{>{\centering\arraybackslash}p{0.2\textwidth}} @{}}
   \toprule
   & \cite{rochet06two} & \cite{evans13} & \cite{rysman09} \\
   \midrule
   payment systems     & Y & Y & Y \\  
   video game consoles & Y & Y & Y \\
   operating systems   & Y & Y & Y \\
   online recruitment  & N & Y & Y \\
   shopping malls      & N & Y & Y \\
   \addlinespace
   academic journals   & Y & Y & Y \\
   industrial standards& Y & Y & Y \\
   automobile engines  & N & N & Y \\
   airports            & N & Y & Y \\
   supermarkets        & Y & Y & Y/N \\
   \addlinespace
   conferences         & Y & Y & Y \\
   franchising         & N & Y/N & Y \\
   collecting societies& Y & Y & Y \\
   highways            & N & N & Y \\
   \bottomrule
   \end{tabular}
   
\vspace{8mm}

   \settowidth{\mylen}{Y/N} % set width of data columns
   \begin{threeparttable}
   \caption{Comparison of two-sided market definitions, 
            Natural column widths}
   \label{tab:comparison2}
   \begin{tabular}{@{} l *{3}{wc{\mylen}} @{}}
   \toprule
   & \cite{rochet06two} & \cite{evans13} & \cite{rysman09} \\
   \midrule
   payment systems     & Y & Y & Y \\  
   video game consoles & Y & Y & Y \\
   operating systems   & Y & Y & Y \\
   online recruitment  & N & Y & Y \\
   shopping malls      & N & Y & Y \\
   \addlinespace
   academic journals   & Y & Y & Y \\
   industrial standards& Y & Y & Y \\
   automobile engines  & N & N & Y \\
   airports            & N & Y & Y \\
   supermarkets        & Y & Y & Y/N \\
   \addlinespace
   conferences         & Y & Y & Y \\
   franchising         & N & Y/N & Y \\
   collecting societies& Y & Y & Y \\
   highways            & N & N & Y \\
   \bottomrule
   \end{tabular}
   \end{threeparttable}
\end{table} 
 
\end{document}

You must log in to answer this question.

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