Skip to content

refactor latex table templates to avoid extra vertical space (refs #3405) - #3415

Merged
jfbu merged 2 commits into
sphinx-doc:masterfrom
jfbu:on3405refactortemplates
Feb 11, 2017
Merged

jfbu merged 2 commits into
sphinx-doc:masterfrom
jfbu:on3405refactortemplates

Conversation

@jfbu

@jfbu jfbu commented Feb 11, 2017

Copy link
Copy Markdown
Contributor
  • The center, flushleft, flushright environments added at #3377: support :align: option for tables #3405 add extra vertical spaces in PDF output compared to earlier situation. This PR removes them.

  • The tabular and tabulary templates are also modified in order for produced LaTeX code to have start of environments at start of new line, for better readability

  • By default, the table will be horizontally centered. This is already the default behaviour of longtable. Before incorporation of :align: option, default for short tables not using longtable was flushleft and one could not change it. Now default is like longtable centered.

Relates

…phinx-doc#3405)

also, make "center" the default for short table horizontal alignment (it
is already so for longtable)
@jfbu jfbu added this to the 1.6 milestone Feb 11, 2017

@tk0miya tk0miya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with nits. Please update if you'll agree with my comments.
Anyway please go ahead!

Comment thread tests/test_build_latex.py Outdated
# simple_table
table = tables['simple table']
assert ('\\noindent\\begin{tabulary}{\\linewidth}{|L|L|}' in table)
assert ('\\begin{tabulary}{\\linewidth}{|L|L|}' in table)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should always check \\begingroup\n\\centering\n\\begin{tabulary}... here.
It is a part of start tag of both tabular and tabulrary.

Comment thread tests/test_build_latex.py Outdated
table = tables['table having :widths: option']
assert ('\\noindent\\begin{tabular}{|\\X{30}{100}|\\X{70}{100}|}' in table)
assert ('\\begin{tabular}{|\\X{30}{100}|\\X{70}{100}|}' in table)
assert ('\\hline\n\\end{tabular}' in table)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And, we should also check \\end{tabular}\n\\par\n\\endgroup here.

@jfbu

jfbu commented Feb 11, 2017

Copy link
Copy Markdown
Contributor Author

@tk0miya thanks for review ! tests updated. I updated CHANGES, and needed to mention there that there is no text flow around table currently. Because of that I am not sure :align: option is that useful, as in 90% of cases I expect best layout is to use centering. At any rate this PR removes the discrepancy between tables rendered with longtable which always centered and the short ones which always flushed left. Now, by default, all tables are centered horizontally.

@tk0miya

tk0miya commented Feb 11, 2017

Copy link
Copy Markdown
Member

Agreed. +1 for the default alignment of non-longtables.

@jfbu
jfbu merged commit 1c38710 into sphinx-doc:master Feb 11, 2017
@jfbu

jfbu commented Feb 11, 2017 •

Copy link
Copy Markdown
Contributor Author

(I rebased and merged at 1c38710; thanks again!)

@jfbu
jfbu deleted the on3405refactortemplates branch March 10, 2017 13:17
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 15, 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