Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9116885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:46:47+00:00 2026-06-17T04:46:47+00:00

I am trying to parse an HTML-table into LaTeX code (using longtabu as it

  • 0

I am trying to parse an HTML-table into LaTeX code (using longtabu 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 colspan-feature (I am skipping rowspan for now) and that is where the problem lies. The table that is causing problems looks something like this:

<table>
<tr>
    <td width="385" colspan="3">
        Content
    </td>
    <td width="359" colspan="3">
        Content
    </td>
    <td width="151">
        Content
    </td>
</tr>
<tr>
    <td width="24">
        Content
    </td>
    <td width="361" colspan="2">
        Content
    </td>
    <td width="359" colspan="3">
        Content
    </td>
    <td width="151">
        Content
    </td>
</tr>
<tr>
    <td width="24">
        Content
    </td>
    <td width="276">
        Content
    </td>
    <td width="85">
        Content
    </td>
    <td width="198" colspan="2">
        Content
    </td>
    <td width="161">
        Content
    </td>
    <td width="151">
        Content
    </td>
</tr>

I identified the problem in the fact, that none of the table rows defines all of the column-widths.

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?

What would be the best approach to solve such an equations system in Java?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:46:48+00:00Added an answer on June 17, 2026 at 4:46 am

    Assuming that the source table is not over constrained, underconstraint, nor inconsistently constrained, I would recommend:

    • Define a fact table that lists the known width for each column as it is determined
    • Define a collection of Constraint object for each colspan entry that specify the starting column, the column span, and total width.
    • Make a pass through the entire table definition collecting facts and constraints.
    • Then make a pass through the fact table, and for each column that is not defined, run through all of the constraints and see if there is a constraint over a set of columns for which all of the other columns are defined. Such a constraint will produce a value for the currently considered column.
    • Every time a new column value is discovered, you start back at the beginning of the fact table, scan for unknown columns, and for each scan the entire constraint set again.

    This is an n-squared (or worse) algorithm, but should be fine as long as the table does not have ten thousand rows or columns. If the table is correctly constrained you will reach a point where all the column widths are defined. The advantage of a brute-force algorithm such as this is that it is relatively easy to debug and should be stable.

    If the table is under-constrained, you reach a point where you make a pass, and there remain uncalculated column widths. If you want to handle this, you add another pass, and this time take an arbitrary constraint that involves the uncalculated table column, which also must include one or more other uncalculated table columns, and allocate the remaining space equally across all the uncalculated columns in the constraint. Since this is an arbitrary constraint, you may get a different answer on different runs … but the table is under constrained … does it matter?

    When done, you have a complete fact table with all the column widths, and you can then generate your LaTeX code with all table columns specified.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse a html doc using some code I found from this
I am trying to parse a page using YQL. A HTML table is being
I'm using a PHP script to parse a HTML table into an array. But
I am trying to parse a simple html table using beautifulsoup but I have
I'm trying to parse some HTML using the HTML Agility Pack. The following code
I am trying to parse an HTML table using Hpricot but am stuck, not
I am trying to parse an HTML table using lxml. While rows = outhtml.xpath('//tr/td/span[@class=boldred]/text()')
I am trying to use preg_replace function to parse this table in a Html
I am trying to parse html using BeautifulSoup to try and extract the webpage
I'm trying to Parse the following HTML pages using BeautifulSoup (I'm going to parse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.