great-tables icon indicating copy to clipboard operation
great-tables copied to clipboard

feat: allow rendering of tables to LaTeX

Open rich-iannone opened this issue 1 year ago • 1 comments

This feature PR implements the rendering of tables to LaTeX, addressing https://github.com/posit-dev/great-tables/issues/75 and https://github.com/posit-dev/great-tables/issues/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.

rich-iannone avatar Oct 02 '24 18:10 rich-iannone

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 :warning:
great_tables/_utils.py 88.46% 3 Missing :warning:
great_tables/_utils_render_latex.py 99.13% 2 Missing :warning:
great_tables/_gt_data.py 80.00% 1 Missing :warning:
great_tables/_spanners.py 66.66% 1 Missing :warning:
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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 02 '24 18:10 codecov[bot]

  • 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

rich-iannone avatar Nov 04 '24 19:11 rich-iannone

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

machow avatar Nov 04 '24 20:11 machow