Save huxtable in R to file in LaTex format

527 Views Asked by At

How can I save a huxtable to a file in LaTeX (.tex) format? I did find this code to print LaTeX tables to the console:

library(huxtable)
ht <- huxtable(
        a = 1:3,
        b = letters[1:3]
      )
print_latex(ht)

Does the huxtable package have a native way to save the table to disk or do we need a workaround?

2

There are 2 best solutions below

1
On BEST ANSWER

The huxtable package has a function to do that: quick_latex(ht, file = "Table.tex", open = FALSE).

1
On

There might be other ways but using capture.output works -

library(huxtable)
capture.output(print_latex(ht), file = 'output.tex')