Skip to contents

For certain pieces of text (like in column labels or table headings) we may want to express them as raw LaTeX. In fact, with LaTeX, so much more can be done for formatting. The latex() function will guard the input LaTeX from being escaped.

Usage

latex(text)

Arguments

text

LaTeX text

scalar<character> // required

The text that is understood to be LaTeX text, which is to be preserved in the LaTeX output context.

Value

A character object of class latex. It's tagged as an latex fragment that is not to be sanitized.

Examples

Use the exibble dataset to create a gt table. When adding a title through tab_header(), we'll use the latex() helper to signify to gt that we're using LaTeX formatting.

exibble |>
  dplyr::select(currency, char) |>
  gt() |>
  tab_header(title = latex("\\emph{LaTeX}"))

This image of a table was generated from the first code example in the `latex()` help file.

Function ID

8-2

Function Introduced

v1.0.1 (May 10, 2025)