Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to span two column in table (using xtabular) by the following command:

\multicolumn{2}{|p{(\linewidth-\tabcolsep*2-\arrayrulewidth*1)*2/2}|}

The package calc must calculate this equation:

\linewidth-\tabcolsep*2-\arrayrulewidth*1)*2/2

but I get a compile error:

Missing number, treated as zero.

Even simple operation isn't calculated:

\arrayrulewidth*1

I use doxygen documentation and I create tables with HTML tags. This TeX table generated by doxygen:

\begin{TabularC}{2}
\hline
\multicolumn{2}{|p{(\linewidth-\tabcolsep*2-\arrayrulewidth*1)*2/2}|}{Environment  }\\\cline{1-2}
Gravity acceleration &0.\-0  \\\cline{1-2}
Water depth &0.\-0  \\\cline{1-2}
Water density &0.\-0  \\\cline{1-2}
Wave frequencies &$<$empty$>$  \\\cline{1-2}
\end{TabularC}

And TabularC definition:

\newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp}%
\newlength{\tmplength}%
\newenvironment{TabularC}[1]%
{%
\setlength{\tmplength}%
     {\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)}%
      \par\begin{xtabular*}{\linewidth}%
             {*{#1}{|>{\PBS\raggedright\hspace{0pt}}p{\the\tmplength}}|}%
}%
{\end{xtabular*}\par}%

Table in HTML:

<table cellspacing='0' cellpadding='5' style='border: 1px solid rgb(200, 200, 200)'>
<tr>
  <td colspan='2' style='background-color: black; color: white; text-align: center'>Environment</td>
</tr>
<tr>
  <td style='border-right: 1px solid rgb(200, 200, 200)'>Gravity acceleration</td>
  <td>0.0</td>
</tr>
<tr>
  <td style='border-right: 1px solid rgb(200, 200, 200)'>Water depth</td>
  <td>0.0</td>
</tr>
<tr>
  <td style='border-right: 1px solid rgb(200, 200, 200)'>Water density</td>
  <td>0.0</td>
</tr>
<tr>
  <td style='border-right: 1px solid rgb(200, 200, 200)'>Wave frequencies</td>
  <td>&lt;empty&gt;</td>
</tr>
</table>

Command \multicolumn generated from colspan.

share|improve this question
    
I use doxygen, so that equation generetad by it. I post example with table. –  Anton Nov 6 '13 at 5:58
    
Try 2\tabcolsep instead of \tabcolsep*2 –  Marco Daniel Nov 6 '13 at 6:00
    
Tried \linewidth-\tabcolsep and still have this error. –  Anton Nov 6 '13 at 6:16
    
Sorry, can't find anything useful. I don't understand, how TabularC is work, but using \multicolumn without equation (\linewidth-\tabcolsep*2-\arrayrulewidth*1)*2/2 (for example, \multicolumn{2}{|c|}) working. –  Anton Nov 6 '13 at 7:01
add comment

1 Answer

up vote 4 down vote accepted

Well, let no one say The LaTeX Companion isn't useful! Apparently Doxygen is cribbing from it (cf. p. 250).

This works, although the appearance of the table could certainly be improved:

\documentclass[12pt]{article}
\listfiles
\usepackage{calc,xtab,array}

\newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp}%
\newlength{\tmplength}%

\newenvironment{TabularC}[1]{%
  \setlength{\tmplength}%
  {\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)}%
  \par\begin{xtabular*}{\linewidth}%
    {*{#1}{|>{\PBS
          \raggedright\hspace{0pt}} p{\the\tmplength}}|}%
  }%
  {\end{xtabular*}\par}%

\begin{document}

\begin{TabularC}{2}
  \hline \multicolumn{2}{|p{(\linewidth-\tabcolsep*2-\arrayrulewidth*1)*2/2}|}%
  {Environment  }\tabularnewline\cline{1-2}

  Gravity acceleration &0.\-0  \tabularnewline\cline{1-2}

  Water depth &0.\-0  \tabularnewline\cline{1-2}

  Water density &0.\-0  \tabularnewline\cline{1-2}

  Wave frequencies &$<$empty$>$  \tabularnewline\cline{1-2}
\end{TabularC}

\end{document}

I'm not sure what the exact problem was, maybe not loading the array package. (This is often why a minimal example is so important.)

Edit Output of \listfiles (put the command in the preamble, as [now] done above):

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size12.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
    calc.sty    2007/08/22 v4.3 Infix arithmetic (KKT,FJ)
    xtab.sty    2011/07/31 v2.3f Extended supertabular package
   array.sty    2008/09/09 v2.4c Tabular extension package (FMi)
 ***********
share|improve this answer
    
Sorry, that I can't give you more information. I'm new in TeX. I can't compile this example, have the same error. Can it be problem with packages? May be too old version? –  Anton Nov 6 '13 at 7:25
    
What error do you get? –  jon Nov 6 '13 at 7:26
    
! Missing number, treated as zero. <to be read again> ( l.20 {Environment } \tabularnewline\cline{1-2} 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.) –  Anton Nov 6 '13 at 7:29
    
And more info l.20 {Environment } \tabularnewline\cline{1-2} 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.) –  Anton Nov 6 '13 at 7:31
    
@Anton -- Odd. I added the output from \listfiles, but these are not packages that get modified too often, as you can see. (Unfortunately, I must turn in now as I have an early morning tomorrow. Hopefully some clarity will emerge between now than then!) –  jon Nov 6 '13 at 7:37
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.