hughjonesd / huxtable

An R package to create styled tables in multiple output formats, with a friendly, modern interface.
http://hughjonesd.github.io/huxtable
Other
321 stars 28 forks source link

Compile failure with `quick_pdf()` when col_width is specified with numeric values #111

Closed gestauffer closed 5 years ago

gestauffer commented 5 years ago

When I try to export a table with quick_pdf(), after using numeric values to specify column width, e,g., set_col_width(1:3, c(0.6,0.2,0.2)) the export fails and produces an error:

! Illegal unit of measure (pt inserted).
<to be read again> 
                   !
l.108 \end{tabularx}
                    \end{threeparttable} 
Error: Failed to compile 

C:\Users\staufge\AppData\Local\Temp\Rtmp6p7GhF\file26983e8c25a6.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See file26983e8c25a6.log for more info.

This error is not produced when knitting out of rmarkdown.

For more detail, see my post at: https://stackoverflow.com/questions/55833023/confusion-about-setting-column-width-in-huxtable/55852144?noredirect=1#comment98442440_55852144

hughjonesd commented 5 years ago

The following works for me:

test = data.frame(var1=1918:1925,var2=c(9009,1000:1006),var3 = 1100:1107)
HUX <- hux(test)
HUX = set_col_width(HUX, 1:3, c(0.6,0.2,0.2))
quick_pdf(HUX)

Could you provide a MWE and report your platform details, including whether the tinytex package is installed?

gestauffer commented 5 years ago

Hmm, it works for me now as well. I thought that the issue cropped up with wrap(HUX) = TRUE, but that doesn't create a problem now. And the code below works as well (that was my MWE).

library(dplyr)
library(huxtable)

test=data.frame(var1=1918:1925,var2=c(9009,1000:1006),var3 = 1100:1107)
HUX <- hux(test)

# add caption, borders, and colnames
HUX <- set_caption(HUX,"Example table") %>%
set_caption_pos("topleft") %>%
set_top_border(1,,1) %>%
set_bottom_border(final(1), , 1)    %>%
set_align(,,"left") %>%
add_colnames()

#set width
HUX <- set_width(HUX,1) %>%
    set_wrap(,,TRUE) %>%    
    set_col_width(1:3, c(0.6,0.2,0.2)) 
quick_pdf(HUX)                                

My platform is Win 10, R 3.5.0 (I can't update right now for institutional reasons). The tinytex package is installed.

hughjonesd commented 5 years ago

Heh. Reopen if you manage to reproduce!