Quantcast
Channel: Active questions tagged kable - Stack Overflow
Viewing all articles
Browse latest Browse all 106

R - kableExtra - simple LaTeX table in PDF document with no column header & contains all vertical and horizontal borders

$
0
0

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:

enter image description here

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:

enter image description here

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

enter image description here

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.


Viewing all articles
Browse latest Browse all 106

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>