Question Details

No question body available.

Tags

r gtsummary gt

Answers (1)

Accepted Answer Available
Accepted Answer
July 14, 2025 Score: 5 Rep: 12,001 Quality: Expert Completeness: 80%

The issue can be broken down to this:

rstudio/markdown < 2.0

> gt:::markdowntolatex(text = "5/6", mdengine = "markdown") [1] "⅚"

> packageVersion("markdown") [1] ‘1.13’

"5/6" gets a special treatment during processing, see markdown:::pants for the relevant values (e.g. "6/7" works without special processing):

> markdown:::pants 1/2 1/3 2/3 1/4 3/4 1/5 2/5 3/5 "½" "&frac13;" "&frac23;" "¼" "¾" "&frac15;" "&frac25;" "&frac35;" 4/5 1/6 5/6 1/8 3/8 5/8 7/8 1/7 "&frac45;" "&frac16;" "&frac56;" "&frac18;" "&frac38;" "&frac58;" "&frac78;" "⅐" 1/9 1/10 (c) (r) (tm) "⅑" "⅒" "©" "®" "™"

In markdown::markdownoptions() is a smartypants option enabled which later causes the conversion which you see in the final table.

What works for me in order to circumvent this is to use the HTML code for the forward slash:

gt:::markdowntolatex(text = "5/6", mdengine = "markdown") [1] "5/6"

enter image description here

rstudio/markdown = 2.0

Several users described that the issue described in the question is not reproducible. This is indeed the case with the markdown package in version 2.0.

> gt:::markdown
tolatex(text = "5/6", mdengine = "markdown") [1] "5/6"

> packageVersion("markdown") [1] ‘2.0’

The reason is as follows: The markdown package is now superseded by litedown and therefore, several markdown functions are now only wrapper functions for litedown ones. In particular, markdown::markdownoptions only calls litedown under the hood:

> markdown::markdown
options function () litedown::markdownoptions()

Now the special treatment of 5/6 is not seen anymore because litedown currently has no smartypants option

# options disabled by default x2 = c( 'toc', 'hardbreaks', 'tagfilter', 'number
sections', 'cleveref', 'offline', 'smartypants' )

(although litedown:::pants and litedown:::smartypants are available), whereas markdown up to 1.13 had:

# options enabled by default x1 = c( 'smart', 'smartypants', 'embedresources', 'jsmath', 'jshighlight', 'superscript', 'subscript', 'latexmath', 'autoidentifiers', setdiff(commonmark::listextensions(), 'tagfilter') )