Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3378: latex: Support :widths: option of table directives #3379

Merged
merged 1 commit into from
Feb 1, 2017

Conversation

tk0miya
Copy link
Member

@tk0miya tk0miya commented Feb 1, 2017

refs: #3378

@tk0miya tk0miya requested a review from jfbu February 1, 2017 05:26
@tk0miya tk0miya assigned tk0miya and unassigned tk0miya Feb 1, 2017
@tk0miya tk0miya added this to the 1.6 milestone Feb 1, 2017
Copy link
Contributor

@jfbu jfbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in my testing !

Later I will think about adding the \newcolumntype thing for more abbreviated mark-up.

elif self.table.colwidths:
total = sum(self.table.colwidths)
colspec = ['p{\\dimexpr(\\linewidth-\\arrayrulewidth)*%d/%d'
'-2\\tabcolsep-\\arrayrulewidth\\relax}' % (width, total)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to do something like

\newcolumntype{X}[2]{p{\dimexpr(\linewidth-\arrayrulewidth)*#1/#2-2\tabcolsep-\arrayrulewidth\relax}}

in sphinx.sty and then generate mark-up by writer like

|X{50}{70}|X{20}{70}|

for smaller files. I must check which letter is best available for this (i.e. not used by packages user may add to default config).

Fortunately \dimexpr handles <dimen>*A/B in double precision for the first multiplication so that even with things like 500/1000 there will be no overflow, despite the maximal dimension in TeX being only about 5.76 m.

@jfbu
Copy link
Contributor

jfbu commented Feb 1, 2017

I forgot to mention i my review that it would be desirable in future in case columns are narrow not to automatically widen to the full available width, as it seems HTML behaves this way. But this does not look like easy problem in LaTeX without dedicated package. Will check tabulary documentation.

@tk0miya tk0miya merged commit 396c312 into sphinx-doc:master Feb 1, 2017
@tk0miya tk0miya deleted the 3378_support_widths_in_latex branch February 1, 2017 15:00
@tk0miya
Copy link
Member Author

tk0miya commented Feb 1, 2017

Merged. Please update macros as you like :-)

jfbu added a commit to jfbu/sphinx that referenced this pull request Feb 1, 2017
The ``\X`` token is used as column-specifier: this does not define or
redefine ``\X`` as a LaTeX macro. Using a letter could have led to
conflict with user extra packages or macro definitions. This column
specifier takes two arguments which must be positive integers, as
produced by LaTeX writer for ``:widths:`` option or for equal widths
columns. As it always uses ``\linewidth`` the latter was not abstracted
into a third argument.
jfbu added a commit to jfbu/sphinx that referenced this pull request Feb 1, 2017
The ``\X`` token is used as column-specifier: this does not define or
redefine ``\X`` as a LaTeX macro. Using a letter could have led to
conflict with user defined column types or table packages. This column
specifier takes two arguments which must be positive integers, as
produced by LaTeX writer for ``:widths:`` option or for equal widths
columns. As it always uses ``\linewidth`` the latter was not abstracted
into a third argument.
jfbu added a commit that referenced this pull request Feb 4, 2017
Simplify LaTeX mark-up for table column widths (ref #3379)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants