Numeric column widths are treated as proportions of the table width. Character widths must be valid CSS or LaTeX dimensions.

col_width(ht)
col_width(ht) <- value
set_col_width(ht, col, value)

Arguments

ht

A huxtable.

col

A col specifier. See rowspecs for details.

value

Numeric or character vector.. Set to NA to reset to the default, which is NA.

Value

col_width() returns the col_width property. set_col_width() returns the modified huxtable.

Details

In LaTeX, if you specify a column width, but set wrap to FALSE and have cells which overrun, then you may have problems with table position and with background colours in other cells. The workaround is to adjust the width, so that your cells no longer overrun.

See also

Other table measurements: height(), row_height(), width()

Examples


col_width(jams) <-  c(.2, .8)
#> Warning: number of items to replace is not a multiple of replacement length
col_width(jams)
#>  Type Price Sugar 
#>   0.2   0.8   0.2 
jams$Notes <- c("Notes",
      "This year's finest", "", "")
jams
#>                   Type           Price       Sugar       Notes  
#>                                            content              
#>                   Strawberr       1.90      40.00%        This  
#>                   y                                     year's  
#>                                                         finest  
#>                   Raspberry       2.10      35.00%              
#>                   Plum            1.80      50.00%              
#> 
#> Column names: Type, Price, Sugar, Notes
set_col_width(jams, c(.4, .5, .1))
#> Warning: number of items to replace is not a multiple of replacement length
#>                              Type            Price  
#>                              Strawberry       1.90  
#>                              Raspberry        2.10  
#>                              Plum             1.80  
#> 
#> Column names: Type, Price, Sugar, Notes
#> 
#> 2/4 columns shown.