Currently, cols_align() works on entire columns and there is no way to align the column labels differently than the data cells associated with the targeted columns. It would also be good to align certain cells differently.
All of this might involve incorporating either the rows or locations argument in order to target cells.
Just curious--when would you want to align column labels different than their respective data cells?
It’s sometimes more aesthetically pleasing to have centered headers with (1) columns that contain free-form text (usually these are wider columns), (2) in tables with many columns of mixed alignments, or (3) for column headers under a spanning column header (to center those column labels).
Great, thanks for the clarification.
You’re welcome! I’ve seen some wonderful tables in books that do great stuff with different alignments. Unfortunately these examples are hard to find on the internet, but having the freedom for a few more styling choices like this I feel will go a long way.
We can modify the column labels’ alignment easily now with tab_style() so this update isn’t really needed anymore.
Most helpful comment
It’s sometimes more aesthetically pleasing to have centered headers with (1) columns that contain free-form text (usually these are wider columns), (2) in tables with many columns of mixed alignments, or (3) for column headers under a spanning column header (to center those column labels).