[Tex/LaTex] Why doesn’t the calc package work

calculations

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.

Best Answer

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)
 ***********