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><empty></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:
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):