-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
ENH: add long and short captions to Styler.to_latex
#41659
Conversation
Styler.to_latex
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.
Minor comment from my side.
By the way, I am not an expert in html rendering, so I cannot provide a review on the html related changes.
|
||
def test_long_captions(styler): | ||
result = styler.to_latex(caption=("short cap", "long cap")) | ||
assert "\\caption[short cap]{long cap}" in result |
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.
Can you replicate the existing behavior as here https://github.com/pandas-dev/pandas/pull/35668/files?
Currently in DataFrame.to_latex
we can pass a string full_caption
or a tuple (full_caption, short_caption)
.
In your code it is vice versa (short_caption, full_caption)
.
Also I would rename this test function to test_short_caption
, since it targets a feature of adding a short caption.
In addition, you would need to change the indices in the docstring as well.
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.
good catch. easy fix. should be ok now.
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.
Looks good to me.
One should remember to add tests for short captions for longtables once those are implemented.
\caption{% raw %}{{% endraw %}{{caption}}{% raw %}}{% endraw %} | ||
|
||
{% elif caption and caption is sequence %} | ||
\caption[{{caption[1]}}]{% raw %}{{% endraw %}{{caption[0]}}{% raw %}}{% endraw %} |
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.
Please keep in mind that the same behavior should be implemented for longtable (once the longtables are implemented through the styler).
# Conflicts: # pandas/io/formats/templates/html.tpl # pandas/tests/io/formats/style/test_style.py
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.
small comment. can you add this issue number to an existing whatsnew (for .to_latex stuff) ping on green
@@ -87,8 +87,8 @@ class Styler(StylerRenderer): | |||
List of {selector: (attr, value)} dicts; see Notes. | |||
uuid : str, default None | |||
A unique identifier to avoid CSS collisions; generated automatically. | |||
caption : str, default None | |||
Caption to attach to the table. | |||
caption : str, tuple, default None |
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.
would emphasize here and below tht this is (full caption, short caption)
thanks |
completes an item on the list for
DataFrame.to_latex
deprecation #41649