Donate to Remove ads

Got a credit card? use our Credit Card & Finance Calculators

Thanks to johnstevens77,Bhoddhisatva,scotia,Anonymous,Cornytiv34, for Donating to support the site

Formatting tables nicely

Formerly "Lemon Fool - Improve the Recipe" repurposed as Room 102 (see above).
Gengulphus
Lemon Quarter
Posts: 4255
Joined: November 4th, 2016, 1:17 am
Been thanked: 2628 times

Formatting tables nicely

#178897

Postby Gengulphus » November 8th, 2018, 2:58 am

From viewtopic.php?f=93&t=14635:

TheMotorcycleBoy wrote:
...
PS does anyone know how I can make my tables look more sane, i.e. not pad the first column with w/s and instead left justify all my columns?

A few notes about what follows:

  • On Windows, non-breaking spaces are available from the 'Character Map' tool: if you bring it up (and provided the tool hasn't been changed in your version!) they're available from the fifth line of the character display, just after the "{ | } ~" sequence. For other OSes, I'm afraid I'll have to leave you to find them for yourself!
  • To see what I've done rather than just its effects, start a quoted reply to this post by clicking its " button, then study the source within the quote tabs. And I'm afraid even looking at it carefully won't tell you which spaces in it are non-breaking ones - you'll need to infer that from where the long strings of spaces occur...
  • Experimenting with widening and narrowing the window you're displaying this post in will be needed to actually see what I'm talking about at some points. And as a result, it may well not be possible to see it well at all on narrow screens, e.g. mobiles - sorry, but there's only so much that can be done to work around the limitations they impose.
  • I'm not saying that all tables are worth putting the amount of effort in what follows into them! I can tell you about the techniques, but you'll have to judge whether to use them for yourself...
  • Do not expect perfection - these are work-arounds to get the best out of a fairly simplistic table-generation tool, not a full solution to its problems.
  • That last point is not an attack on TLF's table-generation facilities or on stooz's development of them, nor an assertion that they need more work done on them. They're an excellent "90% of the desired effect for 10% of the effort that a full 100% of it would take" type solution - and I'm not certain the figures shouldn't be 99% and 1% instead!

You can put in an extra column (or more than one) to the right, which it looks as though you might have attempted but using a column of ordinary spaces. That doesn't work, because the software seems to strip out the spaces as unnecessary white space, then regard the column that now contains nothing at all as being zero-width, which remains zero-width no matter what percentage it is expanded by... Instead, make a column of a suitable number of non-breaking spaces, which aren't regarded as white space, like this:

Original:

With an added column of 80 non-breaking spaces:

Note that you only need one entry in the column to contain the non-breaking spaces - I used the header row entry in that example.

Also note that that won't display very nicely on narrow screens/windows, as the software will insist on the extra column being there, and will break other rows across multiple lines if necessary to achieve that. You can prevent that happening by making some suitable entry in the columns being broken unbreakable, by using non-breaking spaces instead of ordinary spaces, not using breakable punctuation and padding with extra non-breaking spaces if needed. In your case, the header entry in the first column is suitable:


There is still the problem with all of these techniques that you cannot make the table narrower than the post it is in - all you can do is banish the white space to its right hand side. Also, by insisting on columns being at least a certain width with non-breaking spaces, you impose a minimum width on the entire table, which the software will deal with if necessary for a narrow screen/window by making the post sideways-scrollable. People won't need to scroll sideways and won't find anything there if they try, but won't know that until they do try! In short, no solution is perfect - one just has to put however much effort one reckons is justified into getting the table displaying reasonably nicely despite the imperfections. (Personally, I generally don't bother, but with tables I'm going to post again and again such as those in viewtopic.php?f=15&t=13383 I'll put quite a bit of effort into making the underlying spreadsheet automatically generate the table source. By now, generating a new version of those tables requires nothing more than updating prices, forecast yields and a few other figures, then copying a "table source" cell in the spreadsheet and pasting it into my post...)

You can use the [align] tab to make columns left-, right- or center-aligned as you prefer. For instance, I generally like columns of monetary amounts to be right-aligned, so that digits of equal significance line up, and I can get that:


One particular problem that occurs with that is that if you have a right-aligned column followed by a left-aligned column, the software generates no gap between them. That, and other problems due to columns running into each other, can be solved with an extra column of one or two non-breaking spaces between them.

Gengulphus

TheMotorcycleBoy
Lemon Quarter
Posts: 3245
Joined: March 7th, 2018, 8:14 pm
Has thanked: 2222 times
Been thanked: 587 times

Re: Formatting tables nicely

#178906

Postby TheMotorcycleBoy » November 8th, 2018, 6:19 am

Gengulphus wrote:From viewtopic.php?f=93&t=14635:

I've not got the time right now to read up on this, but I had to reply briefly to say many thanks for taking the time to do this Geng.

I did brief skim over your writings, though Geng, well enough to read the hint about the false column with 80 spaces - and only needing to do this once.

So rest assured this thread is getting bookmarked for me to look at when I get a free moment today!

Matt

tjh290633
Lemon Half
Posts: 8208
Joined: November 4th, 2016, 11:20 am
Has thanked: 913 times
Been thanked: 4096 times

Re: Formatting tables nicely

#178929

Postby tjh290633 » November 8th, 2018, 9:06 am

A further comment on your problem with [ pre]..[/ pre], I suspect that you are trying to construct your table as you are writing. If you have it in a spreadsheet, just copy it into the text box. The columns will align without your intervention. The only problem is a blank column in the header row, where a full stop in the first cell in the row cures that. HTML ignores extra spaces, which is why Gengulphus's hard spaces are needed.

The alternative is to compose your table as a text file in Notepad, which you should be able to paste in directly between the [ pre]and[/ pre] tags.

TJH

TheMotorcycleBoy
Lemon Quarter
Posts: 3245
Joined: March 7th, 2018, 8:14 pm
Has thanked: 2222 times
Been thanked: 587 times

Re: Formatting tables nicely

#178984

Postby TheMotorcycleBoy » November 8th, 2018, 12:51 pm

tjh290633 wrote:A further comment on your problem with [ pre]..[/ pre], I suspect that you are trying to construct your table as you are writing. If you have it in a spreadsheet, just copy it into the text box. The columns will align without your intervention. The only problem is a blank column in the header row, where a full stop in the first cell in the row cures that.

Thanks, TJH

I must admit that sometimes my copy and pastes from the spreadsheet, will *just work*, e.g. if each column contains strings of a short and similar length.

But it's when (in particular the first column) from my spreadsheet, has strings of varying lengths, e.g. "EBIT" and "Impairment of Property, plant and equipment", (and like to keep things in my spreadsheets very descriptive - in addition to them often being lifted straight from published .pdfs), that I think I end up spacing stuff out when using the [ pre] way. But I've not really spent that much time analysing this as yet...

thanks anyway
Matt

TheMotorcycleBoy
Lemon Quarter
Posts: 3245
Joined: March 7th, 2018, 8:14 pm
Has thanked: 2222 times
Been thanked: 587 times

Re: Formatting tables nicely

#178989

Postby TheMotorcycleBoy » November 8th, 2018, 1:19 pm

I've been having a quick play with the non breaking space idea (at work lunch hour, so can't be particularly adventurous). I use linux (home and for work) and so the good ol' windows character map (which I know of old) is not on my linux box......so I'll have to google for an open source equivalent later on. So I can't go much further with NBSP idea currently.

I did manage to follow TJHs link to the spreadsheet raw copy to [ pre], [ code], [ table], the [ pre] option right out of the box, was reasonably acceptable:

Income Statement           |       | Balance Sheet           |      
Revenue | 0.00 | Non current assets |
Gross Profit | 0.00 | Goodwill | 0.00
Operating Profit (EBIT) | 0.00 | Other intangibles | 0.00
Finance expense (interest) | 0.00 | Deferred tax | 0.00
Finance income (interest) | 0.00 | Property,equipment etc. | 0.00
Interest adjustment | 0.00 | Receivables | 0.00
PBT profit before tax | 0.00 | Investments | 0.00
PAT “profit for the year” | 0.00 | Miscellaneous | 0.00
Minority interest payouts | 0.00 | Pension surplus | 0.00


Alas no linux charmap, and no fooling TLF parser!


back to the day job,
Matt

TheMotorcycleBoy
Lemon Quarter
Posts: 3245
Joined: March 7th, 2018, 8:14 pm
Has thanked: 2222 times
Been thanked: 587 times

Re: Formatting tables nicely

#179385

Postby TheMotorcycleBoy » November 10th, 2018, 4:10 pm

Just copying TJH's post to earlier analysis thread with the link to TLF spreadsheet to lemon pre/table/code tool:

"My method with tables is to have the details in a spreadsheet, then just copy into a [pre] format box in the Lemon Fool Financial Software tool, found at http://lemonfoolfinancialsoftware.weebl ... ormat.html

I replace the column separator with three spaces, and put a full stop in any empty cells in the header row.

Numbers are usually right justified and text left justified.

TJH"

Just to keep it near to a tables thread.


Return to “Room 102 - Site Issues, Complaints & General Chat”

Who is online

Users browsing this forum: No registered users and 8 guests