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

feat: allow rendering of tables to LaTeX #481

Merged
merged 198 commits into from
Nov 4, 2024
Merged

feat: allow rendering of tables to LaTeX #481

merged 198 commits into from
Nov 4, 2024

Conversation

rich-iannone
Copy link
Member

@rich-iannone rich-iannone commented Oct 2, 2024

This feature PR implements the rendering of tables to LaTeX, addressing #75 and #178. This will be exposed through the as_latex() method on the GT class. If in Quarto and the render target is LaTeX, tables will be automatically rendered as LaTeX tables.

Preview: https://pr-481--gt-python.netlify.app/a-latex_examples/index.pdf.

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

Attention: Patch coverage is 95.26917% with 29 lines in your changes missing coverage. Please review.

Project coverage is 88.88%. Comparing base (cc9829c) to head (c2f7c81).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
great_tables/_formats.py 92.25% 22 Missing ⚠️
great_tables/_utils.py 88.46% 3 Missing ⚠️
great_tables/_utils_render_latex.py 99.13% 2 Missing ⚠️
great_tables/_gt_data.py 80.00% 1 Missing ⚠️
great_tables/_spanners.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #481      +/-   ##
==========================================
+ Coverage   87.86%   88.88%   +1.01%     
==========================================
  Files          42       44       +2     
  Lines        4852     5216     +364     
==========================================
+ Hits         4263     4636     +373     
+ Misses        589      580       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot temporarily deployed to pr-481 October 2, 2024 18:12 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 October 2, 2024 20:53 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 October 2, 2024 21:20 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 October 2, 2024 21:38 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 October 3, 2024 01:04 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 October 3, 2024 01:10 Destroyed
great_tables/gt.py Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pr-481 October 31, 2024 15:12 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 November 1, 2024 19:38 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 November 1, 2024 20:08 Destroyed
Copy link
Collaborator

@machow machow left a comment

Choose a reason for hiding this comment

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

From pairing -- we ran the examples from https://posit-dev.github.io/great-tables/examples/ .

Main pieces:

  • Explicitly raise or warn for currently unsupported behaviors (e.g. styles)
  • formatters sometimes run but their output generate latex errors
    • fmt_nanoplot
    • fmt_markdown
    • fmt_image
    • fmt_url
    • fmt_integer (?) -- this seems to raise a python error
  • the md() and html() functions produce output that causes latex errors (but maybe this is okay?)

One interesting note is that quarto can handle images and urls in tables. We don't have to do the same, but it's worth documenting down quarto's behavior the road!

@github-actions github-actions bot temporarily deployed to pr-481 November 4, 2024 15:04 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 November 4, 2024 17:30 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 November 4, 2024 17:31 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 November 4, 2024 17:57 Destroyed
@rich-iannone
Copy link
Member Author

  • Explicitly raise or warn for currently unsupported behaviors (e.g. styles)

Now we warn when there is any definition of tab_style() in LaTeX output.

  • formatters sometimes run but their output generate latex errors
    • fmt_nanoplot
    • fmt_markdown
    • fmt_image
    • fmt_url
    • fmt_integer (?) -- this seems to raise a python error
  • fmt_integer() is fine. No error on second look
  • fmt_url() is not in API.
  • fmt_image now provides a warning and formatting is skipped
  • fmt_markdown raises a NotImplementedError in LaTeX render
  • fmt_nanoplot also raises a NotImplementedError
  • the md() and html() functions produce output that causes latex errors (but maybe this is okay?)
  • md() still raises a NotImplementedError
  • html() will warn and perform LaTeX escaping on the string

@github-actions github-actions bot temporarily deployed to pr-481 November 4, 2024 19:49 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 November 4, 2024 19:59 Destroyed
@github-actions github-actions bot temporarily deployed to pr-481 November 4, 2024 20:02 Destroyed
@rich-iannone rich-iannone requested a review from machow November 4, 2024 20:21
@machow machow merged commit 5913c57 into main Nov 4, 2024
13 checks passed
@machow machow deleted the feat-latex-rendering branch November 4, 2024 20:34
@machow
Copy link
Collaborator

machow commented Nov 4, 2024

From pairing, LGTM -- thanks for this ENORMOUS push, excited for latex tables!

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

Successfully merging this pull request may close these issues.

2 participants