-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Escape special characters in to_latex() output #5374
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
Conversation
May consider escaping all of these:
Pandas already deals with three of them:
|
Looks fine, need a minimal test case to ensure this behavior comes out |
@@ -434,6 +434,7 @@ def write(buf, frame, column_format, strcols): | |||
buf.write('\\midrule\n') # End of header | |||
crow = [(x.replace('_', '\\_') | |||
.replace('%', '\\%') | |||
.replace('$', '\\$') |
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.
Since all of the escaping has the same form (append ), maybe consider writing a function that you pass a list of symbols to?
can you add some tests for this? |
@y-p hows this look? |
Looks ok to me. |
@bjornarneson can you squash this down to a single commit? see this: https://github.com/pydata/pandas/wiki/Using-Git |
@bjornarneson ...look ok and passes...ready to merge? |
actually...can you add a release note that indicates this change? (in 0.13.1 improvements would be fine, ref this PR as the issue) |
pls rebase this on master and squash down to a single commit....see here:https://github.com/pydata/pandas/wiki/Using-Git |
@jreback It is probably obvious that I know only enough Git to be dangerous.... I have tried to follow the directions at the link you provided, but have been stymied by failed merges/pushes/rebases/etc. Short of starting over completely, fixing the mess I have made is beyond my current abilities right now. I am sorry about this! |
Someone can walk you through it; git can be frustrating at first (and once you're familiar with it, come to think of it). Checkout your |
Thanks a lot -- I'd like to learn how to do this properly. I checked out a clean copy of my patch-1 branch:
Then I fetch/rebase:
...and use the interactive window to squash all the commits into one commit. Then I get this message:
Git status shows this:
This is the point where I don't know how to proceed. Any teaching would be most appreciated. |
That last output is saying that git can't automatically merge your changes to
Delete the Then add that file |
Thanks Tom -- I appreciate the help. Hopefully this last commit is in good shape. I think I was fouling things up with another command somewhere between manually fixing the release.rst file and the force push. |
Escape special characters in to_latex() output
@bjornarneson thanks! and @TomAugspurger thanks for the help! |
Hi guys. Are there any way to switch off escaping? I.e. if there's a column with the latex-formatted text:
will result in the same output. |
I have also been bitten by this, as I use latex formatting and even latex macros inside strings which are then to be rendered with to_latex: import pandas as pd # version 0.13 revno 5096 or later |
What I wanted to say with my former comment, I also need an option to switch off escaping of latex characters! |
easy enough to do this see #6472 simply add a |
Some characters have special meaning in latex: & % $ # _ { } ~ ^ . When a dataframe contains a special character (as part of an index label, for example), to_latex() spits out invalid latex.