By default, an added table header will have center alignment for both the title and the subtitle elements. This method allows us to easily set the horizontal alignment of the title and subtitle to the left, right, or center by using the "align" argument. This method serves as a convenient shortcut for gt.tab_options(heading_align=<align>).
Parameters
Name
Type
Description
Default
align
str
The alignment of the title and subtitle elements in the table header. Options are "center" (the default), "left", or "right".
The GT object is returned. This is the same object that the method is called on so that we can facilitate method chaining.
Examples
Using select columns from the exibble dataset, let’s create a table with a number of components added. Following that, we’ll align the header contents (consisting of the title and the subtitle) to the left with the opt_align_table_header() method.
from great_tables import GT, exibble, md( GT( exibble[["num", "char", "currency", "row", "group"]], rowname_col="row", groupname_col="group" ) .tab_header( title=md("Data listing from **exibble**"), subtitle=md("`exibble` is a **Great Tables** dataset.") ) .fmt_number(columns="num") .fmt_currency(columns="currency") .tab_source_note(source_note="This is only a subset of the dataset.") .opt_align_table_header(align="left"))