title: How to calculate the widths of multi-column (colspan) HTML-tables?
body: <p>I am trying to parse an HTML-table into LaTeX code (using <code>longtabu</code> as it supports custom column width settings) in a Java program I am writing. My code was running quite stable and the output seemed quite OK until just now. I have to support the table's <code>colspan</code>-feature (I am skipping rowspan for now) and that is where the problem lies. The table that is causing problems looks something like this:</p>
  
  <pre><code>&lt;table&gt;
  &lt;tr&gt;
      &lt;td width="385" colspan="3"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="359" colspan="3"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="151"&gt;
          Content
      &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td width="24"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="361" colspan="2"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="359" colspan="3"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="151"&gt;
          Content
      &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td width="24"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="276"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="85"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="198" colspan="2"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="161"&gt;
          Content
      &lt;/td&gt;
      &lt;td width="151"&gt;
          Content
      &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p></p>
  
  <p>I identified the problem in the fact, that none of the table rows defines all of the column-widths.</p>
  
  <p>In my understanding I would need a system of linear equations to solve the calculation of the width of the single columns... am I right or have a I missed something?</p>
  
  <p>What would be the best approach to solve such an equations system in Java?</p>