-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: add environment
, e.g. "longtable", to Styler.to_latex
#41866
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
cacb041
add latex environment variable and longtable template
attack68 a4f75ab
add latex environment variable and longtable template
attack68 1962c58
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 24d0e9c
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 084b2f6
longtable with captions
attack68 3a054c3
add tests for longtable
attack68 bcf1168
add tests for longtable
attack68 2529b1d
mypy fix
attack68 c6e608b
test fix
attack68 bd7c5f8
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 dbe4154
improve docs, and whats new
attack68 b412a12
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 ea7f956
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 38fa8c4
Merge branch 'rls1.3.0' into longtable_to_latex
attack68 cf70df1
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 7ad8802
merge into master and add extra needed tests
attack68 ab7e6f1
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 e2ea44a
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 ec6ebc4
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 06962c6
parametrize multindex columns (ivan request)
attack68 8e3ff5b
parametrize caption label (ivan request)
attack68 67ffe24
more readable (ivan request)
attack68 903923b
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 17e090f
ivan requests
attack68 4ada8ba
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 78159fe
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 8164c2e
imporve tests (ivan request)
attack68 9d4972c
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 175e1e3
ValueError on position_float tests (simon request)
attack68 8081971
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 42151ac
whatsnew 1.4.0
attack68 2311db2
whatsnew 1.4.0
attack68 3da4ed7
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 4cd8263
add to doc packages
attack68 3b7427d
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 3c5a2e9
Merge remote-tracking branch 'upstream/master' into longtable_to_latex
attack68 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,5 @@ | ||
{% if parse_wrap(table_styles, caption) %} | ||
\begin{table} | ||
{%- set position = parse_table(table_styles, 'position') %} | ||
{%- if position is not none %} | ||
[{{position}}] | ||
{%- endif %} | ||
|
||
{% set position_float = parse_table(table_styles, 'position_float') %} | ||
{% if position_float is not none%} | ||
\{{position_float}} | ||
{% endif %} | ||
{% if caption and caption is string %} | ||
\caption{% raw %}{{% endraw %}{{caption}}{% raw %}}{% endraw %} | ||
|
||
{% elif caption and caption is sequence %} | ||
\caption[{{caption[1]}}]{% raw %}{{% endraw %}{{caption[0]}}{% raw %}}{% endraw %} | ||
|
||
{% endif %} | ||
{% for style in table_styles %} | ||
{% if style['selector'] not in ['position', 'position_float', 'caption', 'toprule', 'midrule', 'bottomrule', 'column_format'] %} | ||
\{{style['selector']}}{{parse_table(table_styles, style['selector'])}} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
\begin{tabular} | ||
{%- set column_format = parse_table(table_styles, 'column_format') %} | ||
{% raw %}{{% endraw %}{{column_format}}{% raw %}}{% endraw %} | ||
|
||
{% set toprule = parse_table(table_styles, 'toprule') %} | ||
{% if toprule is not none %} | ||
\{{toprule}} | ||
{% endif %} | ||
{% for row in head %} | ||
{% for c in row %}{%- if not loop.first %} & {% endif %}{{parse_header(c, multirow_align, multicol_align, True)}}{% endfor %} \\ | ||
{% endfor %} | ||
{% set midrule = parse_table(table_styles, 'midrule') %} | ||
{% if midrule is not none %} | ||
\{{midrule}} | ||
{% endif %} | ||
{% for row in body %} | ||
{% for c in row %}{% if not loop.first %} & {% endif %} | ||
{%- if c.type == 'th' %}{{parse_header(c, multirow_align, multicol_align)}}{% else %}{{parse_cell(c.cellstyle, c.display_value)}}{% endif %} | ||
{%- endfor %} \\ | ||
{% endfor %} | ||
{% set bottomrule = parse_table(table_styles, 'bottomrule') %} | ||
{% if bottomrule is not none %} | ||
\{{bottomrule}} | ||
{% endif %} | ||
\end{tabular} | ||
{% if parse_wrap(table_styles, caption) %} | ||
\end{table} | ||
{% if environment == "longtable" %} | ||
{% include "latex_longtable.tpl" %} | ||
{% else %} | ||
{% include "latex_table.tpl" %} | ||
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
\begin{longtable} | ||
{%- set position = parse_table(table_styles, 'position') %} | ||
{%- if position is not none %} | ||
[{{position}}] | ||
{%- endif %} | ||
{%- set column_format = parse_table(table_styles, 'column_format') %} | ||
{% raw %}{{% endraw %}{{column_format}}{% raw %}}{% endraw %} | ||
|
||
{% for style in table_styles %} | ||
{% if style['selector'] not in ['position', 'position_float', 'caption', 'toprule', 'midrule', 'bottomrule', 'column_format', 'label'] %} | ||
\{{style['selector']}}{{parse_table(table_styles, style['selector'])}} | ||
{% endif %} | ||
{% endfor %} | ||
{% if caption and caption is string %} | ||
\caption{% raw %}{{% endraw %}{{caption}}{% raw %}}{% endraw %} | ||
{%- set label = parse_table(table_styles, 'label') %} | ||
{%- if label is not none %} | ||
\label{{label}} | ||
{%- endif %} \\ | ||
{% elif caption and caption is sequence %} | ||
\caption[{{caption[1]}}]{% raw %}{{% endraw %}{{caption[0]}}{% raw %}}{% endraw %} | ||
{%- set label = parse_table(table_styles, 'label') %} | ||
{%- if label is not none %} | ||
\label{{label}} | ||
{%- endif %} \\ | ||
{% endif %} | ||
{% set toprule = parse_table(table_styles, 'toprule') %} | ||
{% if toprule is not none %} | ||
\{{toprule}} | ||
{% endif %} | ||
{% for row in head %} | ||
{% for c in row %}{%- if not loop.first %} & {% endif %}{{parse_header(c, multirow_align, multicol_align, True)}}{% endfor %} \\ | ||
{% endfor %} | ||
{% set midrule = parse_table(table_styles, 'midrule') %} | ||
{% if midrule is not none %} | ||
\{{midrule}} | ||
{% endif %} | ||
\endfirsthead | ||
{% if caption and caption is string %} | ||
\caption[]{% raw %}{{% endraw %}{{caption}}{% raw %}}{% endraw %} \\ | ||
{% elif caption and caption is sequence %} | ||
\caption[]{% raw %}{{% endraw %}{{caption[0]}}{% raw %}}{% endraw %} \\ | ||
{% endif %} | ||
{% if toprule is not none %} | ||
\{{toprule}} | ||
{% endif %} | ||
{% for row in head %} | ||
{% for c in row %}{%- if not loop.first %} & {% endif %}{{parse_header(c, multirow_align, multicol_align, True)}}{% endfor %} \\ | ||
{% endfor %} | ||
{% if midrule is not none %} | ||
\{{midrule}} | ||
{% endif %} | ||
\endhead | ||
{% if midrule is not none %} | ||
\{{midrule}} | ||
{% endif %} | ||
\multicolumn{% raw %}{{% endraw %}{{column_format|length}}{% raw %}}{% endraw %}{r}{Continued on next page} \\ | ||
{% if midrule is not none %} | ||
\{{midrule}} | ||
{% endif %} | ||
\endfoot | ||
{% set bottomrule = parse_table(table_styles, 'bottomrule') %} | ||
{% if bottomrule is not none %} | ||
\{{bottomrule}} | ||
{% endif %} | ||
\endlastfoot | ||
{% for row in body %} | ||
{% for c in row %}{% if not loop.first %} & {% endif %} | ||
{%- if c.type == 'th' %}{{parse_header(c, multirow_align, multicol_align)}}{% else %}{{parse_cell(c.cellstyle, c.display_value)}}{% endif %} | ||
{%- endfor %} \\ | ||
{% endfor %} | ||
\end{longtable} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{% if environment or parse_wrap(table_styles, caption) %} | ||
\begin{% raw %}{{% endraw %}{{environment if environment else "table"}}{% raw %}}{% endraw %} | ||
{%- set position = parse_table(table_styles, 'position') %} | ||
{%- if position is not none %} | ||
[{{position}}] | ||
{%- endif %} | ||
|
||
{% set position_float = parse_table(table_styles, 'position_float') %} | ||
{% if position_float is not none%} | ||
\{{position_float}} | ||
{% endif %} | ||
{% if caption and caption is string %} | ||
\caption{% raw %}{{% endraw %}{{caption}}{% raw %}}{% endraw %} | ||
|
||
{% elif caption and caption is sequence %} | ||
\caption[{{caption[1]}}]{% raw %}{{% endraw %}{{caption[0]}}{% raw %}}{% endraw %} | ||
|
||
{% endif %} | ||
{% for style in table_styles %} | ||
{% if style['selector'] not in ['position', 'position_float', 'caption', 'toprule', 'midrule', 'bottomrule', 'column_format'] %} | ||
\{{style['selector']}}{{parse_table(table_styles, style['selector'])}} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
\begin{tabular} | ||
{%- set column_format = parse_table(table_styles, 'column_format') %} | ||
{% raw %}{{% endraw %}{{column_format}}{% raw %}}{% endraw %} | ||
|
||
{% set toprule = parse_table(table_styles, 'toprule') %} | ||
{% if toprule is not none %} | ||
\{{toprule}} | ||
{% endif %} | ||
{% for row in head %} | ||
{% for c in row %}{%- if not loop.first %} & {% endif %}{{parse_header(c, multirow_align, multicol_align, True)}}{% endfor %} \\ | ||
{% endfor %} | ||
{% set midrule = parse_table(table_styles, 'midrule') %} | ||
{% if midrule is not none %} | ||
\{{midrule}} | ||
{% endif %} | ||
{% for row in body %} | ||
{% for c in row %}{% if not loop.first %} & {% endif %} | ||
{%- if c.type == 'th' %}{{parse_header(c, multirow_align, multicol_align)}}{% else %}{{parse_cell(c.cellstyle, c.display_value)}}{% endif %} | ||
{%- endfor %} \\ | ||
{% endfor %} | ||
{% set bottomrule = parse_table(table_styles, 'bottomrule') %} | ||
{% if bottomrule is not none %} | ||
\{{bottomrule}} | ||
{% endif %} | ||
\end{tabular} | ||
{% if environment or parse_wrap(table_styles, caption) %} | ||
\end{% raw %}{{% endraw %}{{environment if environment else "table"}}{% raw %}}{% endraw %} | ||
|
||
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
not sure i love this name, maybe template: and this should be 'longtable', 'table' ?
your comment on position_float is hard to interpret here
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.
environment is the proper LaTeX name for these blocks: LaTeX environments
'longtable' and 'table' are common environments for this but there are others. e.g. see #37443
some arguments are nullified by the use of the 'longtable' environment, such as 'position_float'. can try and rephrase this.
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.
maybe should raise ValueError if invalid combinations of parameters are given
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.
there was already validation on
position_float
so this was non-contentious addition.