Skip to contents

The currency() helper function makes it easy to specify a context-aware currency symbol to currency argument of fmt_currency(). Since gt can render tables to several output formats, currency() allows for different variations of the custom symbol based on the output context (which are html, latex, rtf, and default). The number of decimal places for the custom currency defaults to 2, however, a value set for the decimals argument of fmt_currency() will take precedence.


currency(..., .list = list2(...))



Currency symbols by output context

<named arguments> // required (or, use .list)

One or more named arguments using output contexts as the names and currency symbol text as the values.


Alternative to ...

<list of multiple expressions> // required (or, use ...)

Allows for the use of a list as an input alternative to ....


A list object of class gt_currency.


We can use any combination of html, latex, rtf, and default as named arguments for the currency text in each of the namesake contexts. The default value is used as a fallback when there doesn't exist a dedicated currency text value for a particular output context (e.g., when a table is rendered as HTML and we use currency(latex = "LTC", default = "ltc"), the currency symbol will be "ltc". For convenience, if we provide only a single string without a name, it will be taken as the default (i.e., currency("ltc") is equivalent to currency(default = "ltc")). However, if we were to specify currency strings for multiple output contexts, names are required each and every context.


Use the exibble dataset to create a gt table. Within the fmt_currency() call, we'll format the currency column to have currency values in guilder (a defunct Dutch currency). We can register this custom currency with the currency() helper function, supplying the "&fnof;" HTML entity for html outputs and using "f" for any other type of gt output.

exibble |>
  gt() |>
    columns = currency,
    currency = currency(
      html = "&fnof;",
      default = "f"
    decimals = 2

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

Function ID


Function Introduced

v0.2.0.5 (March 31, 2020)