Cross referencing gt table when knitting to PDF in Markdown

There's a thread from a few years ago that is still relevant.

I prefer to work either in HTML or pdf, depending on the destination requirements, without mixing the two. Here's an example of what's possible using xtable to output.

which is produced with

data(tli)
fm1sc <- aov(tlimth ~ sex + ethnicty + grade, data = tli)
fm1sc.table <- xtable(fm1sc,
  caption = c("ANOVA Model with Predictors Sex, Ethnicity, and Grade",
    "ANOVA: Sex, Ethnicity, Grade"),
  label = "TAAS")
print(fm1sc.table, comment = FALSE)