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

Table title is cut off if title is wider than table #139

Open
nathanrboyer opened this issue Sep 3, 2021 · 4 comments
Open

Table title is cut off if title is wider than table #139

nathanrboyer opened this issue Sep 3, 2021 · 4 comments

Comments

@nathanrboyer
Copy link
Contributor

I would think default behavior should be to center the table beneath the full title.

FAD Residual Bore Tangential St…
           t₀ = 1.000
Root Mean Square Error = 3.529E…
┌───────────┬──────────────────┐
│  Variable │         Region 1 │
├───────────┼──────────────────┤
│ Coeff. x⁰ │    A₀₁ = -54.071 │
│ Coeff. x¹ │    A₁₁ = 586.412 │
│ Coeff. x² │ A₂₁ = -1,869.967 │
│ Coeff. x³ │  A₃₁ = 2,338.279 │
│ Coeff. x⁴ │ A₄₁ = -1,004.765 │
│ Thickness │       t₁ = 1.000 │
│   Indices │    i₁ = [1, 202] │
└───────────┴──────────────────┘
@nathanrboyer nathanrboyer changed the title Table title is cut off if table is narrower than title. Table title is cut off if title is wider than table Sep 3, 2021
@ronisbr
Copy link
Owner

ronisbr commented Sep 8, 2021

Hi @nathanrboyer

Sorry for the delay. Can you please explain me better what do you want? I think I did not understand correctly.

@nathanrboyer
Copy link
Contributor Author

nathanrboyer commented Sep 9, 2021

For the above table, I would like max(title_width, table_width) to determine the display width with spaces added around the sides of the table if needed like below so the title isn't cut short.

FAD Residual Bore Tangential Stress
              t₀ = 1.000
Root Mean Square Error = 3.529E-02
  ┌───────────┬──────────────────┐
  │  Variable │         Region 1 │
  ├───────────┼──────────────────┤
  │ Coeff. x⁰ │    A₀₁ = -54.071 │
  │ Coeff. x¹ │    A₁₁ = 586.412 │
  │ Coeff. x² │ A₂₁ = -1,869.967 │
  │ Coeff. x³ │  A₃₁ = 2,338.279 │
  │ Coeff. x⁴ │ A₄₁ = -1,004.765 │
  │ Thickness │       t₁ = 1.000 │
  │   Indices │    i₁ = [1, 202] │
  └───────────┴──────────────────┘

@nathanrboyer
Copy link
Contributor Author

nathanrboyer commented Sep 24, 2021

Sorry, I didn't explain well. Here is a full MWE now that I understand the problem a little better.

julia> using DataFrames, PrettyTables

julia> df = DataFrame(x=['a','b','c'], y=1.0:3.0)
3×2 DataFrame
 Row │ x     y       
     │ Char  Float64 
─────┼───────────────
   1 │ a         1.0
   2 │ b         2.0
   3 │ c         3.0

julia> pretty_table(df, title="Short Title", title_alignment=:c, title_same_width_as_table = true)
   Short Title
┌──────┬─────────┐
│    x │       y │
│ Char │ Float64 │
├──────┼─────────┤
│    a │     1.0 │
│    b │     2.0 │
│    c │     3.0 │
└──────┴─────────┘

julia> pretty_table(df, title="This is a Very Long Title", title_alignment=:c, title_same_width_as_table = true)
This is a Very Lo…
┌──────┬─────────┐
│    x │       y │
│ Char │ Float64 │
├──────┼─────────┤
│    a │     1.0 │
│    b │     2.0 │
│    c │     3.0 │
└──────┴─────────┘

julia> pretty_table(df, title="This is a Very Long Title", title_alignment=:c, title_same_width_as_table = false)
                                                                                                                      This is a Very Long Title
┌──────┬─────────┐
│    x │       y │
│ Char │ Float64 │
├──────┼─────────┤
│    a │     1.0 │
│    b │     2.0 │
│    c │     3.0 │
└──────┴─────────┘

I don't find either option for the long title satisfactory. There doesn't seem to be any way to center the table beneath the title if the title is wider than the table. I would like to achieve the same look with the long title as with the short title above. For the long title, spacing would be added to the left of the table until it is centered underneath the full long title.

@ronisbr
Copy link
Owner

ronisbr commented Oct 4, 2021

Hi @nathanrboyer

Yes, I now see what you want. However, implementing this will take a while because the system will need modifications to allow centering the table in the screen or in the title.

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

2 participants