Forum How do I...?

Dealing with very wide tables

jean
Hi there

Any tips on dealing with very wide tables? Is it possible to tell prince to print my table sideways?
mikeday
You can place the table on a landscape page:
@page sideways { size: landscape }
table.big { page: sideways }
...
<table class="big">
this table will be placed on a landscape page
</table>
jean
mikeday wrote:
You can place the table on a landscape page:


Cool! Hmm, the table wraps over multiple pages. Only the first page becomes landscape ..
mikeday
Strange, that is not supposed to happen. Are you able to send me a small sample document demonstrating the problem?
jean
I'm sorry, the problem was between keyboard and chair. The CSS rule was on the table heading, not the table. I fixed that.

Now I'm struggling to keep the section heading on the same page as the table. Here is all the relevant CSS:

h3#physical_disk_details__section {
    page: sideways;
    page-break-before: always;
}

a[name="physical_disk_details__table"] ~ p {
    page: sideways;
    page-break-before: avoid;
    page-break-after: avoid;
}

a[name="physical_disk_details__table"] ~ div.table-contents {
    page: sideways;
    page-break-before: avoid;
    page-break-after: always;
}


And the HTML (no, not ideal; generated by DocBook XSL):

<div class="section" lang="en">
  <div class="titlepage">
    <div>
      <div>
        <h3 class="title" id="physical_disk_details__section">7.2.&nbsp;Physical disk details</h3>
    </div>
  </div>
</div>
<div class="table">
  <a name="physical_disk_details__table"></a>
  <p class="title"><b>Table&nbsp;10.&nbsp;Physical disk details</b></p>
  <div class="table-contents">
    <table summary="Physical disk details" border="1">
mikeday
If this is the heading "Table 10. Physical disk details" then ensure that the <div> and <table> element both have "page-break-before: avoid" and it should be okay. It is possible for intervening elements to interfere, so better to apply it to as many elements as possible until it works. :)