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
reformat longtable to match table
  • Loading branch information
Sylvain Lannuzel committed Jul 27, 2020
commit bd55f50b4765897b14e5320da9fda85fa779cdb3
41 changes: 20 additions & 21 deletions pandas/io/formats/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ def _write_tabular_begin(self, buf, column_format: str):
else:
position_ = f"[{self.position}]"

buf.write(
f"\\begin{{table}}{position_}\n\\centering{caption_}{label_}\n"
)
buf.write(f"\\begin{{table}}{position_}\n\\centering{caption_}{label_}\n")
else:
# then write output only in a tabular environment
pass
Expand Down Expand Up @@ -347,29 +345,30 @@ 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:
caption_ = f"\\caption{{{self.caption}}}"

if self.label is None:
label_ = ""
else:
label_ = f"\\label{{{self.label}}}"

if self.position is None:
position_ = ""
else:
position_ = f"[{self.position}]"
buf.write(f"\\begin{{longtable}}{position_}{{{column_format}}}\n")

if self.caption is not None or self.label is not None:
if self.capt 8000 ion is None:
pass
else:
buf.write(f"\\caption{{{self.caption}}}")

if self.label is None:
pass
else:
buf.write(f"\\label{{{self.label}}}")

# a double-backslash is required at the end of the line
# as discussed here:
# https://tex.stackexchange.com/questions/219138
buf.write("\\\\\n")
if self.position is None:
position_ = ""
else:
pass
position_ = f"[{self.position}]"
Copy link
Member

Choose a reason for hiding this comment

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

Duplicated lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right thanks !

buf.write(
f"\\begin{{longtable}}{position_}{{{column_format}}}\n{caption_}{label_}"
)
if self._table_float:
buf.write("\\\\\n")

@staticmethod
def _write_longtable_end(buf):
Expand Down
0