Page 1 of 1
Table cell centered text issue
Posted: Fri Jun 27, 2025 12:26 pm
by Eric Mui
I'm trying to center text in tbody cells. So I added <xsl:attribute name="text-align"></xsl:attribute> to the attribute set "tbody.row.entry__content" in tables-attr.xsl.
I'm writing in Chinese. If the text in a table cell is longer for one line to hold, it will be in two lines. The thing is, the second line will always be a bit to the right than the first line, such as:
测试测试测试
(two spaces here)测试测试测试
If the text is generated into multiple lines, only the last line is a bit to the right compared to other lines, such as:
测试测试测试
测试测试测试
测试测试测试
(two spaces here)测试测试测试
Can anyone help? Thank!
Re: Table cell centered text issue
Posted: Thu Jul 24, 2025 10:28 am
by Eric Mui
Anyone can help?
This prevents me from centering any Chinese text in table entries.
Re: Table cell centered text issue
Posted: Mon Jul 28, 2025 10:51 am
by julien_lacour
Hello,
I guess you're using the DITA Map PDF - based on XSL-FO scenario. Why not using directly DITA @align attribute inside the table?
Code: Select all
<table id="table_ibs_ncc_dgc" frame="all">
<tgroup cols="3">
<colspec colnum="1" colname="c1" colwidth="1*" align="center" colsep="1" rowsep="1"/>
<colspec colnum="2" colname="c2" colwidth="1*" align="center" colsep="1" rowsep="1"/>
<colspec colnum="3" colname="c3" colwidth="1*" align="center" colsep="1" rowsep="1"/>
<tbody>
<row>
<entry>测试测试测试 测试测试测试</entry>
<entry>测试测试测试 测试测试测试</entry>
<entry>测试测试测试 测试测试测试</entry>
</row>
<row>
<entry>测试测试测试 测试测试测试 测试测试测试 测试测试测试</entry>
<entry>测试测试测试 测试测试测试 测试测试测试 测试测试测试</entry>
<entry>测试测试测试 测试测试测试 测试测试测试 测试测试测试</entry>
</row>
</tbody>
</tgroup>
</table>
Regards,
Julien
Re: Table cell centered text issue
Posted: Tue Jul 29, 2025 5:14 am
by Eric Mui
julien_lacour wrote: ↑Mon Jul 28, 2025 10:51 am
Hello,
I guess you're using the DITA Map PDF - based on XSL-FO scenario. Why not using directly DITA @align attribute inside the table?
Code: Select all
<table id="table_ibs_ncc_dgc" frame="all">
<tgroup cols="3">
<colspec colnum="1" colname="c1" colwidth="1*" align="center" colsep="1" rowsep="1"/>
<colspec colnum="2" colname="c2" colwidth="1*" align="center" colsep="1" rowsep="1"/>
<colspec colnum="3" colname="c3" colwidth="1*" align="center" colsep="1" rowsep="1"/>
<tbody>
<row>
<entry>测试测试测试 测试测试测试</entry>
<entry>测试测试测试 测试测试测试</entry>
<entry>测试测试测试 测试测试测试</entry>
</row>
<row>
<entry>测试测试测试 测试测试测试 测试测试测试 测试测试测试</entry>
<entry>测试测试测试 测试测试测试 测试测试测试 测试测试测试</entry>
<entry>测试测试测试 测试测试测试 测试测试测试 测试测试测试</entry>
</row>
</tbody>
</tgroup>
</table>
Regards,
Julien
Hi Julien, thanks for your reply.
Yes. I am using xsl-fo. The issue is that no matter what you want to align, you need to set text-align attribute of the the entry content to center. If I do that, and the entry contains a continuous text that is broken into multiple lines due to not enough space, the last line will not be correctly aligned. Please see my example below:
In oxygen:
in-oxygen.jpeg
In PDF:
in-pdf.jpeg
Regards,
Eric
Re: Table cell centered text issue
Posted: Tue Jul 29, 2025 9:58 am
by julien_lacour
Hi Eric,
It is not necessary to use the text-align attribute on table cells.
You just need to use the @align attribute: either on <colspec> elements or directly on <entry> elements.
If you replace the outputclass by align, you will get the correct output.
Regards,
Julien
Re: Table cell centered text issue
Posted: Thu Aug 07, 2025 12:48 pm
by Eric Mui
Hi Julien,
Thanks for your reply.
I tried your recommendation. I used the align attribute on either the colspec or entry, but nothing happens. I checked the stylesheet. You still need to set the text-align attribute, such as below, right? The below also came with the same issue.
<xsl:template match="*" mode="processTableEntry">
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="applySpansAttrs"/>
<xsl:call-template name="applyAlignAttrs"/>
<xsl:call-template name="generateTableEntryBorder"/>
<xsl:choose>
<xsl:when test="@rotate eq '1'">
<xsl:apply-templates select="." mode="rotateTableEntryContent"/>
</xsl:when>
<xsl:otherwise>
<fo:block xsl:use-attribute-sets="tbody.row.entry__content">
<xsl:attribute name="text-align" select="@align"/>
<xsl:call-template name="processEntryContent"/>
</fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Re: Table cell centered text issue
Posted: Mon Aug 11, 2025 10:53 am
by julien_lacour
Hello,
I've tested the table @align behavior using DITA Map PDF - based on XSL-FO on the following Oxygen's versions:
- <oXygen/> XML Editor 25.1, build 2023110913
- <oXygen/> XML Editor 26.1, build 2024091606
- <oXygen/> XML Editor 27.1, build 2025063013
Each time the correct output is generated
only using the attribute in the DITA Topic. No additional XSLT processing is needed.
Have you tried with the default scenario? Does it work?
Could you indicate which version of Oxygen you are running?
Are you using custom DITA-OT plugins or are you running Oxygen's default publishing engine?
Regards,
Julien
Re: Table cell centered text issue
Posted: Wed Aug 13, 2025 12:36 pm
by Eric Mui
Hi,
I used the default pdf2 plugin and managed to center a column by setting the align attribute. But the issue remained. Please see the example below.
20250813-173508.jpeg
Re: Table cell centered text issue
Posted: Thu Aug 14, 2025 11:18 am
by julien_lacour
Hi,
I don’t see an issue here: when using center alignment, the algorithm aims to balance the content as best as it can, which may result in lines of varying widths. It seems you’re actually looking to justify the text. Unfortunately, Apache FOP doesn’t currently support align="justify", so if you set this value in the DITA topics, the text will still be left-aligned.
Regards,
Julien
Re: Table cell centered text issue
Posted: Tue Aug 19, 2025 5:50 am
by Eric Mui
Hi Julien,
What I want is that the text should be taking all available space on first line before moving on to the next. Now I know this is an issue with Apache FOP. Because when I publish with Antenna House, everything is exactly what I want.
Thanks for your patient reply!
