Skip to content
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

[feature request] customize header padding #338

Open
dave-doty opened this issue Aug 24, 2024 · 0 comments
Open

[feature request] customize header padding #338

dave-doty opened this issue Aug 24, 2024 · 0 comments

Comments

@dave-doty
Copy link

It appears that tabulate wants at least 3 spaces between a column delimiter and the header text (in the opposite direction indicated by colalign):

print(tabulate([["First name", "Last name"], ["John", "Doe"]], 
               headers="firstrow", tablefmt="rounded_outline", colalign=("left", "right")))
╭──────────────┬─────────────╮
│ First name   │   Last name │
├──────────────┼─────────────┤
│ John         │         Doe │
╰──────────────┴─────────────╯

I wish I could customize this, particularly for tables with many columns, and allow, say 1 space of padding instead of 3:

print(tabulate([["First name", "Last name"], ["John", "Doe"]], 
               headers="firstrow", tablefmt="rounded_outline", colalign=("left", "right"),
               min_header_padding=1))
╭────────────┬───────────╮
│ First name │ Last name │
├────────────┼───────────┤
│ John       │       Doe │
╰────────────┴───────────╯

It would make sense even to allow this on both sides of the header entry:

print(tabulate([["First name", "Last name"], ["John", "Doe"]], 
               headers="firstrow", tablefmt="rounded_outline", colalign=("left", "right"),
               min_header_left_padding=0, min_header_right_padding=0))
╭──────────┬─────────╮
│First name│Last name│
├──────────┼─────────┤
│ John     │     Doe │
╰──────────┴─────────╯
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant