Re: [xsl] FO: center a table

Subject: Re: [xsl] FO: center a table
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Dec 2005 10:31:15 -0500
Sorry, I responded to the response but not the original post, so I didn't see that the original poster already had a test example.

At 2005-12-27 11:21 +0100, Florent Georges wrote:
  I can't figure out how to make this simple task: I have a fo:table in
a fo:flow, and I have to center the table horizontally in the flow.
Something like the following, but with centering the table:

The following change to your example works just fine. I added a table-and-caption to centre the table, then I added a text-align="start" to start-align the table contents, and I turned on the border to see that it was, indeed, in the centre of the line.


I hope this helps.

. . . . . . . . . . Ken

<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
  <fo:layout-master-set>
    <fo:simple-page-master master-name="master"
                           page-height="845pt"
                           page-width="598pt">
      <fo:region-body margin-left="50pt"
                      margin-top="50pt"
                      margin-bottom="50pt"
                      margin-right="50pt"/>
    </fo:simple-page-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="master">
    <fo:flow flow-name="xsl-region-body">
      <fo:table-and-caption text-align="center">
        <fo:table width="100pt" table-layout="fixed" text-align="start"
                  border="solid 1pt">
          <fo:table-column column-width="100pt"/>
          <fo:table-body>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>foo</fo:block>
              </fo:table-cell>
            </fo:table-row>
          </fo:table-body>
        </fo:table>
      </fo:table-and-caption>
    </fo:flow>
  </fo:page-sequence>
</fo:root>


-- Upcoming XSLT/XSL-FO hands-on courses: Denver,CO March 13-17,2006 World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread