Hi,

This code skips LaTeX builder via this if-block. Please remove this to
align tables on LaTaX builder.
```
        if self.app.builder.name != 'latex':
            return
```

Thanks,
Takeshi KOMIYA

2019年5月28日(火) 22:30 Sebastian Huber <[email protected]>:
>
>
>
> Am Donnerstag, 11. Januar 2018 17:52:26 UTC+1 schrieb Komiya Takeshi:
>>
>> Hi,
>>
>> Personally, I prefer to use an extension for this case.
>> I believe the following code help you. You can use this code with appending
>> them to your conf.py.
>>
>> ```
>> from docutils import nodes
>> from sphinx.transforms import SphinxTransform
>>
>>
>> class AdjustTableAlign(SphinxTransform):
>>     default_priority = 500
>>
>>     def apply(self):
>>         if self.app.builder.name != 'latex':
>>             return
>>
>>         for node in self.document.traverse(nodes.table):
>>             node.attributes.setdefault('align', 'left')
>>
>>
>> def setup(app):
>>     app.add_post_transform(AdjustTableAlign)
>> ```
>>
>> I know the python code is a bit harder to understand and to maintain it.
>> But this does not touch the LaTeX macros directly, so this way is a
>> bit robuster than
>> writing LaTeX macros.
>
>
> I tried this extension code to align all table cell content to the left by 
> default. It seems to have no effect, the table cells are still center 
> aligned. I added a "print(node)" before the 
> "node.attributes.setdefault('align', 'left') " and see lots of output, so the 
> extension seems to do something.
>
> ```
>
> .. list-table:: Traceability from Item to Item in ECSS-E-ST-40C
>     :widths: 16, 20, 18, 18, 8, 20
>     :header-rows: 1
>     :class: longtable
>
>     * - Reference
>       - Subject
>       - Source
>       - Destination
>       - Y/N
>       - Solution
>     * - 5.7.3.5.a
>       - Evaluation of acceptance testing
>       - acceptance tests
>       - requirements baseline
>       - N
>       - ?
> ```
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sphinx-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sphinx-users/80367e75-3ef2-48f0-81cc-69d65290a84f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/CAFmkQAPP%3DOaytnue43phzC_TKmNoFfP-dFmDMy2s0se4U6bxUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to