nutterb / pixiedust

Tables So Beautifully Fine-Tuned You Will Believe It's Magic.
179 stars 18 forks source link

< not showing up correctly in LaTeX output. #74

Closed ckraner closed 6 years ago

ckraner commented 7 years ago

Loving the progress on making this package. A lot of great commands. However, when you use the pvalString() function on the table, and then output it to LaTeX, the < does not show up, rather ¿ does. This is because in the code it is just < .001, and < is a reserved character. Please change to use a verbatim environment for that value. (i.e. "\verb|<|" or another delimiter). Use the verbatim over math environment for formatting.

nutterb commented 7 years ago

I'm not getting the same issue on my machine, which may very well be a matter of configuration. The code I'm using is below.

Which version of pixiedust are you using?

---
title: "Untitled"
output: pdf_document
header-includes: 
- \usepackage{amssymb} 
- \usepackage{arydshln} 
- \usepackage{caption} 
- \usepackage{graphicx} 
- \usepackage{hhline} 
- \usepackage{longtable} 
- \usepackage{multirow} 
- \usepackage[dvipsnames,table]{xcolor} 
---

```{r, include = FALSE}
library(dplyr)
library(pixiedust)
```<!-- remove this comment. it's just for making the code appear correctly on GitHub -->

```{r}
options(pixiedust_print_method = "latex")

data.frame(x = letters[1:2],
           b = c("df$x", "df$y"),
           c = c(.00001, .9999),
           stringsAsFactors = FALSE) %>%
  dust(float = FALSE) %>%
  sprinkle(cols = "c",
           fn = quote(pvalString(value))) %>%
  sprinkle(cols = "b", 
           sanitize = TRUE) 
```<!-- remove this comment. it's just for making the code appear correctly on GitHub -->

If that gives you problems, you might try using the sanitize sprinkle. Hopefully that will resolve the matter. If it persists, let me know and I'll have to ask a lot more questions to figure out what is happening.

---
title: "Untitled"
output: pdf_document
header-includes: 
- \usepackage{amssymb} 
- \usepackage{arydshln} 
- \usepackage{caption} 
- \usepackage{graphicx} 
- \usepackage{hhline} 
- \usepackage{longtable} 
- \usepackage{multirow} 
- \usepackage[dvipsnames,table]{xcolor} 
---

```{r, include = FALSE}
library(dplyr)
library(pixiedust)
```<!-- remove this comment. it's just for making the code appear correctly on GitHub -->

```{r}
options(pixiedust_print_method = "latex")

data.frame(x = letters[1:2],
           b = c("df$x", "df$y"),
           c = c(.00001, .9999),
           stringsAsFactors = FALSE) %>%
  dust(float = FALSE) %>%
  sprinkle(cols = "c",
           fn = quote(pvalString(value)),
           sanitize = TRUE) %>%
  sprinkle(cols = "b", 
           sanitize = TRUE) 
```<!-- remove this comment. it's just for making the code appear correctly on GitHub -->
ckraner commented 7 years ago

sanitize fixed this issue, along with my other issue regarding R-format of names. Although sanitize only worked when it was in it's own sprinkle and not with the pvalString(value) sprinkle.

Thank you for your fast reply!

nutterb commented 7 years ago

I'm going to reopen this because the statement "Although sanitize only worked when it was in its own sprinkle and not with the pvalSTring(value) sprinkle" concerns me. The sprinkles shouldn't interfere with each other in that way, so I want to look into this further.