Table cell centered text issue

Post here questions and problems related to editing and publishing DITA content.
Eric Mui
Posts: 3
Joined: Thu Feb 13, 2025 6:48 am

Table cell centered text issue

Post 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!
Eric Mui
Posts: 3
Joined: Thu Feb 13, 2025 6:48 am

Re: Table cell centered text issue

Post by Eric Mui »

Anyone can help?
This prevents me from centering any Chinese text in table entries.
julien_lacour
Posts: 688
Joined: Wed Oct 16, 2019 3:47 pm

Re: Table cell centered text issue

Post 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
Eric Mui
Posts: 3
Joined: Thu Feb 13, 2025 6:48 am

Re: Table cell centered text issue

Post 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
You do not have the required permissions to view the files attached to this post.
julien_lacour
Posts: 688
Joined: Wed Oct 16, 2019 3:47 pm

Re: Table cell centered text issue

Post 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
Post Reply