The code in Chunk 1 compiles, but no caption when the markup language is markdown. The table is not a floating environment.

# Chunk 1
library(qwraps2)
options(qwraps2_markup = "markdown")
eg_table <- summary_table(mtcars[c("mpg", "hp")])
print(eg_table, caption = "Example Caption")

Chunk 2 will work and I can reference the captioned Table \ref{tab:example_table_2} as I would any other table in \LaTeX.

# Chunk 2
options(qwraps2_markup = "latex")
eg_table <- summary_table(mtcars[c("mpg", "hp")])

# use booktabs = TRUE to have better formatting.
print(eg_table, caption = "Example Caption", booktabs = TRUE)

The last chunk here, chunk 3 will result in a compile error. The issue is that th summary statistics characters are generated with the expectation of markdown but the markup language wrapping up the character matrix is \LaTeX. The \± html code introduces the `Extra alignment tab has been change to \cr. error.

# Chunk 3 ... compile error if chunk option "results = 'asis'" is used.  No
options(qwraps2_markup = "markdown")
eg_table <- summary_table(mtcars[c("mpg", "hp")])
print(eg_table, caption = "Example Caption", markup = "latex")

# omit the \hline after every row
print(eg_table, caption = "Example Caption", markup = "latex", booktabs = TRUE)


dewittpe/qwraps2 documentation built on Jan. 4, 2024, 1:59 p.m.