8000 To latex position by SylvainLan · Pull Request #35284 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

To latex position #35284

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 15 commits into from
Aug 7, 2020
Prev Previous commit
Next Next commit
remove double backlash for position argument
  • Loading branch information
Sylvain Lannuzel committed Jul 27, 2020
commit 644bdf716f0d342a26cf539d1458d8b861a89ece
6 changes: 4 additions & 2 deletions pandas/io/formats/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ def _write_longtable_begin(self, buf, column_format: str):
<https://en.wikibooks.org/wiki/LaTeX/Tables>`__ e.g 'rcl'
for 3 columns
"""

if self.caption is None:
caption_ = ""
else:
Expand All @@ -367,7 +366,10 @@ def _write_longtable_begin(self, buf, column_format: str):
buf.write(
f"\\begin{{longtable}}{position_}{{{column_format}}}\n{caption_}{label_}"
)
if self._table_float:
if self.caption is not None or self.label is not None:
# a double-backslash is required at the end of the line
# as discussed here:
# https://tex.stackexchange.com/questions/219138
buf.write("\\\\\n")

@staticmethod
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/io/formats/test_to_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ def test_to_latex_longtable_position(self):
result_p = df.to_latex(longtable=True, position=the_position)

expected_p = r"""\begin{longtable}[t]{lrl}
\\
\toprule
{} & a & b \\
\midrule
Expand Down
0