Setting table width and column width with Table Stylesheet

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
stephgl
Propeller Head
Posts: 94
Joined: Wed Jan 17, 2007 11:22 am
Location: Greater Sacramento Area

Setting table width and column width with Table Stylesheet

Post by stephgl »

I'm making a new project with many dozens of tables. I am making one-row tables in snippets, since I will need to display rows individually in some places, and in various-order groups in other places.

I am trying to use the TableStyles stylesheets to manage the formatting of these tables. I need each table's overall width to be the same, and each column number the same width from table to table (but not equal column widths within a table.)

I see in the TableStyles editor's Columns dialog I can set the width of each column as a percentage - this is great. But how do I set the overall width of the table using the TableStyles editor? I don't see a table width setting anywhere.

Thanks,
-Steph
-stephgl
stephgl
Propeller Head
Posts: 94
Joined: Wed Jan 17, 2007 11:22 am
Location: Greater Sacramento Area

Re: Setting table width and column width with Table Stylesheet

Post by stephgl »

I see I need to clarify that I'd like the overall table width to be 100% of what's available, with each column a defined% of what's left. Actually I'm not sure this is possible. Would I need to have at least the first column a fixed width?
-stephgl
cbdebris
Sr. Propeller Head
Posts: 105
Joined: Wed Aug 15, 2007 4:15 pm
Location: California

Re: Setting table width and column width with Table Stylesheet

Post by cbdebris »

We set a max-width property for our tables. This is in our general stylesheet. With the new modal tablestyles we still do that, because it's the only way we can get a consistency on table size.
All life is a blur of Republicans and meat. -- Zippy the Pinhead
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Setting table width and column width with Table Stylesheet

Post by LTinker68 »

You can set an overall width on a table, or set a width on every cell, or set a width on the overall table and some of the cells, but not all! Setting the width on the overall table and every column will cause problems, although that's more an HTML thing than a Flare thing.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
stephgl
Propeller Head
Posts: 94
Joined: Wed Jan 17, 2007 11:22 am
Location: Greater Sacramento Area

Re: Setting table width and column width with Table Stylesheet

Post by stephgl »

LTinker68 wrote:You can set an overall width on a table, or set a width on every cell....
Thanks everyone!

Lisa, so it would be "legal" to set each column as a percentage? And then, have no table width property? I see there is no way to set the table width property in the table stylesheet editor. However, I don't know how a table stylesheet interacts with the table styles in the master stylesheet (I use those at the project level). Is there an article about that some place, that I've missed?


Hmm, I think there's something fishy about the tables I've created from a massive Word import. I'm having better luck with tables I built in the Flare editor. I don't want to recreate all these tables by hand though, I'll see what I can strip from the files in batches with UltraEdit.
-stephgl
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Setting table width and column width with Table Stylesheet

Post by LTinker68 »

stephgl wrote:Lisa, so it would be "legal" to set each column as a percentage? And then, have no table width property? I see there is no way to set the table width property in the table stylesheet editor. However, I don't know how a table stylesheet interacts with the table styles in the master stylesheet (I use those at the project level). Is there an article about that some place, that I've missed?
It's not so much a "legal" issue in regards to CSS or HTML that I'm aware of -- it's more observed behavior. And it may not be an issue anymore with browsers -- they might automatically adjust for the problem by ignoring the table width if all of the columns have widths (since the columns are closer to the content, that makes sense). I don't think you set the table width via the table stylesheet -- you can either specify it inline at the time you insert the table (via the Table Properties screen) or you have the width set via the main topic stylesheet. As for how the table stylesheet interacts with the master topic stylesheet, it follows CSS rules. When you build the output, the table stylesheet is referenced after the topic stylesheet in the topic, so the table stylesheet will inherit its attribute values from the topic stylesheet unless the same attribute has a different value in the table stylesheet, in which case the table stylesheet's values are used. If the attribute isn't defined in the table stylesheet and it isn't defined in the topic stylesheet, then it will use the values specified in the MadCap.css stylesheet, which is referenced first in the compiled topic, but which you can't edit directly (Flare creates it at build time). If the attribute isn't defined in that stylesheet either, then the attribute will use the default value specified in the browser you're using to view the output (and therefore, might be a different value than is used in another browser). I'm not sure what the print outputs use as the values in that case -- probably whatever the CSS standard has specified, or maybe the default values in Internet Explorer.

