pbs-assess / csasdown

:book: An R package for creating CSAS reports in PDF or Word format with R Markdown and bookdown
Other
47 stars 17 forks source link

Help with special characters table? #256

Closed DylanMG closed 8 months ago

DylanMG commented 8 months ago

I have a fairly simple table with some tex formatting I am trying to render in a ResDoc.

It renders fine when I run it in my figures-tables.Rmd but it won't knit when running index.Rmd. I get the Error: LaTeX failed to compile and have followed all steps on the Yi Hui page, and checked resdoc.log.

resdoc.log was saying I had an unsupported unicode "^" character, which isn't even in my table. Tried using combos of escape and format arguments as suggested in the escaping special characters section in the Rmd cookbook.

Table looks like this: Table_Priors.csv

and am tying to render simple code like this:

priors <- read.csv(here("analysis/data/raw/Table_priors.csv"))

csasdown::csas_table(priors,
                     escape = TRUE, format = "latex", #have tried every combo of T/F, pandoc/latex...
                     caption = "(ref:tab-prior-posterior)")

What could I be missing?

seananderson commented 8 months ago

What was your solution? It can be hard to read in .csv's like in that R with sufficient \ escaping since I think you'd still need \\ in the Rmd to end up with \ in the .tex and the reading of a .csv strips off some level of \ escapes.

DylanMG commented 8 months ago

I was trying to delete the issue because I found my main issue was actually some reference not working with tex. Then I dug back into this table and found I had some bad syntax where "$\sigmaS{MAX}$" should have been "$\sigma{S{MAX}}$".

After fixing that the table works fine with a basic:

csasdown::csas_table(priors,
                     escape = TRUE, 
                     caption = "(ref:tab-prior-posterior)")

Still learning to debug, Really need to take advantage of looking carefully at resdoc.log when things break!