-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix #3378: latex: Support :widths:
option of table directives
#3379
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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
.
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. |
Merged. Please update macros as you like :-) |
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.
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.
Simplify LaTeX mark-up for table column widths (ref #3379)
refs: #3378