stephgl wrote:Hmm, I think there's something fishy about the tables I've created from a massive Word import. I'm having better luck with tables I built in the Flare editor. I don't want to recreate all these tables by hand though, I'll see what I can strip from the files in batches with UltraEdit.
Yeah, you most likely have a slew of inline styles in those tables. Strip out what you can after importing to Flare, or copy-and-paste the table from Word into Flare -- that might strip more Word-specific styles out.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
stephgl
Propeller Head
Posts: 94
Joined: Wed Jan 17, 2007 11:22 am
Location: Greater Sacramento Area

Re: Setting table width and column width with Table Stylesheet

Post by stephgl »

Thanks for the detailed reply, Lisa, your posts are always very helpful to me. I've got a better picture of the three-stylesheet structure now.

Haven't retackled those imported tables yet.
-stephgl
clxmichelle
Propeller Head
Posts: 10
Joined: Thu Jun 07, 2012 12:59 pm

Re: Setting table width and column width with Table Stylesheet

Post by clxmichelle »

So I had been having a tricky time getting column widths to sort they way I wanted, and the auto option just kept putting space in all the wrong places. I finally stumbled on the following to get some control over how it spreads out:

Code: Select all

   ...
            <table max-width="95%" class="mrgnThnGryBrdrLOfixed">
            <caption class="tableCaptionRepeat">Table: Property Links</caption>
            <col style="width:30%" />
            <col style="width:65%" />
            <tbody>
                <tr>
            ...
It solves for my PDF output, and doesn't seem to break in HTML5 (but that part's not fully tested). The fix seemed to be making the col widths add up to the table max-width value. I tried leaving one col width blank as Lisa suggested, but still got space where I really didn't want it. I'd give a screen shot, but I don't see a way to paste in the bulletin board.

Hopefully I am not setting up some down-the-road bummer, but so far it's been working.
~michelle
kel322
Propeller Head
Posts: 34
Joined: Tue Jan 03, 2017 12:56 pm

Re: Setting table width and column width with Table Styleshe

Post by kel322 »

This still seems to be a problem in Flare.

I've been working on a style guide where 20+ topics use a table. Aside from the <td> cell content, the table is the same in all of the topics. When I build my print output (PDF), I cannot get consistent column sizes. I have tried just about everything I can think of, and I have tried everything suggested on these forums.

I tried using the table stylesheet, which didn't work. Then I got rid of the table stylesheet and used just the project stylesheet, adding CSS classes to define the width of the table, the columns, the th, and the td (all in different, various combinations), which didn't work. I've tried using just inline styles, which didn't work. I've tried defining rules for hyphenation, widows, and orphans; these were ignored. I've tested using different forms of measurement (pixels, inches, percentages, etc.). Nothing works!

The width of the table columns seem to be sized based on cell content even if the code is telling them not to.

I could possibly live without being driven crazy if the column widths weren't the same on each page, BUT on some of the pages the <th> gets pushed to the next line, creating ridiculous breaks (even if it shouldn't). See image below (the blue lines are just rule lines form the PDF to better show the difference in column sizes.
dictionary.png
Has anyone figured out anything about making tables look consistent in print output in Flare? It's ridiculous to have the column sizes change on each topic.

On a positive note, everything looks great in the online output.
You do not have the required permissions to view the files attached to this post.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Setting table width and column width with Table Styleshe

Post by ChoccieMuffin »

I can't add anything useful to this topic other than sympathising with your pain.

I HATE tables in Flare! What's so difficult about allowing a user creating a PDF to set the width of a column in the project stylesheet, eh?
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
ClanMoffat
Jr. Propeller Head
Posts: 9
Joined: Thu Jun 22, 2023 2:34 am

Re: Setting table width and column width with Table Stylesheet

Post by ClanMoffat »

If you are defining the tables as Flare Table Styles, then you can add the column width % in the definitions...
I have set the table width as 100% and added column width % values for ALL columns, and the output looks good in PDF and on-screen...

This seems to look pretty good, though not all columns are the same width - that depends on the contents of the tables! :shock:

Problems have risen with a late project request to add in MS Word output as well as PDF! :(
This has caused problems with table widths, especially with tables in 1st- or 2nd-level lists, so I've added a fixed-width variable. for example:
    <ul> <li> <table style="width: var(--TableWidth-1stListItem-Word)...

    ~It would be nice to add in a CSS solution there instead of "heard-coding" that solution for Print output tasks! :)

    PDF column widths look sensible, whereas Word column widths look horrible, and seem not to use the % values as guidance! :(

    Good luck!
    Post Reply