Thanks,

However I need to ask if that works with apache fop ? I am getting some strange 
behaviour, the table is centred but
it shrinks in comparison with the desired size. 

Any ideias ?

Thanks in advance.
Best Regards,

On Mar 26, 2014, at 2:15 PM, [email protected] wrote:

> Here is what I use in my stylesheets.
>  
> Regards
> Dean Nelson
>  
>  
> <!-- center tables in print, from p. 474 in Stayton: --> 
> <xsl:template name="table.layout"> 
>  <xsl:param name="table.content"/> 
>     <xsl:choose>
>      <xsl:when test="self::table[@align = 'center']">
>    <fo:table width="100%" table-layout="fixed"> 
> <!--    <fo:table width="100%" table-layout="fixed" border="solid">  -->
>    <fo:table-column column-width="proportional-column-width(1)"/>
>    <xsl:choose>
>     <xsl:when test="self::table[@width]">
>       <fo:table-column column-width="{@width}"/> 
>       <xsl:message>Table width set to <xsl:value-of 
> select="@width"></xsl:value-of> </xsl:message>
>     </xsl:when>
>     <xsl:otherwise>
>      <fo:table-column/> 
>       <xsl:message>Table width NOT set.</xsl:message>
>     </xsl:otherwise>
>    </xsl:choose>
>    <fo:table-column column-width="proportional-column-width(1)"/> 
>    <fo:table-body  start-indent="0pt"> 
>          <fo:table-row> 
>            <fo:table-cell column-number="2"> 
>              <fo:table> 
>                <fo:table-body start-indent="0pt"> 
>                  <fo:table-row><fo:table-cell><fo:block> 
>                    <xsl:copy-of select="$table.content"/> 
>                  </fo:block></fo:table-cell></fo:table-row> 
>                </fo:table-body> 
>              </fo:table> 
>            </fo:table-cell> 
>             </fo:table-row> 
>      </fo:table-body> 
>     </fo:table> 
>         </xsl:when>
>      <xsl:when test="self::table[@align = 'right']">
>    <fo:table width="100%" table-layout="fixed"> 
>    <fo:table-column column-width="proportional-column-width(1)"/>
>    <fo:table-column column-width="proportional-column-width(1)"/> 
>    <xsl:choose>
>     <xsl:when test="self::table[@width]">
>       <fo:table-column column-width="{@width}"/> 
>       <xsl:message>Table width set to <xsl:value-of 
> select="@width"></xsl:value-of> </xsl:message>
>     </xsl:when>
>     <xsl:otherwise>
>      <fo:table-column/> 
>       <xsl:message>Table width NOT set.</xsl:message>
>     </xsl:otherwise>
>    </xsl:choose>
>    <fo:table-body  start-indent="0pt"> 
>          <fo:table-row> 
>            <fo:table-cell column-number="3"> 
>              <fo:table> 
>                <fo:table-body start-indent="0pt"> 
>                  <fo:table-row><fo:table-cell><fo:block> 
>                    <xsl:copy-of select="$table.content"/> 
>                  </fo:block></fo:table-cell></fo:table-row> 
>                </fo:table-body> 
>              </fo:table> 
>            </fo:table-cell> 
>             </fo:table-row> 
>      </fo:table-body> 
>     </fo:table> 
>         </xsl:when>
>   <xsl:otherwise> 
>    <xsl:copy-of select="$table.content"/> 
>   </xsl:otherwise>
>     </xsl:choose>
> </xsl:template>
>  
>  
>  
> In a message dated 3/26/2014 7:05:43 A.M. Pacific Daylight Time, 
> [email protected] writes:
> 26 mar 2014 kl. 14:09 skrev Rogério Rosa <[email protected]>:
> 
> > Hello,
> > 
> > I am having a hard time to centre a table when the width is less than 100%. 
> > There is any way to centre it?
> > 
> > Thanks in advance.
> > Best Regards,
> 
> Hi!
> 
> I suppose you are talking about PDF output, right? My understanding is that 
> this depends on the FO engine you are using. Both RenderX and FOP need some 
> tweaks whereas AH Formatter has support for center aligned tables out of the 
> box. You should read about table alignment here:
> 
> http://www.sagehill.net/docbookxsl/TableAlignment.html
> 
> Cheers,
> /frank
> 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]

Reply via email to