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

Fix render with large tables #155

Open
sbreitbart-NOAA opened this issue Jan 24, 2025 · 6 comments · May be fixed by #158
Open

Fix render with large tables #155

sbreitbart-NOAA opened this issue Jan 24, 2025 · 6 comments · May be fixed by #158
Assignees
Labels
bug Something isn't working
Milestone

Comments

@sbreitbart-NOAA
Copy link
Collaborator

Tables width > page width
Tables spanning >1 page
Landscape tables >1 page

  • sablefish + bsb good examples
@sbreitbart-NOAA sbreitbart-NOAA added the bug Something isn't working label Jan 24, 2025
@sbreitbart-NOAA sbreitbart-NOAA added this to the 2025 Q2 Goals milestone Jan 24, 2025
@sbreitbart-NOAA sbreitbart-NOAA self-assigned this Jan 24, 2025
@sbreitbart-NOAA
Copy link
Collaborator Author

sbreitbart-NOAA commented Jan 27, 2025

Ideas that have not worked:

  • adding these "landscape mode" braces around results chunk in skeleton, and/or specific R chunk in 08_tables.qmd After downloading the latest quarto version (1.6), the page does rotate to landscape when braces are put around an R chunk in 08_tables.qmd!
  • rotating the flextable (no option for this; only rotating text, which doesn't update the placement of the headers)
  • Putting latex commands inside an R chunk instead of outside, like this:
  cat(\newpage)
  cat(\blandscape)
  indices_table
  cat(\elandscape)
  cat(\newpage)

@sbreitbart-NOAA sbreitbart-NOAA added the help wanted Extra attention is needed label Jan 27, 2025
@sbreitbart-NOAA
Copy link
Collaborator Author

sbreitbart-NOAA commented Jan 28, 2025

Ideas that have shown promise:

  1. Adding the 3 latex packages in the skeleton yaml under the "header-includes" line, and wrapping a plot chunk (e.g., label: 'tbl-indices-plot') in these lines, as explained in this post:

\newpage
\blandscape
Landscape

summary(cars)

\elandscape

This forces the R chunk to be plotted in a landscape-oriented page, and creates output like this: Image

  1. Adding code like this to that same chunk in 08_tables.qmd (replacing the above summary(cars) line), so that if the table is wider than the rotated page, the text is shrunken so that the table can fit in the landscape page.

Example code:

# set page width in inches
page_width <- 7.5

# identify flextable width
table_width <- flextable::flextable_dim(indices_table)[["widths"]] |> as.numeric()

if (table_width > page_width){
  indices_table <- indices_table |>
    flextable::fit_to_width(max_width = page_width )

  indices_table
} else {
  indices_table
}

This creates output like this:

Image

  1. After updating quarto to the latest version (1.6) 🤦 : Using the quarto landscape braces in the 08_tables.qmd (putting them around the R chunk), and not needing any extra yaml additions to the skeleton under header-includes! Creates output like in note 2, above.

Helpful post explaining previous questions and solutions for implementing landscape page orientation in quarto

@Schiano-NOAA
Copy link
Collaborator

#2 could be a good option. We would just need to code it into the tables. This however does not help the users if they are making custom ones. This is a great start!

@sbreitbart-NOAA
Copy link
Collaborator Author

#2 could be a good option. We would just need to code it into the tables. This however does not help the users if they are making custom ones. This is a great start!

Turns out, I just needed to update quarto to get the landscape option to work 🤦 but it's much easier to use. It might be possible to automate the insertion of the landscape braces around the chunk if a table is too wide for portrait- will try this next. But I think we've hit a milestone of identifying how to switch a table's orientation from portrait to landscape, at least!

@sbreitbart-NOAA sbreitbart-NOAA linked a pull request Jan 28, 2025 that will close this issue
@sbreitbart-NOAA sbreitbart-NOAA linked a pull request Jan 28, 2025 that will close this issue
@Schiano-NOAA
Copy link
Collaborator

#2 could be a good option. We would just need to code it into the tables. This however does not help the users if they are making custom ones. This is a great start!

Turns out, I just needed to update quarto to get the landscape option to work 🤦 but it's much easier to use. It might be possible to automate the insertion of the landscape braces around the chunk if a table is too wide for portrait- will try this next. But I think we've hit a milestone of identifying how to switch a table's orientation from portrait to landscape, at least!

What version did you update it to?

@sbreitbart-NOAA
Copy link
Collaborator Author

#2 could be a good option. We would just need to code it into the tables. This however does not help the users if they are making custom ones. This is a great start!

Turns out, I just needed to update quarto to get the landscape option to work 🤦 but it's much easier to use. It might be possible to automate the insertion of the landscape braces around the chunk if a table is too wide for portrait- will try this next. But I think we've hit a milestone of identifying how to switch a table's orientation from portrait to landscape, at least!

What version did you update it to?

I updated the CLI to 1.6.40 (download page here). My quarto R package's version is 1.4.4.

@sbreitbart-NOAA sbreitbart-NOAA removed the help wanted Extra attention is needed label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants