I am attempting to re-create a LibreOffice Writer table in R using the kableExtra
package in a rmarkdown
-generated PDF document using a LaTeX table.
The desired table looks like this:
The R code that is used to attempt to match that table is:
options(knitr.kable.NA = "")library(kableExtra)library(data.table)invoice_table <- data.table(row1 = c("Date", NA, "Net Price", "Tax", "Total Price", "Amount Due"),row2 = c("Description", rep(NA, 5)), row3 = c("Charge Type", "Project", rep(NA, 4)),row4 = c("Quantity", rep(NA, 5)), row5 = c("Unit Price", rep(NA, 5)),row6 = c("Total", rep(NA, 5)))invoice_tables3 <- kbl(invoice_table, col.names = rep("", ncol(invoice_table)), toprule = "", vline = "|")invoice_tables3
This is the output of the R code:
As can be seen from the tables, there are no headers (columns) and there are intersecting vertical and horizontal lines within and outside the table rows and columns.
How can the LibreOffice Writer table be replicated in a LaTeX table to be included in a PDF document?
UPDATE: Although this was not stated at the beginning, the table is intended to be a part of an invoice template.
The following is the table generated by flextable
This is the flextable
code:
myft <- flextable(invoice_table, cwidth = 1)theme_box(myft)
As I did not have success with flextable
, huxtable
, etc., I used kableExtra
because it worked and it came the closest to the table that I wanted to make.