Library

Documentation for PrettyTables.jl.

PrettyTables.AbstractHighlighterType
abstract type AbstractHighlighter

Supertype of the highlighters of all back ends. A highlighter has the fields:

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature fd(h, data, i, j) in which h is the highlighter. This function must return the decoration to be applied to the highlighted cell.

The subtypes are the general Highlighter, which can be used with every back end, and the back end highlighters TextHighlighter, HtmlHighlighter, LatexHighlighter, MarkdownHighlighter, TypstHighlighter, and ExcelHighlighter.

source
PrettyTables.EmptyCellsType
struct EmptyCells

Specification for adding a set of empty cells at the column label rows.

Fields

  • number_of_cells::Int: Number of cells to add (must be greater than 0).
source
PrettyTables.ExcelFormatterType
struct ExcelFormatter

Define the Excel format to apply to a cell.

Fields

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be formatted, or false otherwise. The first argument is the entire data matrix passed to pretty_table, allowing data[i, j] to be inspected inside the predicate.
  • numFmt::Vector{ExcelPair}: Specifies the format to apply to the cell. The format should be specified with an ExcelPair (i.e. Pair{String, String}) using the XLSX.jl formatting definitions used by the XLSX.setFormat function.
  • region::Symbol: Region of the table in which the formatter is applied. It can be :data or :summary_row. If it is :data, the formatter is applied to the data cells and the value of i passed to f is the data row index. If it is :summary_row, the formatter is applied to the summary row cells and the value of i passed to f is the summary row index (i.e. 1 for the first summary row, 2 for the second, and so on).

Constructors

ExcelFormatter(f::Function, numFmt::Vector{ExcelPair}; region::Symbol = :data)

The keyword region defaults to :data, so the formatter matches data cells based on the data row index unless :summary_row is explicitly requested.

Remarks

It is possible to apply a set of native Excel formats by passing a Vector{ExcelFormatter} to the excel_formatters keyword. Each Excel formatter is an instance of the structure ExcelFormatter.

The first formatter (in the order they are specified) that satisfies the specified condition in the given table cell is applied, and the remainder of the formatters in the list are skipped. If none matches, no ExcelFormatter is applied.

An ExcelFormatter can be applied in the summary row, too. In this case, set region to :summary_row. The value of i passed to f then relates to the summary row index (1 for the first summary row, 2 for the second, and so on), rather than the data table row. The value of j has the same meaning/values (column specifier) as in the data table itself.

Excel formatters may be applied in addition to the standard formatters. The standard formatters control the literal values written to Excel while the Excel formatters control how Excel displays the literal cell values.

For example, to apply Excel-native formatting to different columns of a table:

excel_formatters = [
    ExcelFormatter((data, i, j) -> (j==1), ["format" => "#,##0_0_0"])
    ExcelFormatter((data, i, j) -> (j==2), ["format" => "#,##0.??_0_0"])
    ExcelFormatter((data, i, j) -> (j==3), ["format" => "#,##0.???"])
    ExcelFormatter((data, i, j) -> (j==4), ["format" => "0_0_0_0"])
]

Excel formatters apply native Excel formatting to native Excel values. However, PrettyTables.jl can handle Julia types that can't be represented natively in Excel. If these are passed natively, then XLSX.jl will fail. To circumvent this, a predefined formatter has been provided which converts any unhandled types to strings (using string()). For more information, see fmt__excel_stringify.

source
PrettyTables.ExcelHighlighterType
struct ExcelHighlighter

Define the default highlighter of a table when using the Excel back end.

Fields

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature f(h, data, i, j) in which h is the highlighter. This function must return a Vector{ExcelPair} with the styling attributes to apply to the highlighted cell.

Remarks

An Excel highlighter can be constructed using the following helpers:

ExcelHighlighter(f::Function, decoration::ExcelPair)
ExcelHighlighter(f::Function, decoration::Vector{ExcelPair})
ExcelHighlighter(f::Function, fd::Function)

The decoration is a flat Vector{ExcelPair} (same format as ExcelTableStyle fields). Font attributes are passed directly; fill attributes use the "cell_fill_" key prefix (the prefix is stripped before calling XLSX.setFill). Border attributes are not supported in highlighters.

For example, to highlight cells in column 3 with a value greater than 10 in red bold, cells with value 0 in green with a solid fill, and cells in column 4 greater than 10 in blue:

highlighters = [
    ExcelHighlighter((data, i, j) -> (j == 3) && (data[i, j] > 10), [
        "color" => "red", "bold" => "true",
        "cell_fill_pattern" => "solid", "cell_fill_fgColor" => "grey90",
    ]),
    ExcelHighlighter((data, i, j) -> (data[i, j] ≈ 0.0),
        ["color" => "green", "bold" => "true"],
    ),
    ExcelHighlighter((data, i, j) -> (j == 4) && (data[i, j] > 10),
        ["color" => "blue", "bold" => "true"],
    ),
]

The following helpers create the decoration from a Face of StyledStrings.jl, converted with excel_decoration, from a Crayon, converted to the equivalent face, or from the keywords of Face and Crayon (see Highlighter):

ExcelHighlighter(f::Function, face::Face)

ExcelHighlighter(f::Function, crayon::Crayon)

ExcelHighlighter(f::Function; kwargs...)
source
PrettyTables.ExcelTableBordersType
struct ExcelTableBorders

Define the border styles for each line type used when printing a table with the Excel back end. All fields are Vector{ExcelPair} compatible with the XLSX.setBorder function.

Fields

Horizontal Lines

  • top_line::Vector{ExcelPair}: Style for the top border of the table. (Default: ["style" => "thick", "color" => "Black"])
  • header_line::Vector{ExcelPair}: Style for the line drawn under the column label section. (Default: ["style" => "medium", "color" => "Black"])
  • merged_header_cell_line::Vector{ExcelPair}: Style for the line below merged header cells. (Default: ["style" => "thin", "color" => "Black"])
  • middle_line::Vector{ExcelPair}: Style for all other internal horizontal lines (data row underlines, lines around row groups, lines around summary rows) and for vertical lines between data columns. (Default: ["style" => "thin", "color" => "Black"])
  • bottom_line::Vector{ExcelPair}: Style for the bottom border of the table. (Default: ["style" => "thick", "color" => "Black"])

Vertical Lines

  • left_line::Vector{ExcelPair}: Style for the left border of the table. (Default: ["style" => "thick", "color" => "Black"])
  • center_line::Vector{ExcelPair}: Style for structural vertical lines (after the row number column and after the row label column). (Default: ["style" => "thin", "color" => "Black"])
  • right_line::Vector{ExcelPair}: Style for the right border of the table. (Default: ["style" => "thick", "color" => "Black"])
source
PrettyTables.ExcelTableFormatType
struct ExcelTableFormat

Define the table borders that will be used to form the Excel table.

Fields

  • borders::ExcelTableBorders: Border style configuration for all line types.
  • horizontal_line_at_beginning::Bool: Whether to draw a horizontal line at the first table row after the title/subtitle section (i.e., the top of the column labels or the first data row if there are no column labels). Title and subtitle rows are never bordered.
  • horizontal_line_after_column_labels::Bool: Whether to draw a line under the column header section.
  • horizontal_line_between_column_labels::Bool: Whether to draw a line between (unmerged) column header rows.
  • horizontal_line_at_merged_column_labels::Bool: Whether to draw a line under merged column headers. The default is true, whereas the text back end defaults to false.
  • horizontal_lines_at_data_rows::Union{Symbol, Vector{Int}}: Controls which data rows get an underline. :all draws a line after every data row; :none draws none; a Vector{Int} draws a line only after the listed row indices.
  • horizontal_line_after_data_rows::Bool: Whether to draw a line under the data table section.
  • horizontal_line_before_row_group_label::Bool: Whether to draw a line above each row group divider.
  • horizontal_line_after_row_group_label::Bool: Whether to draw a line below each row group divider.
  • horizontal_line_before_summary_rows::Bool: Whether to draw a line between the data rows and the summary rows.
  • horizontal_line_after_summary_rows::Bool: Whether to draw a line under the last summary row.
  • vertical_line_at_beginning::Bool: Whether to draw a vertical line at the left side of the table (spanning only the content rows, not title/subtitle or footnotes).
  • vertical_line_after_row_number_column::Bool: Whether to draw a vertical line to the right of the row number column.
  • vertical_line_after_row_label_column::Bool: Whether to draw a vertical line to the right of the row label column.
  • vertical_lines_at_data_columns::Union{Symbol, Vector{Int}}: Controls which data columns get a right-side divider. :all draws after every data column; :none draws none; a Vector{Int} draws only after the listed column indices.
  • vertical_line_after_data_columns::Bool: Whether to draw a vertical line after the last data column (spanning only the content rows, not title/subtitle or footnotes).
  • vertical_line_after_continuation_column::Bool: If true, a vertical line will be drawn after the continuation column.
source
PrettyTables.ExcelTableStyleType
struct ExcelTableStyle

Define the style (font and cell attributes) of each of the table elements used with the Excel back end.

Fields

  • title::Vector{ExcelPair}: Style for the title.
  • subtitle::Vector{ExcelPair}: Style for the subtitle.
  • row_number_label::Vector{ExcelPair}: Style for the row number label.
  • row_number::Vector{ExcelPair}: Style for the row number.
  • stubhead_label::Vector{ExcelPair}: Style for the stubhead label.
  • row_label::Vector{ExcelPair}: Style for the row label.
  • row_group_label::Vector{ExcelPair}: Style for the row group label.
  • first_line_column_label::Union{Vector{ExcelPair}, Vector{Vector{ExcelPair}}}: Style for the first line of the column labels. If a vector of Vector{ExcelPair} is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{Vector{ExcelPair}, Vector{Vector{ExcelPair}}}: Style for the rest of the column labels. If a vector of Vector{ExcelPair} is provided, each column label will use the corresponding style.
  • first_line_merged_column_label::Vector{ExcelPair}: Style for the merged cells at the first column label line.
  • merged_column_label::Vector{ExcelPair}: Style for the merged cells at the rest of the column labels.
  • data_cell::Vector{ExcelPair}: Style for the table cells.
  • summary_row_label::Vector{ExcelPair}: Style for the summary row label.
  • summary_row_cell::Vector{ExcelPair}: Style for the summary row cell.
  • footnote::Vector{ExcelPair}: Style for the footnotes.
  • source_note::Vector{ExcelPair}: Style for the source notes.

Remarks

Each field corresponds to a table element and should be a vector of ExcelPair, i.e. Pair{String, String}, describing properties and values compatible with the XLSX.setFont function. We can also define properties to be applied to the cell itself with the function XLSX.setFill. In this case, prefix the parameter name with "cell_fill_" (e.g., "cell_fill_pattern" => "solid").

It is only necessary to define those fields for which the default style needs to be overwritten. For example:

Examples

style = ExcelTableStyle(
    column_label                   = [["bold" => "true"], ["color" => "red"]], # assuming two columns
    summary_row_label              = ["size" => "8"],
    first_line_merged_column_label = ["bold" => "true", "color" => "orange"],
    footnote                       = ["italic" => "true", "color" => "cyan"],
    row_group_label                = ["bold" => "true", "color" => "magenta"],
    subtitle                       = ["italic" => "true"],
    title                          = ["bold" => "true", "color" => "orange", "size" => "18", "under" => "single"],
)

Constructor

ExcelTableStyle(; kwargs...)

Create a style in which each field can be passed as a keyword. Every keyword also accepts a Face (or a Crayon, converted to the equivalent face), which is converted with excel_decoration. The keywords first_line_column_label and column_label also accept a vector with one decoration (Excel attributes or Face) per column.

source
PrettyTables.HighlighterType
struct Highlighter <: AbstractHighlighter

Highlighter defined by a Face of StyledStrings.jl, which can be used with every back end.

Fields

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature fd(h, data, i, j) in which h is the highlighter. This function must return the Face to be applied to the cell that must be highlighted. It can also return the native decoration of the back end that is printing the table (a Crayon for the text back end, CSS properties for the HTML back end, and so on).
  • _decoration::Face: The Face to be applied to the highlighted cell if the default fd is used.

Remarks

This structure can be constructed using the following helpers:

Highlighter(f::Function; kwargs...)

where it will construct a Face using the keywords in kwargs and apply it to the highlighted cell. The keywords can be the ones of Face (weight, slant, foreground, background, underline, strikethrough, inverse, ...) or the ones of Crayon (bold, faint, italics, negative, foreground, background, underline, strikethrough), which are translated to the equivalent face attributes,

Highlighter(f::Function, face::Face)
Highlighter(f::Function, crayon::Crayon)

where it will apply the face (or the crayon, converted to a face) to the highlighted cell, and

Highlighter(f::Function, fd::Function)

where it will apply the decoration returned by the function fd to the highlighted cell.

Each back end converts this highlighter to its native highlighter once per printed table, converting the face with html_decoration, latex_decoration, markdown_decoration, typst_decoration, or excel_decoration. The text back end renders the face using its escape sequence.

Examples

julia> hl = Highlighter((data, i, j) -> data[i, j] > 5, Face(; weight = :bold, foreground = :red));

julia> pretty_table([1 10; 3 7]; highlighters = [hl])

julia> pretty_table([1 10; 3 7]; backend = :html, highlighters = [hl])
source
PrettyTables.HtmlHighlighterType
struct HtmlHighlighter

Define the default highlighter of a table when using the HTML back end.

Fields

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature f(h, data, i, j) in which h is the highlighter. This function must return a Vector{Pair{String, String}} with properties compatible with the style field that will be applied to the highlighted cell.

Remarks

This structure can be constructed using the following helpers:

HtmlHighlighter(f::Function, decoration::HtmlPair)

HtmlHighlighter(f::Function, decoration::Vector{HtmlPair})

HtmlHighlighter(f::Function, fd::Function)

The first two apply a fixed decoration to the highlighted cell, whereas the third lets the user select the desired decoration by specifying the function fd.

The following helpers create the decoration from a Face of StyledStrings.jl, converted with html_decoration, from a Crayon, converted to the equivalent face, or from the keywords of Face and Crayon (see Highlighter):

HtmlHighlighter(f::Function, face::Face)

HtmlHighlighter(f::Function, crayon::Crayon)

HtmlHighlighter(f::Function; kwargs...)
source
PrettyTables.HtmlPairType
const HtmlPair = Pair{String, String}

Pair with a CSS property and its value, which is the native decoration of the HTML back end (for example, "font-weight" => "bold").

source
PrettyTables.HtmlTableBordersType
struct HtmlTableBorders

Define the borders of a table printed with the HTML back end. All fields are strings with a CSS border shorthand value (e.g., "1px dashed #0000ff").

Fields

Horizontal Lines

  • top_line::String: Border at the top of the table. (Default: "2px solid black")
  • header_line::String: Border of the lines surrounding the column labels. (Default: "1px solid black")
  • merged_header_cell_line::String: Border below merged column label cells. (Default: "1px solid black")
  • middle_line::String: Border of horizontal lines inside the table body. (Default: "1px solid black")
  • bottom_line::String: Border at the bottom of the table. (Default: "2px solid black")

Vertical Lines

  • left_line::String: Border at the left of the table. (Default: "2px solid black")
  • center_line::String: Border of vertical lines inside the table body. (Default: "1px solid black")
  • right_line::String: Border at the right of the table. (Default: "2px solid black")
source
PrettyTables.HtmlTableFormatType
struct HtmlTableFormat

Define the format of the tables printed with the HTML back end.

Fields

  • css::String: CSS to be injected at the end of the <style> section. Notice that this field is only applied if stand_alone = true.
  • table_width::String: Table width. Notice that this field is only applied if stand_alone = true.
  • borders::HtmlTableBorders: Format of the borders. The borders are emitted as inline styles in the table elements. Hence, they are applied in any rendering mode.
  • horizontal_line_at_beginning::Bool: If true, a horizontal line will be drawn at the beginning of the table.
  • horizontal_line_before_column_labels::Bool: If true, a horizontal line will be drawn before the column labels when the table has a title or subtitle. (HTML back end only)
  • horizontal_line_after_column_labels::Bool: If true, a horizontal line will be drawn after the column labels.
  • horizontal_line_at_merged_column_labels::Bool: If true, a horizontal line will be drawn at the bottom of the merged column labels.
  • horizontal_lines_at_data_rows::Union{Symbol, Vector{Int}}: A horizontal line will be drawn after each data row index listed in this vector. If the symbol :all is passed, a horizontal line will be drawn after every data row. If the symbol :none is passed, no horizontal lines will be drawn after the data rows.
  • horizontal_line_before_row_group_label::Bool: If true, a horizontal line will be drawn before the row group label.
  • horizontal_line_after_row_group_label::Bool: If true, a horizontal line will be drawn after the row group label.
  • horizontal_line_after_data_rows::Bool: If true, a horizontal line will be drawn after the data rows.
  • horizontal_line_before_summary_rows::Bool: If true, a horizontal line will be drawn before the summary rows. Notice that this line is the same as the one drawn if horizontal_line_after_data_rows is true. However, in this case, the line is omitted if there are no summary rows.
  • horizontal_line_after_summary_rows::Bool: If true, a horizontal line will be drawn after the summary rows.
  • horizontal_line_after_footnotes::Bool: If true, a horizontal line will be drawn after the footnotes when the table also has source notes. (HTML back end only)
  • horizontal_line_at_end::Bool: If true, a horizontal line will be drawn at the end of the table, i.e. after the last summary row or the last data row and before the footnotes and source notes, even when horizontal_line_after_data_rows and horizontal_line_after_summary_rows are false. (HTML back end only)
  • vertical_line_at_beginning::Bool: If true, a vertical line will be drawn at the beginning of the table.
  • vertical_line_after_row_number_column::Bool: If true, a vertical line will be drawn after the row number column.
  • vertical_line_after_row_label_column::Bool: If true, a vertical line will be drawn after the row label column.
  • vertical_lines_at_data_columns::Union{Symbol, Vector{Int}}: A vertical line will be drawn after each data column index listed in this vector. If the symbol :all is passed, a vertical line will be drawn after every data column. If the symbol :none is passed, no vertical lines will be drawn after the data columns.
  • vertical_line_after_data_columns::Bool: If true, a vertical line will be drawn after the data columns.
  • vertical_line_after_continuation_column::Bool: If true, a vertical line will be drawn after the continuation column.

Remarks

By default, the HTML back end draws no lines: every line presence field defaults to false (or :none), and the emitted code has no border decoration. Hence, the table appearance can be fully customized with CSS. The fields above (or the backend-agnostic TableFormat) can be used to draw lines as inline styles, which are applied in any rendering mode.

The horizontal line at the beginning of the table is emitted as an inline border of the <table> element, the other horizontal lines (including the line at the end of the table) are emitted as inline borders of the <tr> elements, and the vertical lines are emitted as inline borders of the <col> elements, except for the line under a merged column label, which is a border of the cell. Since the table borders are collapsed, those borders are applied to the edges of every cell of the row or column. When two lines meet at the same edge (for example, the line after the data rows and the line before the summary rows), the CSS border-collapsing rules select the wider border, and then the border with the higher style precedence.

As in the text back end, the footnotes and source notes are outside the ruled area: the line at the end of the table is drawn before them, and the vertical lines at the edges of the table are hidden in their cells. Also as in the other back ends, the line drawn after the last row of the ruled area by horizontal_line_after_summary_rows, horizontal_line_after_data_rows (if the table has no summary rows), or horizontal_line_after_column_labels (if the table has no rows) uses the bottom line style instead of the middle or header one, whereas the lines selected by horizontal_lines_at_data_rows are internal and always use the middle line style.

source
PrettyTables.HtmlTableStyleType
struct HtmlTableStyle

Define the style of the tables printed with the HTML back end.

Fields

  • top_left_string::Vector{HtmlPair}: Style for the top left string.
  • top_right_string::Vector{HtmlPair}: Style for the top right string.
  • table::Vector{HtmlPair}: Style for the table.
  • title::Vector{HtmlPair}: Style for the title.
  • subtitle::Vector{HtmlPair}: Style for the subtitle.
  • row_number_label::Vector{HtmlPair}: Style for the row number label.
  • row_number::Vector{HtmlPair}: Style for the row number.
  • stubhead_label::Vector{HtmlPair}: Style for the stubhead label.
  • row_label::Vector{HtmlPair}: Style for the row label.
  • row_group_label::Vector{HtmlPair}: Style for the row group label.
  • first_line_column_label::Union{Vector{HtmlPair}, Vector{Vector{HtmlPair}}}: Style for the first line of the column labels. If a vector of Vector{HtmlPair} is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{Vector{HtmlPair}, Vector{Vector{HtmlPair}}}: Style for the rest of the column labels. If a vector of Vector{HtmlPair} is provided, each column label will use the corresponding style.
  • first_line_merged_column_label::Vector{HtmlPair}: Style for the merged cells at the first column label line.
  • merged_column_label::Vector{HtmlPair}: Style for the merged cells at the rest of the column labels.
  • summary_row_cell::Vector{HtmlPair}: Style for the summary row cell.
  • summary_row_label::Vector{HtmlPair}: Style for the summary row label.
  • footnote::Vector{HtmlPair}: Style for the footnote.
  • source_note::Vector{HtmlPair}: Style for the source notes.

Constructor

HtmlTableStyle(; kwargs...)

Create a style in which each field can be passed as a keyword. Every keyword also accepts a Face (or a Crayon, converted to the equivalent face), which is converted with html_decoration. The keywords first_line_column_label and column_label also accept a vector with one decoration (CSS properties or Face) per column.

source
PrettyTables.LatexEnvironmentsType
const LatexEnvironments = Vector{String}

Vector with the LaTeX environments applied to a cell, which is the native decoration of the LaTeX back end (for example, ["textbf", "small"]).

source
PrettyTables.LatexHighlighterType
LatexHighlighter

Defines the default highlighter of a table when using the LaTeX backend.

Fields

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd: A function with the signature fd(h, data, i, j)::Vector{String} in which h is the highlighter object, data is the matrix, and (i, j) is the element position in the table. This function should return a vector with the LaTeX environments to be applied to the cell.

Remarks

This structure can be constructed using two helpers:

LatexHighlighter(f::Function, envs::Vector{String})

where it will apply recursively all the LaTeX environments in envs to the highlighted text, and

LatexHighlighter(f::Function, fd::Function)

where the user selects the desired decoration by specifying the function fd.

Thus, for example:

LatexHighlighter((data, i, j) -> true, ["textbf", "small"])

will wrap all the cells in the table in the following environment:

\small{\textbf{<Cell text>}}

Notice that the environments are applied in order, meaning that the last one in the vector ends up being the outermost.

The following helpers create the decoration from a Face of StyledStrings.jl, converted with latex_decoration, from a Crayon, converted to the equivalent face, or from the keywords of Face and Crayon (see Highlighter):

LatexHighlighter(f::Function, face::Face)

LatexHighlighter(f::Function, crayon::Crayon)

LatexHighlighter(f::Function; kwargs...)
source
PrettyTables.LatexTableBordersType
struct LatexTableBorders

Define the horizontal rules of a table printed with the LaTeX back end. All fields are strings with a LaTeX command. The vertical lines are drawn with the column specification of the table environment and cannot be customized here.

Fields

  • top_line::String: Rule at the top of the table. (Default: "\\hline")
  • header_line::String: Rule of the lines surrounding the column labels. (Default: "\\hline")
  • merged_header_cell_line::String: Command of the rule under merged column label cells, to which the back end appends the column range. (Default: "\\cline")
  • middle_line::String: Rule of the horizontal lines inside the table body. (Default: "\\hline")
  • bottom_line::String: Rule at the bottom of the table. (Default: "\\hline")
source
PrettyTables.LatexTableFormatType
struct LatexTableFormat

Define the format of the tables printed with the LaTeX back end.

Fields

  • borders::LatexTableBorders: Format of the borders.
  • horizontal_line_at_beginning::Bool: If true, a horizontal line will be drawn at the beginning of the table.
  • horizontal_line_at_merged_column_labels::Bool: If true, a horizontal line will be drawn at the bottom of the merged column labels using \cline. The default is true, whereas the text back end defaults to false.
  • horizontal_line_after_column_labels::Bool: If true, a horizontal line will be drawn after the column labels.
  • horizontal_lines_at_data_rows::Union{Symbol, Vector{Int}}: A horizontal line will be drawn after each data row index listed in this vector. If the symbol :all is passed, a horizontal line will be drawn after every data row. If the symbol :none is passed, no horizontal lines will be drawn after the data rows.
  • horizontal_line_before_row_group_label::Bool: If true, a horizontal line will be drawn before the row group label.
  • horizontal_line_after_row_group_label::Bool: If true, a horizontal line will be drawn after the row group label.
  • horizontal_line_after_data_rows::Bool: If true, a horizontal line will be drawn after the data rows.
  • horizontal_line_before_summary_rows::Bool: If true, a horizontal line will be drawn before the summary rows. Notice that this line is the same as the one drawn if horizontal_line_after_data_rows is true. However, in this case, the line is omitted if there are no summary rows.
  • horizontal_line_after_summary_rows::Bool: If true, a horizontal line will be drawn after the summary rows.
  • vertical_line_at_beginning::Bool: If true, a vertical line will be drawn at the beginning of the table.
  • vertical_line_after_row_number_column::Bool: If true, a vertical line will be drawn after the row number column.
  • vertical_line_after_row_label_column::Bool: If true, a vertical line will be drawn after the row label column.
  • vertical_lines_at_data_columns::Union{Symbol, Vector{Int}}: A vertical line will be drawn after each data column index listed in this vector. If the symbol :all is passed, a vertical line will be drawn after every data row. If the symbol :none is passed, no vertical lines will be drawn after the data columns.
  • vertical_line_after_data_columns::Bool: If true, a vertical line will be drawn after the data columns.
  • vertical_line_after_continuation_column::Bool: If true, a vertical line will be drawn after the continuation column.
source
PrettyTables.LatexTableStyleType
struct LatexTableStyle

Define the style of the tables printed with the latex back end.

Fields

  • title::LatexEnvironments: Latex environments with the style for the title.
  • subtitle::LatexEnvironments: Latex environments with the style for the subtitle.
  • row_number_label::LatexEnvironments: Latex environments with the style for the row number label.
  • row_number::LatexEnvironments: Latex environments with the style for the row numbers.
  • stubhead_label::LatexEnvironments: Latex environments with the style for the stubhead label.
  • row_label::LatexEnvironments: Latex environments with the style for the row labels.
  • row_group_label::LatexEnvironments: Latex environments with the style for the row group label.
  • first_line_column_label::Union{LatexEnvironments, Vector{LatexEnvironments}}: Latex environments with the style for the first line of the column labels. If a vector of LatexEnvironments is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{LatexEnvironments, Vector{LatexEnvironments}}: Latex environments with the style for the rest of the column labels. If a vector of LatexEnvironments is provided, each column label will use the corresponding style.
  • first_line_merged_column_label::LatexEnvironments: Latex environments with the style for the merged cells at the first column label line.
  • merged_column_label::LatexEnvironments: Latex environments with the style for the merged cells at the rest of the column labels.
  • summary_row_cell::LatexEnvironments: Latex environments with the style for the summary row cell.
  • summary_row_label::LatexEnvironments: Latex environments with the style for the summary row label.
  • footnote::LatexEnvironments: Latex environments with the style for the footnotes.
  • source_note::LatexEnvironments: Latex environments with the style for the source notes.
  • omitted_cell_summary::LatexEnvironments: Latex environments with the style for the omitted cell summary.

Constructor

LatexTableStyle(; kwargs...)

Create a style in which each field can be passed as a keyword. Every keyword also accepts a Face (or a Crayon, converted to the equivalent face), which is converted with latex_decoration. The keywords first_line_column_label and column_label also accept a vector with one decoration (LaTeX environments or Face) per column.

source
PrettyTables.LineStyleType
struct LineStyle

Describe the design of a table line independently from the back end, including its style, width, and color. Every field set to nothing means that the back end default for that aspect of the line must be kept.

Each back end converts this object to its native line design using the same approach as the conversion of Face to decorations. The conversion is a best effort: aspects a back end cannot express are silently ignored (for example, the LaTeX back end ignores width and color, and the text back end maps the designs to the available box-drawing characters).

Fields

  • style::Union{Nothing, Symbol}: Line style: :solid, :dashed, :dotted, or :double. (Default: nothing)
  • width::Union{Nothing, Symbol}: Line width: :thin, :medium, or :thick. (Default: nothing)
  • color::Union{Nothing, SimpleColor}: Line color. The keyword constructor also accepts a Symbol with a named color, an UInt32 with a 24-bit color, a string like "#rrggbb", or a tuple (r, g, b) of integers, all normalized to SimpleColor. (Default: nothing)
source
PrettyTables.LineStyleMethod
LineStyle(; kwargs...) -> LineStyle
LineStyle(style, width, color) -> LineStyle

Create a LineStyle from the keywords (or the positional arguments) style, width, and color, validating the values and normalizing color to SimpleColor. The function throws an ArgumentError if style or width is not supported, or if color cannot be converted to a color.

Keywords

  • style::Union{Nothing, Symbol}: Line style: :solid, :dashed, :dotted, or :double. (Default: nothing)
  • width::Union{Nothing, Symbol}: Line width: :thin, :medium, or :thick. (Default: nothing)
  • color::Any: Line color as a SimpleColor, a Symbol with a named color, an UInt32 with a 24-bit color, a string like "#rrggbb", or a tuple (r, g, b) of integers. (Default: nothing)
source
PrettyTables.MarkdownHighlighterType
struct MarkdownHighlighter

Defines the default highlighter of a table when using the markdown backend.

Fields

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature fd(h, data, i, j) in which h is the highlighter. This function must return the MarkdownStyle to be applied to the cell that must be highlighted.

Remarks

This structure can be constructed using two helpers:

MarkdownHighlighter(f::Function, decoration::MarkdownStyle)

MarkdownHighlighter(f::Function, fd::Function)

The first will apply a fixed decoration to the highlighted cell specified in decoration whereas the second lets the user select the desired decoration by specifying the function fd.

The following helpers create the decoration from a Face of StyledStrings.jl, converted with markdown_decoration, from a Crayon, converted to the equivalent face, or from the keywords of Face and Crayon (see Highlighter):

MarkdownHighlighter(f::Function, face::Face)

MarkdownHighlighter(f::Function, crayon::Crayon)

MarkdownHighlighter(f::Function; kwargs...)
source
PrettyTables.MarkdownStyleType
struct MarkdownStyle

Structure that defines styling parameters to a table cell in the markdown back end.

Fields

  • bold::Bool: Bold text.
  • italic::Bool: Italic text.
  • strikethrough::Bool: Strikethrough.
  • code::Bool: Code.
source
PrettyTables.MarkdownTableFormatType
struct MarkdownTableFormat

Define the format of the tables printed with the markdown back end.

Fields

  • title_heading_level::Int: Title heading level.
  • subtitle_heading_level::Int: Subtitle heading level.
  • horizontal_line_char::Char: Character used to draw the horizontal line.
  • line_before_summary_rows::Bool: Whether to draw a line before the summary rows.
  • compact_table::Bool: If true, the table is printed in a compact format without extra spaces between columns.
source
PrettyTables.MarkdownTableStyleType
struct MarkdownTableStyle

Define the style of the tables printed with the markdown back end.

Fields

  • row_number_label::MarkdownStyle: Style for the row number label.
  • row_number::MarkdownStyle: Style for the row number.
  • stubhead_label::MarkdownStyle: Style for the stubhead label.
  • row_label::MarkdownStyle: Style for the row label.
  • row_group_label::MarkdownStyle: Style for the row group label.
  • first_line_column_label::Union{MarkdownStyle, Vector{MarkdownStyle}}: Style for the first line of the column label. If a vector of MarkdownStyle is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{MarkdownStyle, Vector{MarkdownStyle}}: Style for the column label. If a vector of MarkdownStyle is provided, each column label will use the corresponding style.
  • summary_row_label::MarkdownStyle: Style for the summary row label.
  • summary_row_cell::MarkdownStyle: Style for the summary row cell.
  • footnote::MarkdownStyle: Style for the footnote.
  • source_note::MarkdownStyle: Style for the source note.
  • omitted_cell_summary::MarkdownStyle: Style for the omitted cell summary.

Constructor

MarkdownTableStyle(; kwargs...)

Create a style in which each field can be passed as a keyword. Every keyword also accepts a Face (or a Crayon, converted to the equivalent face), which is converted with markdown_decoration. The keywords first_line_column_label and column_label also accept a vector with one decoration (MarkdownStyle or Face) per column.

source
PrettyTables.MultiColumnType
struct MultiColumn

Specification for merging columns at the column label rows.

Fields

  • column_span::Int: Number of columns to merge (must be greater than 1).
  • data::Any: Merged cell data.
  • alignment::Symbol: Merge cell alignment.
source
PrettyTables.PrettyTableType
mutable struct PrettyTable

This structure stores the data and configuration options required to print a table. The table to be displayed is specified by the data field, while any additional configuration options, corresponding to the keyword arguments accepted by the pretty_table function, can be set as fields with matching names.

Users can overload the show function to customize how the table is printed for different MIME types. PrettyTables.jl provides a default show method for printing tables to stdout.

Fields

  • data::Any: The table to be displayed.
  • configurations::Dict{Symbol, Any}: A dictionary containing configuration options for the table. The keys are symbols corresponding to the keyword arguments accepted by the pretty_table function, and the values are the corresponding settings. It is not recommended to add configurations here directly. Use the native Julia syntax to set fields in the PrettyTable object instead.

Extended Help

Examples

julia> pt = PrettyTable(ones(3, 3))
┌────────┬────────┬────────┐
│ Col. 1 │ Col. 2 │ Col. 3 │
├────────┼────────┼────────┤
│    1.0 │    1.0 │    1.0 │
│    1.0 │    1.0 │    1.0 │
│    1.0 │    1.0 │    1.0 │
└────────┴────────┴────────┘

julia> pt.table_format = TextTableFormat(; @text__no_vertical_lines)
TextTableFormat(TextTableBorders('┐', '┌', '└', '┘', '┬', '├', '┤', '┼', '┴', '│', '─'), true, :none, false, true, :none, true, true, true, true, true, false, false, false, :none, false, false, true, 0, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing)

julia> pt
────────────────────────
 Col. 1  Col. 2  Col. 3
────────────────────────
    1.0     1.0     1.0
    1.0     1.0     1.0
    1.0     1.0     1.0
────────────────────────

julia> pt.data = 2 .* ones(3, 3)
3×3 Matrix{Float64}:
 2.0  2.0  2.0
 2.0  2.0  2.0
 2.0  2.0  2.0

julia> pt
────────────────────────
 Col. 1  Col. 2  Col. 3
────────────────────────
    2.0     2.0     2.0
    2.0     2.0     2.0
    2.0     2.0     2.0
────────────────────────
source
PrettyTables.TableFormatType
struct TableFormat

Describe the table lines (presence and design) independently from the back end. This object can be passed to the keyword table_format of pretty_table with any back end, allowing the user to switch back ends without rewriting the line configuration.

Every field set to nothing keeps the default behavior of the selected back end. Hence, a TableFormat never replaces the back end table format entirely: each set field overrides only the corresponding field of the back end default format. For example, leaving horizontal_line_at_merged_column_labels as nothing keeps the default of each back end (false in the text and HTML back ends and true in the LaTeX and Typst back ends).

Notice that nothing differs from :none in the fields that accept a Symbol: nothing keeps the back end default, whereas :none explicitly disables the lines.

The conversion to the back end native format is a best effort: the manual page Table Format describes which fields each back end honors. In particular, the Markdown back end only supports horizontal_line_before_summary_rows.

Fields

Line Design

Each field below describes the design of one line role using a LineStyle:

  • top_line::Union{Nothing, LineStyle}: Line at the top of the table. (Default: nothing)
  • header_line::Union{Nothing, LineStyle}: Line after the column labels. (Default: nothing)
  • merged_header_cell_line::Union{Nothing, LineStyle}: Line under merged column label cells. (Default: nothing)
  • middle_line::Union{Nothing, LineStyle}: Lines drawn inside the table body. (Default: nothing)
  • bottom_line::Union{Nothing, LineStyle}: Line at the bottom of the table. (Default: nothing)
  • left_line::Union{Nothing, LineStyle}: Line at the left of the table. (Default: nothing)
  • center_line::Union{Nothing, LineStyle}: Vertical lines drawn inside the table body. (Default: nothing)
  • right_line::Union{Nothing, LineStyle}: Line at the right of the table. (Default: nothing)

Line Presence

  • horizontal_line_at_beginning::Union{Nothing, Bool}: Whether to draw a horizontal line at the beginning of the table. (Default: nothing)
  • horizontal_line_before_column_labels::Union{Nothing, Bool}: Whether to draw a horizontal line before the column labels when the table has a title or subtitle. This field is only honored by the HTML back end, which places the title inside the ruled area. (Default: nothing)
  • horizontal_line_after_column_labels::Union{Nothing, Bool}: Whether to draw a horizontal line after the column labels. (Default: nothing)
  • horizontal_line_at_merged_column_labels::Union{Nothing, Bool}: Whether to draw a horizontal line under the merged column label cells. (Default: nothing)
  • horizontal_lines_at_data_rows::Union{Nothing, Symbol, Vector{Int}}: Data rows after which a horizontal line must be drawn: :all, :none, or a vector of row indices. (Default: nothing)
  • horizontal_line_before_row_group_label::Union{Nothing, Bool}: Whether to draw a horizontal line before the row group labels. (Default: nothing)
  • horizontal_line_after_row_group_label::Union{Nothing, Bool}: Whether to draw a horizontal line after the row group labels. (Default: nothing)
  • horizontal_line_after_data_rows::Union{Nothing, Bool}: Whether to draw a horizontal line after the data rows. (Default: nothing)
  • horizontal_line_before_summary_rows::Union{Nothing, Bool}: Whether to draw a horizontal line before the summary rows. (Default: nothing)
  • horizontal_line_after_summary_rows::Union{Nothing, Bool}: Whether to draw a horizontal line after the summary rows. (Default: nothing)
  • horizontal_line_after_footnotes::Union{Nothing, Bool}: Whether to draw a horizontal line after the footnotes. This field is only honored by the HTML back end. (Default: nothing)
  • horizontal_line_at_end::Union{Nothing, Bool}: Whether to draw a horizontal line at the end of the table, after the last summary row or the last data row and before the footnotes and source notes, even when horizontal_line_after_data_rows and horizontal_line_after_summary_rows are false. This field is only honored by the HTML back end. (Default: nothing)
  • vertical_line_at_beginning::Union{Nothing, Bool}: Whether to draw a vertical line at the beginning of the table. (Default: nothing)
  • vertical_line_after_row_number_column::Union{Nothing, Bool}: Whether to draw a vertical line after the row number column. (Default: nothing)
  • vertical_line_after_row_label_column::Union{Nothing, Bool}: Whether to draw a vertical line after the row label column. (Default: nothing)
  • vertical_lines_at_data_columns::Union{Nothing, Symbol, Vector{Int}}: Data columns after which a vertical line must be drawn: :all, :none, or a vector of column indices. (Default: nothing)
  • vertical_line_after_data_columns::Union{Nothing, Bool}: Whether to draw a vertical line after the data columns. (Default: nothing)
  • vertical_line_after_continuation_column::Union{Nothing, Bool}: Whether to draw a vertical line after the continuation column. (Default: nothing)
source
PrettyTables.TableStyleType
struct TableStyle

Describe the table decorations independently from the back end using Face objects. This object can be passed to the keyword style of pretty_table with any back end, allowing the user to switch back ends without rewriting the style configuration. Whereas the table format states how the table is printed, the table style states how it is decorated. The keyword constructor also accepts crayons, which are converted to the equivalent faces.

Every field set to nothing keeps the default decoration of the selected back end. Hence, a TableStyle never replaces the back end table style entirely: each set field overrides only the corresponding field of the back end default style. The faces are converted to the native decorations by the keyword constructors of the back end style types (see html_decoration, latex_decoration, markdown_decoration, typst_decoration, and excel_decoration).

The conversion is a best effort: the Markdown back end ignores title, subtitle, first_line_merged_column_label, and merged_column_label because its style type does not have those fields. The backend-specific style fields (for example, table_border of the text back end and data_cell of the Excel back end) are not part of TableStyle and remain available in the native table styles.

Fields

  • title::Union{Nothing, Face}: Face of the title. (Default: nothing)
  • subtitle::Union{Nothing, Face}: Face of the subtitle. (Default: nothing)
  • row_number_label::Union{Nothing, Face}: Face of the row number label. (Default: nothing)
  • row_number::Union{Nothing, Face}: Face of the row numbers. (Default: nothing)
  • stubhead_label::Union{Nothing, Face}: Face of the stubhead label. (Default: nothing)
  • row_label::Union{Nothing, Face}: Face of the row labels. (Default: nothing)
  • row_group_label::Union{Nothing, Face}: Face of the row group labels. (Default: nothing)
  • first_line_column_label::Union{Nothing, Face, Vector{Face}}: Face of the first column label line, or a vector with one face per column. (Default: nothing)
  • column_label::Union{Nothing, Face, Vector{Face}}: Face of the other column label lines, or a vector with one face per column. (Default: nothing)
  • first_line_merged_column_label::Union{Nothing, Face}: Face of the merged cells at the first column label line. (Default: nothing)
  • merged_column_label::Union{Nothing, Face}: Face of the merged cells at the other column label lines. (Default: nothing)
  • summary_row_label::Union{Nothing, Face}: Face of the summary row labels. (Default: nothing)
  • summary_row_cell::Union{Nothing, Face}: Face of the summary row cells. (Default: nothing)
  • footnote::Union{Nothing, Face}: Face of the footnotes. (Default: nothing)
  • source_note::Union{Nothing, Face}: Face of the source notes. (Default: nothing)
source
PrettyTables.TableStyleMethod
TableStyle(; kwargs...) -> TableStyle

Create a TableStyle in which each field can be passed as a keyword. Every keyword accepts a Face or a Crayon, which is converted to the equivalent face. The keywords first_line_column_label and column_label also accept a vector of faces or crayons.

source
PrettyTables.TextHighlighterType
struct TextHighlighter <: AbstractHighlighter

Defines the default highlighter of a table when using the text backend.

Fields

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature fd(h, data, i, j) in which h is the highlighter. This function must return the Face (or Crayon) to be applied to the cell that must be highlighted.

Remarks

This structure can be constructed using the following helpers:

TextHighlighter(f::Function; kwargs...)

where it will construct a Face using the keywords in kwargs and apply it to the highlighted cell. The keywords can be the ones of Face (weight, slant, foreground, background, underline, strikethrough, inverse, ...) or the ones of Crayon (bold, faint, italics, negative, foreground, background, underline, strikethrough), which are translated to the equivalent face attributes,

TextHighlighter(f::Function, face::Face)
TextHighlighter(f::Function, crayon::Crayon)

where it will apply the face (or the crayon, converted to a face) to the highlighted cell, and

TextHighlighter(f::Function, fd::Function)

where it will apply the Face (or Crayon) returned by the function fd to the highlighted cell.

source
PrettyTables.TextTableBordersType
struct TextTableBorders

Define the format of the borders in the tables printed with the text back end.

Fields

  • up_right_corner::Char: Character in the up right corner.
  • up_left_corner::Char: Character in the up left corner.
  • bottom_left_corner::Char: Character in the bottom left corner.
  • bottom_right_corner::Char: Character in the bottom right corner.
  • up_intersection::Char: Character in the intersection of lines in the up part.
  • left_intersection::Char: Character in the intersection of lines in the left part.
  • right_intersection::Char: Character in the intersection of lines in the right part.
  • middle_intersection::Char: Character in the intersection of lines in the middle of the table.
  • bottom_intersection::Char: Character in the intersection of the lines in the bottom part.
  • column::Char: Character in a vertical line inside the table.
  • row::Char: Character in a horizontal line inside the table.
source
PrettyTables.TextTableFormatType
struct TextTableFormat

Define the format of the tables printed with the text back end.

Fields

  • borders::TextTableBorders: Format of the borders.
  • horizontal_line_at_beginning::Bool: If true, a horizontal line will be drawn at the beginning of the table.
  • horizontal_lines_at_column_labels::Union{Symbol, Vector{Int}}: A horizontal line will be drawn after each column label row index listed in this vector. If the symbol :all is passed, a horizontal line will be drawn after every column label. If the symbol :none is passed, no horizontal lines will be drawn.
  • horizontal_line_at_merged_column_labels::Bool: If true, a horizontal line will be drawn at the merged column labels. Notice that the horizontal line drawn using the option horizontal_lines_at_column_labels has precedence over this one. The default is false, whereas the other back ends default to true.
  • horizontal_line_after_column_labels::Bool: If true, a horizontal line will be drawn after the column labels.
  • horizontal_lines_at_data_rows::Union{Symbol, Vector{Int}}: A horizontal line will be drawn after each data row index listed in this vector. If the symbol :all is passed, a horizontal line will be drawn after every data row. If the symbol :none is passed, no horizontal lines will be drawn.
  • horizontal_line_before_row_group_label::Bool: If true, a horizontal line will be drawn before the row group label.
  • horizontal_line_after_row_group_label::Bool: If true, a horizontal line will be drawn after the row group label.
  • horizontal_line_after_data_rows::Bool: If true, a horizontal line will be drawn after the data rows.
  • horizontal_line_before_summary_rows::Bool: If true, a horizontal line will be drawn before the summary rows. Notice that this line is the same as the one drawn if horizontal_line_after_data_rows is true. However, in this case, the line is omitted if there are no summary rows.
  • horizontal_line_after_summary_rows::Bool: If true, a horizontal line will be drawn after the summary rows.
  • vertical_line_at_beginning::Bool: If true, a vertical line will be drawn at the beginning of the table.
  • vertical_line_after_row_number_column::Bool: If true, a vertical line will be drawn after the row number column.
  • vertical_line_after_row_label_column::Bool: If true, a vertical line will be drawn after the row label column.
  • vertical_lines_at_data_columns::Union{Symbol, Vector{Int}}: A vertical line will be drawn after each data column index listed in this vector. If the symbol :all is passed, a vertical line will be drawn after every data column. If the symbol :none is passed, no vertical lines will be drawn after the data columns.
  • vertical_line_after_data_columns::Bool: If true, a vertical line will be drawn after the data columns.
  • vertical_line_after_continuation_column::Bool: If true, a vertical line will be drawn after the continuation column.
  • suppress_vertical_lines_at_column_labels::Bool: If true, the vertical lines inside the column label rows will be suppressed.
  • ellipsis_line_skip::Int: Number of lines to skip when printing an ellipsis.
  • top_line::Union{Nothing, TextTableLine}: Characters of the top line.
  • header_line::Union{Nothing, TextTableLine}: Characters of the lines at the column labels.
  • merged_header_cell_line::Union{Nothing, TextTableLine}: Characters of the lines under the merged column labels.
  • middle_line::Union{Nothing, TextTableLine}: Characters of the lines inside the table.
  • bottom_line::Union{Nothing, TextTableLine}: Characters of the bottom line.
  • left_line::Union{Nothing, Char}: Character of the vertical line at the left of the table.
  • center_line::Union{Nothing, Char}: Character of the vertical lines inside the table.
  • right_line::Union{Nothing, Char}: Character of the vertical line at the right of the table.

Line Characters

The line character fields allow the user to customize the characters of each table line independently. The horizontal line fields accept a TextTableLine, whereas the vertical line fields accept a Char. Every field, and every character inside a TextTableLine, defaults to nothing, meaning that the corresponding character in borders is used. Hence, those fields sparsely override the characters in borders for a single line.

The color of each line can be configured with the line faces of TextTableStyle.

source
PrettyTables.TextTableLineType
struct TextTableLine

Define the characters of a single horizontal line in the tables printed with the text back end. Every field defaults to nothing, meaning that the corresponding character in the field borders of TextTableFormat is used. Hence, this object sparsely overrides the characters of a single line.

Fields

  • up_right_corner::Union{Nothing, Char}: Character in the up right corner.
  • up_left_corner::Union{Nothing, Char}: Character in the up left corner.
  • bottom_left_corner::Union{Nothing, Char}: Character in the bottom left corner.
  • bottom_right_corner::Union{Nothing, Char}: Character in the bottom right corner.
  • up_intersection::Union{Nothing, Char}: Character in the intersection of lines in the up part.
  • left_intersection::Union{Nothing, Char}: Character in the intersection of lines in the left part.
  • right_intersection::Union{Nothing, Char}: Character in the intersection of lines in the right part.
  • middle_intersection::Union{Nothing, Char}: Character in the intersection of lines in the middle of the table.
  • bottom_intersection::Union{Nothing, Char}: Character in the intersection of the lines in the bottom part.
  • row::Union{Nothing, Char}: Character in the horizontal line.
source
PrettyTables.TextTableStyleType
struct TextTableStyle

Define the style of the tables printed with the text back end.

Fields

  • title::Face: Face with the style for the title.
  • subtitle::Face: Face with the style for the subtitle.
  • row_number_label::Face: Face with the style for the row number label.
  • row_number::Face: Face with the style for the row numbers.
  • stubhead_label::Face: Face with the style for the stubhead label.
  • row_label::Face: Face with the style for the row labels.
  • row_group_label::Face: Face with the style for the row group label.
  • first_line_column_label::Union{Face, Vector{Face}}: Face or faces with the style for the first column label lines. If a vector of faces is passed, it must have the same length as the number of columns in the table.
  • column_label::Union{Face, Vector{Face}}: Face or faces with the style for the rest of the column labels. If a vector of faces is passed, it must have the same length as the number of columns in the table.
  • first_line_merged_column_label::Face: Face with the style for the merged cells at the first column label line.
  • merged_column_label::Face: Face with the style for the merged cells at the rest of the column labels.
  • summary_row_cell::Face: Face with the style for the summary row cell.
  • summary_row_label::Face: Face with the style for the summary row label.
  • footnote::Face: Face with the style for the footnotes.
  • source_note::Face: Face with the style for the source notes.
  • omitted_cell_summary::Face: Face with the style for the omitted cell summary.
  • table_border::Face: Face with the style for the table border.
  • top_line::Union{Nothing, Face}: Face with the style for the top line.
  • header_line::Union{Nothing, Face}: Face with the style for the lines at the column labels.
  • merged_header_cell_line::Union{Nothing, Face}: Face with the style for the lines under the merged column labels.
  • middle_line::Union{Nothing, Face}: Face with the style for the lines inside the table.
  • bottom_line::Union{Nothing, Face}: Face with the style for the bottom line.
  • left_line::Union{Nothing, Face}: Face with the style for the vertical line at the left of the table.
  • center_line::Union{Nothing, Face}: Face with the style for the vertical lines inside the table.
  • right_line::Union{Nothing, Face}: Face with the style for the vertical line at the right of the table.

The line faces default to nothing, meaning that the corresponding line is rendered with the face in table_border. When printing with the backend-agnostic TableFormat, the color of each line design is converted to the corresponding line face, unless the line face is explicitly set, which has the highest precedence.

Constructor

TextTableStyle(; kwargs...)

Create a style in which each field can be passed as a keyword. Every keyword accepts a Face or a Crayon, which is converted to the equivalent face. The keywords first_line_column_label and column_label also accept a vector of faces or crayons.

source
PrettyTables.TextTableStyleMethod
TextTableStyle(style::TextTableStyle; kwargs...) -> TextTableStyle

Create a copy of style in which the fields passed as keywords in kwargs are replaced, converting the crayons into faces and rendering the escape sequences again.

source
PrettyTables.TypstCaptionType
struct TypstCaption

Define a Typst caption configuration to be used by the Typst backend.

Fields

  • caption::String: Caption text.
  • kind::String: Caption kind forwarded to Typst (for example, auto or a custom kind).
  • supplement::Union{Nothing, String}: Optional caption supplement.
  • gap::String: Gap between figure content and caption.
  • position::Union{Nothing, String}: Optional caption position.
source
PrettyTables.TypstHighlighterType
struct TypstHighlighter

Define the default highlighter of a table when using the Typst back end.

Fields

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature f(h, data, i, j) in which h is the highlighter. This function must return a Vector{Pair{String, String}} with properties compatible with the style field that will be applied to the highlighted cell.

Remarks

This structure can be constructed using the following helpers:

TypstHighlighter(f::Function, decoration::TypstPair)

TypstHighlighter(f::Function, decoration::Vector{TypstPair})

TypstHighlighter(f::Function, fd::Function)

The first two apply a fixed decoration to the highlighted cell, whereas the third lets the user select the desired decoration by specifying the function fd.

The following helpers create the decoration from a Face of StyledStrings.jl, converted with typst_decoration, from a Crayon, converted to the equivalent face, or from the keywords of Face and Crayon (see Highlighter):

TypstHighlighter(f::Function, face::Face)

TypstHighlighter(f::Function, crayon::Crayon)

TypstHighlighter(f::Function; kwargs...)
source
PrettyTables.TypstPairType
const TypstPair = Pair{String, String}

Pair with a Typst property and its value, which is the native decoration of the Typst back end (for example, "text-weight" => "bold").

source
PrettyTables.TypstTableBordersType
struct TypstTableBorders

Define the stroke widths for the borders of a table printed with the Typst back end. All fields are strings with the properties that can be passed to a stroke object (e.g., "(paint: blue, thickness: 4pt, cap: "round")"). For more information, refer to: https://typst.app/docs/reference/visualize/stroke/

Fields

Horizontal Lines

  • top_line::String: Stroke for the top border of the table. (Default: "1.5pt")
  • header_line::String: Stroke for the line below the table header. (Default: "0.8pt")
  • merged_header_cell_line::String: Stroke for the line below merged header cells. (Default: "0.8pt")
  • middle_line::String: Stroke for horizontal lines inside the table body. (Default: "0.5pt")
  • bottom_line::String: Stroke for the bottom border of the table. (Default: "1.5pt")

Vertical Lines

  • left_line::String: Stroke for the left border of the table. (Default: "1.5pt")
  • center_line::String: Stroke for vertical lines inside the table body. (Default: "0.8pt")
  • right_line::String: Stroke for the right border of the table. (Default: "1.5pt")
source
PrettyTables.TypstTableFormatType
struct TypstTableFormat

Define the format of the tables printed with the Typst back end.

Fields

  • borders::TypstTableBorders: Format of the borders.
  • horizontal_line_at_beginning::Bool: If true, a horizontal line will be drawn at the beginning of the table.
  • horizontal_line_at_merged_column_labels::Bool: If true, a horizontal line will be drawn at the bottom of the merged column labels using table.hline. The default is true, whereas the text back end defaults to false.
  • horizontal_line_after_column_labels::Bool: If true, a horizontal line will be drawn after the column labels.
  • horizontal_lines_at_data_rows::Union{Symbol, Vector{Int}}: A horizontal line will be drawn after each data row index listed in this vector. If the symbol :all is passed, a horizontal line will be drawn after every data row. If the symbol :none is passed, no horizontal lines will be drawn after the data rows.
  • horizontal_line_before_row_group_label::Bool: If true, a horizontal line will be drawn before the row group label.
  • horizontal_line_after_row_group_label::Bool: If true, a horizontal line will be drawn after the row group label.
  • horizontal_line_after_data_rows::Bool: If true, a horizontal line will be drawn after the data rows.
  • horizontal_line_before_summary_rows::Bool: If true, a horizontal line will be drawn before the summary rows. Notice that this line is the same as the one drawn if horizontal_line_after_data_rows is true. However, in this case, the line is omitted if there are no summary rows.
  • horizontal_line_after_summary_rows::Bool: If true, a horizontal line will be drawn after the summary rows.
  • vertical_line_at_beginning::Bool: If true, a vertical line will be drawn at the beginning of the table.
  • vertical_line_after_row_number_column::Bool: If true, a vertical line will be drawn after the row number column.
  • vertical_line_after_row_label_column::Bool: If true, a vertical line will be drawn after the row label column.
  • vertical_lines_at_data_columns::Union{Symbol, Vector{Int}}: A vertical line will be drawn after each data column index listed in this vector. If the symbol :all is passed, a vertical line will be drawn after every data column. If the symbol :none is passed, no vertical lines will be drawn after the data columns.
  • vertical_line_after_data_columns::Bool: If true, a vertical line will be drawn after the data columns.
  • vertical_line_after_continuation_column::Bool: If true, a vertical line will be drawn after the continuation column.
source
PrettyTables.TypstTableStyleType
struct TypstTableStyle

Define the style of the tables printed with the Typst back end.

Fields

  • table::Vector{TypstPair}: Style for the table.
  • title::Vector{TypstPair}: Style for the title.
  • subtitle::Vector{TypstPair}: Style for the subtitle.
  • row_number_label::Vector{TypstPair}: Style for the row number label.
  • row_number::Vector{TypstPair}: Style for the row number.
  • stubhead_label::Vector{TypstPair}: Style for the stubhead label.
  • row_label::Vector{TypstPair}: Style for the row label.
  • row_group_label::Vector{TypstPair}: Style for the row group label.
  • first_line_column_label::Union{Vector{TypstPair}, Vector{Vector{TypstPair}}}: Style for the first line of the column labels. If a vector of Vector{TypstPair} is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{Vector{TypstPair}, Vector{Vector{TypstPair}}}: Style for the rest of the column labels. If a vector of Vector{TypstPair} is provided, each column label will use the corresponding style.
  • first_line_merged_column_label::Vector{TypstPair}: Style for the merged cells at the first column label line.
  • merged_column_label::Vector{TypstPair}: Style for the merged cells at the rest of the column labels.
  • omitted_cell_summary::Vector{TypstPair}: Style for the omitted cell summary.
  • summary_row_cell::Vector{TypstPair}: Style for the summary row cell.
  • summary_row_label::Vector{TypstPair}: Style for the summary row label.
  • footnote::Vector{TypstPair}: Style for the footnote.
  • source_note::Vector{TypstPair}: Style for the source notes.

Constructor

TypstTableStyle(; kwargs...)

Create a style in which each field can be passed as a keyword. Every keyword also accepts a Face (or a Crayon, converted to the equivalent face), which is converted with typst_decoration. The keywords first_line_column_label and column_label also accept a vector with one decoration (Typst properties or Face) per column.

source
PrettyTables.excel_decorationMethod
excel_decoration(face::Face) -> Vector{ExcelPair}

Convert the face of StyledStrings.jl into the attributes used by the Excel back end, which can be passed to an ExcelHighlighter or to a field of ExcelTableStyle.

The conversion is:

Face AttributeExcel Attribute
fontname
height (Int, deci-points)size (rounded to points)
weightbold => "true" (bold weights)
slantitalic => "true" (:italic and :oblique)
foregroundcolor => "FFRRGGBB"
backgroundcell_fill_pattern => "solid" and cell_fill_fgColor => "FFRRGGBB"
underlineunder => "single"
strikethroughstrike => "true"

The colors are resolved with StringManipulation.face_color_rgb, so that the default color of the terminal and unknown names are ignored. The light weights, a Float64 height, and the attributes inverse and inherit are ignored, as well as the color and style of the underline.

Examples

julia> excel_decoration(Face(; weight = :bold, foreground = "#ff0000"))
2-element Vector{Pair{String, String}}:
  "bold" => "true"
 "color" => "FFFF0000"
source
PrettyTables.excel_line_styleMethod
excel_line_style(line_style::LineStyle; default::Vector{ExcelPair} = ExcelPair["style" => "thin", "color" => "Black"]) -> Vector{ExcelPair}

Convert line_style into the border attributes used by the Excel back end.

The Excel border style is selected from the combination of the style and width fields (unset fields default to :solid and :thin):

style \ width:thin:medium:thick
:solidthinmediumthick
:dasheddashedmediumDashedmediumDashed
:dotteddotteddotteddotted
:doubledoubledoubledouble

The color is converted to the 8-digit value "FFRRGGBB". An unset style or width keeps the one of the border attributes in default, and a color that is nothing or cannot be resolved to a 24-bit value keeps the color in default.

source
PrettyTables.fmt__excel_stringifyFunction
fmt__excel_stringify(
    columns::Union{Nothing, Int, AbstractVector{Int}} = nothing
) -> Function

Create a formatter function that converts values XLSX.jl cannot handle directly into their string representation. When columns is nothing, all values are stringified; otherwise only the columns listed in columns are converted.

Note

This function is only available when the package XLSX.jl is loaded.

source
PrettyTables.fmt__latex_snMethod
fmt__latex_sn(m_digits::Int[, columns::AbstractVector{Int}]) -> Function

Format the numbers of the elements in the columns to a scientific notation using LaTeX. If columns is not present, the formatting will be applied to the entire table.

The number is first printed using Printf functions with the g modifier and then converted to the LaTeX format. The number of digits in the mantissa can be selected by the argument m_digits.

The formatted number will be wrapped in the object LatexCell. Hence, this formatter only makes sense if the selected backend is :latex.

Info

This formatter will be applied only to the cells that are of type Number.

Extended Help

Examples

julia> data = [10.0^(-i + j) for i in 1:6, j in 1:6]
6×6 Matrix{Float64}:
 1.0     10.0     100.0    1000.0   10000.0  100000.0
 0.1      1.0      10.0     100.0    1000.0   10000.0
 0.01     0.1       1.0      10.0     100.0    1000.0
 0.001    0.01      0.1       1.0      10.0     100.0
 0.0001   0.001     0.01      0.1       1.0      10.0
 1.0e-5   0.0001    0.001     0.01      0.1       1.0

julia> pretty_table(data; formatters = [fmt__latex_sn(1)], backend = :latex)
\begin{tabular}{|r|r|r|r|r|r|}
  \hline
  \textbf{Col. 1} & \textbf{Col. 2} & \textbf{Col. 3} & \textbf{Col. 4} & \textbf{Col. 5} & \textbf{Col. 6} \\
  \hline
  1 & $1 \cdot 10^{1}$ & $1 \cdot 10^{2}$ & $1 \cdot 10^{3}$ & $1 \cdot 10^{4}$ & $1 \cdot 10^{5}$ \\
  0.1 & 1 & $1 \cdot 10^{1}$ & $1 \cdot 10^{2}$ & $1 \cdot 10^{3}$ & $1 \cdot 10^{4}$ \\
  0.01 & 0.1 & 1 & $1 \cdot 10^{1}$ & $1 \cdot 10^{2}$ & $1 \cdot 10^{3}$ \\
  0.001 & 0.01 & 0.1 & 1 & $1 \cdot 10^{1}$ & $1 \cdot 10^{2}$ \\
  0.0001 & 0.001 & 0.01 & 0.1 & 1 & $1 \cdot 10^{1}$ \\
  $1 \cdot 10^{-5}$ & 0.0001 & 0.001 & 0.01 & 0.1 & 1 \\
  \hline
\end{tabular}
source
PrettyTables.fmt__printfMethod
fmt__printf(fmt_str::String[, columns::AbstractVector{Int}]) -> Function

Apply the format fmt_str (see the Printf standard library) to the elements in the columns specified in the vector columns. If columns is not specified, the format will be applied to the entire table.

Info

This formatter will be applied only to the cells that are of type Number.

Extended Help

Examples

julia> data = [f(a) for a = 0:30:90, f in (sind, cosd, tand)]
4×3 Matrix{Float64}:
 0.0       1.0        0.0
 0.5       0.866025   0.57735
 0.866025  0.5        1.73205
 1.0       0.0       Inf

julia> pretty_table(data; formatters = [fmt__printf("%5.3f")])
┌────────┬────────┬────────┐
│ Col. 1 │ Col. 2 │ Col. 3 │
├────────┼────────┼────────┤
│  0.000 │  1.000 │  0.000 │
│  0.500 │  0.866 │  0.577 │
│  0.866 │  0.500 │  1.732 │
│  1.000 │  0.000 │    Inf │
└────────┴────────┴────────┘

julia> pretty_table(data; formatters = [fmt__printf("%5.3f", [1, 3])])
┌────────┬──────────┬────────┐
│ Col. 1 │   Col. 2 │ Col. 3 │
├────────┼──────────┼────────┤
│  0.000 │      1.0 │  0.000 │
│  0.500 │ 0.866025 │  0.577 │
│  0.866 │      0.5 │  1.732 │
│  1.000 │      0.0 │    Inf │
└────────┴──────────┴────────┘
source
PrettyTables.fmt__roundMethod
fmt__round(digits::Int[, columns::AbstractVector{Int}]) -> Function

Round the elements in the columns specified in the vector columns to the number of digits. If columns is not specified, the rounding will be applied to the entire table.

Info

This formatter will be applied only to the cells that are of type Number.

Extended Help

Examples

julia> data = [f(a) for a = 0:30:90, f in (sind, cosd, tand)]
4×3 Matrix{Float64}:
 0.0       1.0        0.0
 0.5       0.866025   0.57735
 0.866025  0.5        1.73205
 1.0       0.0       Inf

julia> pretty_table(data; formatters = [fmt__round(1)])
┌────────┬────────┬────────┐
│ Col. 1 │ Col. 2 │ Col. 3 │
├────────┼────────┼────────┤
│    0.0 │    1.0 │    0.0 │
│    0.5 │    0.9 │    0.6 │
│    0.9 │    0.5 │    1.7 │
│    1.0 │    0.0 │    Inf │
└────────┴────────┴────────┘

julia> pretty_table(data; formatters = [fmt__round(1, [1, 3])])
┌────────┬──────────┬────────┐
│ Col. 1 │   Col. 2 │ Col. 3 │
├────────┼──────────┼────────┤
│    0.0 │      1.0 │    0.0 │
│    0.5 │ 0.866025 │    0.6 │
│    0.9 │      0.5 │    1.7 │
│    1.0 │      0.0 │    Inf │
└────────┴──────────┴────────┘
source
PrettyTables.html_decorationMethod
html_decoration(face::Face) -> Vector{HtmlPair}

Convert the face of StyledStrings.jl into the CSS properties used by the HTML back end, which can be passed to an HtmlHighlighter or to a field of HtmlTableStyle.

The conversion is:

Face AttributeCSS Property
fontfont-family
height (Int, deci-points)font-size: <pt>pt
height (Float64, factor)font-size: <factor>em
weightfont-weight: bold, lighter, or normal
slantfont-style: italic, oblique, or normal
foregroundcolor: #rrggbb
backgroundbackground-color: #rrggbb
underlinetext-decoration: underline
strikethroughtext-decoration: line-through

underline and strikethrough are merged into a single text-decoration property. The colors are resolved with StringManipulation.face_color_rgb, so that the default color of the terminal and unknown names are ignored. The attributes inverse and inherit, and the color and style of the underline, are ignored.

Examples

julia> html_decoration(Face(; weight = :bold, foreground = "#ff0000"))
2-element Vector{Pair{String, String}}:
       "color" => "#ff0000"
 "font-weight" => "bold"
source
PrettyTables.html_line_styleMethod
html_line_style(line_style::LineStyle; default::String = "1px solid black") -> String

Convert line_style into a CSS border shorthand value.

The width is converted to "1px" (:thin), "2px" (:medium), or "3px" (:thick). The style is converted to the border style "solid", "dashed", "dotted", or "double". The color is converted to the hexadecimal form "#rrggbb". Every unset field, or a color that cannot be resolved to a 24-bit value, keeps the corresponding component of the shorthand default, which must have the form "<width> <style> <color>". If default does not have this form, the unset components are "1px", "solid", and "black".

source
PrettyTables.latex_decorationMethod
latex_decoration(face::Face) -> Vector{String}

Convert the face of StyledStrings.jl into the LaTeX environments used by the LaTeX back end, which can be passed to a LatexHighlighter or to a field of LatexTableStyle.

The environments are returned from the innermost to the outermost:

Face AttributeLaTeX Environment
weighttextbf (bold weights)
slanttextit (:italic and :oblique)
underlineunderline
strikethroughsout (requires the package ulem)
foregroundtextcolor[HTML]{RRGGBB} (requires the package xcolor)
backgroundcolorbox[HTML]{RRGGBB} (requires the package xcolor)

The colors are resolved with StringManipulation.face_color_rgb, so that the default color of the terminal and unknown names are ignored. The light weights, and the attributes font, height, inverse, and inherit, are ignored, as well as the color and style of the underline.

Note

The LaTeX back end does not write any preamble. Hence, the packages xcolor and ulem must be loaded in the document if the face has colors or a strikethrough.

Examples

julia> latex_decoration(Face(; weight = :bold, foreground = "#ff0000"))
2-element Vector{String}:
 "textbf"
 "textcolor[HTML]{FF0000}"
source
PrettyTables.latex_line_styleMethod
latex_line_style(line_style::LineStyle; default::String = "\\hline") -> String

Convert line_style into a LaTeX horizontal rule command. The keyword default is accepted for consistency with the other back ends, but it is not used because the style is the only field of line_style that is converted.

The style is converted as follows: :solid becomes "\\hline", :double becomes "\\hline\\hline", :dashed becomes "\\hdashline", and :dotted becomes "\\hdashline[1pt/1pt]". The dashed and dotted rules require the package arydshln to be loaded in the document. The width and color fields are ignored because LaTeX controls them with the global commands \\arrayrulewidth and \\arrayrulecolor.

source
PrettyTables.markdown_decorationMethod
markdown_decoration(face::Face) -> MarkdownStyle

Convert the face of StyledStrings.jl into the MarkdownStyle used by the Markdown back end, which can be passed to a MarkdownHighlighter or to a field of MarkdownTableStyle.

The bold weights set bold, the slants :italic and :oblique set italic, and strikethrough = true sets strikethrough. Every other attribute is ignored because it cannot be represented in Markdown.

Examples

julia> markdown_decoration(Face(; weight = :bold, foreground = :red))
MarkdownStyle(true, false, false, false)
source
PrettyTables.pretty_tableFunction
pretty_table(table; kwargs...) -> Nothing

Print the table to the stdout.

pretty_table(io::IO, table; kwargs...) -> Nothing
pretty_table(String, table; kwargs...) -> String
pretty_table(HTML,   table; kwargs...) -> HTML

Print the table to the output specified by the first argument.

If the first argument is of type IO, the function prints the table to it. If it is String, a String with the printed table will be returned by the function. If HTML is passed as the first argument, the function will return an HTML object with the table.

When printing, the function verifies if table complies with Tables.jl API. If it is compliant, this interface will be used to print the table. If it is not compliant, only the following types are supported:

  1. AbstractVector: any vector can be printed.
  2. AbstractMatrix: any matrix can be printed.

pretty_table currently supports printing tables for six backends: text, markdown, html, latex, typst, and excel. The desired backend can be set using the backend keyword argument.

For more information, see the Extended Help section.

Extended Help

Table Sections

PrettyTables.jl considers the following table sections when printing a table:

                                      TITLE
                                     Subtitle
┌────────────┬───────────────────┬──────────────┬──────────────┬───┬──────────────┐
│ Row Number │    Stubhead Label │ Column Label │ Column Label │ ⋯ │ Column Label │
│            │                   │ Column Label │ Column Label │ ⋯ │ Column Label │
│            │                   │       ⋮      │       ⋮      │ ⋯ │       ⋮      │
│            │                   │ Column Label │ Column Label │ ⋯ │ Column Label │
├────────────┼───────────────────┼──────────────┼──────────────┼───┼──────────────┤
│          1 │         Row Label │         Data │         Data │ ⋯ │         Data │
│          2 │         Row Label │         Data │         Data │ ⋯ │         Data │
├────────────┴───────────────────┴──────────────┴──────────────┴───┴──────────────┤
│ Row Group Label                                                                 │
├────────────┬───────────────────┬──────────────┬──────────────┬───┬──────────────┤
│          3 │         Row Label │         Data │         Data │ ⋯ │         Data │
│          4 │         Row Label │         Data │         Data │ ⋯ │         Data │
├────────────┴───────────────────┴──────────────┴──────────────┴───┴──────────────┤
│ Row Group Label                                                                 │
├────────────┬───────────────────┬──────────────┬──────────────┬───┬──────────────┤
│          5 │         Row Label │         Data │         Data │ ⋯ │         Data │
│          6 │         Row Label │         Data │         Data │ ⋯ │         Data │
│      ⋮     │          ⋮        │       ⋮      │       ⋮      │ ⋱ │       ⋮      │
│        100 │         Row Label │         Data │         Data │ ⋯ │         Data │
├────────────┼───────────────────┼──────────────┼──────────────┼───┼──────────────┤
│            │ Summary Row Label │ Summary Cell │ Summary Cell │ ⋯ │ Summary Cell │
│            │ Summary Row Label │ Summary Cell │ Summary Cell │ ⋯ │ Summary Cell │
│      ⋮     │          ⋮        │       ⋮      │       ⋮      │ ⋯ │       ⋮      │
│            │ Summary Row Label │ Summary Cell │ Summary Cell │ ⋯ │ Summary Cell │
└────────────┴───────────────────┴──────────────┴──────────────┴───┴──────────────┘
Footnotes
Source notes

All those sections can be configured using keyword arguments as described below.

Quick Start

The following command prints the table in matrix using the text backend with all the available sections:

julia> matrix = [(i, j) for i in 1:3, j in 1:3];

julia> result = pretty_table(
    matrix;
    column_labels            = [["Col. $i" for i in 1:3], ["$i" for i in 1:3]],
    footnotes                = [(:column_label, 1, 2) => "Footnote in column label", (:data, 2, 2) => "Footnote in data"],
    merge_column_label_cells = [MergeCells(1, 2, 2, "Merged Column", :c)],
    row_group_labels         = [2                     => "Row Group"],
    row_labels               = ["Row $i" for i in 1:5],
    show_row_number_column   = true,
    source_notes             = "Source Notes",
    stubhead_label           = "Rows",
    subtitle                 = "Table Subtitle",
    summary_rows             = [(data, i) -> 10i, (data, i) -> 20i],
    title                    = "Table Title",
)
                  Table Title
                Table Subtitle
┌─────┬───────────┬────────┬──────────────────┐
│ Row │      Rows │ Col. 1 │  Merged Column¹  │
│     │           │      1 │       2 │      3 │
├─────┼───────────┼────────┼─────────┼────────┤
│   1 │     Row 1 │ (1, 1) │  (1, 2) │ (1, 3) │
├─────┴───────────┴────────┴─────────┴────────┤
│ Row Group                                   │
├─────┬───────────┬────────┬─────────┬────────┤
│   2 │     Row 2 │ (2, 1) │ (2, 2)² │ (2, 3) │
│   3 │     Row 3 │ (3, 1) │  (3, 2) │ (3, 3) │
├─────┼───────────┼────────┼─────────┼────────┤
│     │ Summary 1 │     10 │      20 │     30 │
│     │ Summary 2 │     20 │      40 │     60 │
└─────┴───────────┴────────┴─────────┴────────┘
¹: Footnote in column label
²: Footnote in data
Source Notes

General Keywords

The following keywords are related to table configuration and are available in all backends:

  • backend::Symbol: Backend used to print the table. The available options are :text, :markdown, :html, :latex, :typst, and :excel. If it is :auto, the backend is obtained from the type of the keyword table_format, falling back to :text if the latter is not present or if it is the backend-agnostic TableFormat, which does not select a backend. (Default: :auto)

IOContext Arguments

  • compact_printing::Bool: If true, the table will be printed in a compact format, i.e, we will pass the context option :compact => true when rendering the values. (Default: true)
  • limit_printing::Bool: If true, the table will be printed in a limited format, i.e, we will pass the context option :limit => true when rendering the values. (Default: true)

Printing Specification Arguments

  • show_omitted_cell_summary::Bool: If true, a summary of the omitted cells will be printed at the end of the table. (Default: true)
  • renderer::Symbol: The renderer used to print the table. The available options are :print and :show. (Default: :print)

Table Sections Arguments

  • title::String: Title of the table. If it is empty, the title will be omitted. (Default: "")
  • subtitle::String: Subtitle of the table. If it is empty, the subtitle will be omitted. (Default: "")
  • stubhead_label::String: Label of the stubhead column. (Default: "")
  • row_number_column_label::String: Label of the row number column. (Default: "Row")
  • row_labels::Union{Nothing, AbstractVector}: Row labels. If it is nothing, the column with row labels is omitted. (Default: nothing)
  • row_group_labels::Union{Nothing, Vector{Pair{Int, String}}}: Row group labels. If it is nothing, no row group label is printed. For more information on how to specify the row group labels, see the section Row Group Labels. (Default: nothing)
  • column_labels::Union{Nothing, AbstractVector}: Column labels. If it is nothing, the function uses a default value for the column labels. For more information on how to specify the column labels, see the section Column Labels. (Default: nothing)
  • show_column_labels::Bool: If true, the column labels will be printed. (Default: true)
  • summary_rows::Union{Nothing, Vector{Function}}: Summary rows. If it is nothing, no summary rows are printed. For more information on how to specify the summary rows, see the section Summary Rows. (Default: nothing)
  • summary_row_labels::Union{Nothing, Vector{String}}: Labels of the summary rows. If it is nothing, the function uses a default value for the summary row labels. (Default: nothing)
  • footnotes::Union{Nothing, Vector{Pair{FootnoteTuple, String}}}: Footnotes. If it is nothing, no footnotes are printed. For more information on how to specify the footnotes, see the section Footnotes. (Default: nothing)
  • source_notes::String: Source notes. If it is empty, the source notes will be omitted. (Default: "")

Alignment Arguments

The following keyword arguments define the alignment of the table sections. The alignment can be specified using a symbol: :l for left, :c for center, or :r for right.

  • alignment::Union{Symbol, Vector{Symbol}}: Alignment of the table data. It can be a Symbol, which will be used for all columns, or a vector of Symbols, one for each column. (Default: :r)
  • column_label_alignment::Union{Nothing, Symbol, Vector{Symbol}}: Alignment of the column labels. It can be a Symbol, which will be used for all columns, a vector of Symbols, one for each column, or nothing, which will use the value of alignment. (Default: nothing)
  • continuation_row_alignment::Union{Nothing, Symbol}: Alignment of the columns in the continuation row. If it is nothing, we use the value of alignment. (Default: nothing)
  • footnote_alignment::Symbol: Alignment of the footnotes. (Default: :l)
  • row_label_column_alignment::Symbol: Alignment of the row labels. (Default: :r)
  • row_group_label_alignment::Symbol: Alignment of the row group labels. (Default: :l)
  • row_number_column_alignment::Symbol: Alignment of the row number column. (Default: :r)
  • source_note_alignment::Symbol: Alignment of the source notes. (Default: :l)
  • subtitle_alignment::Symbol: Alignment of the subtitle. (Default: :c)
  • title_alignment::Symbol: Alignment of the title. (Default: :c)
  • cell_alignment::Union{Nothing, Vector{<:Function}, Vector{Pair{NTuple{2, Int}, Symbol}}}: Either nothing, a vector of functions, or a vector of coordinate/alignment pairs. Each function must have the signature f(data, i, j) and return a valid alignment symbol or nothing for the cell (i, j). Returning nothing leaves the cell alignment unchanged. Each pair must have the form (i::Int, j::Int) => a::Symbol and sets the alignment of cell (i, j) to a. (Default = nothing)
Warning

Some backends do not support all the alignment options. For example, it is impossible to define cell-specific alignment in the markdown backend.

Other Arguments

  • formatters::Union{Nothing, Vector{Function}}: Formatters used to modify the rendered output of the cells. For more information, see the section Formatters. (Default: nothing)
  • maximum_number_of_columns::Int: Maximum number of columns to be printed. If the table has more columns than this value, the table will be truncated. If it is negative, all columns will be printed. (Default: -1)
  • maximum_number_of_rows::Int: Maximum number of rows to be printed. If the table has more rows than this value, the table will be truncated. If it is negative, all rows will be printed. (Default: -1)
  • merge_column_label_cells::Union{Symbol, Vector{MergeCells}}: Merged cells in the column labels. For more information, see the section Column Labels. (Default: :auto)
  • new_line_at_end::Bool: If true, a new line will be printed at the end of the table. (Default: true)
  • show_first_column_label_only::Bool: If true, only the first row of the column labels will be printed. (Default: false)
  • vertical_crop_mode::Symbol: Vertical crop mode. This option defines how the table will be vertically cropped if it has more rows than the number specified in maximum_number_of_rows. The available options are :bottom, when the data will be cropped at the bottom of the table, or :middle, when the data will be cropped at the middle of the table. (Default: :bottom)

Backend-Specific Keywords

The keywords and information specific to each backend can be seen in the docstrings of the following methods:

  • Text backend: pretty_table_text_backend.
  • Markdown backend: pretty_table_markdown_backend.
  • HTML backend: pretty_table_html_backend.
  • LaTeX backend: pretty_table_latex_backend.
  • Typst backend: pretty_table_typst_backend.
  • Excel backend: pretty_table_excel_backend.
Warning

Those methods must not be called directly. They are only defined to split the documentation, providing a better organization.

Specification of Table Sections

Here, we show how to specify the table sections using the keyword arguments.

Column Labels

The specification of column labels must be a vector of elements. Each element in this vector must be another vector with a row of column labels. Notice that each vector must have the same size as the number of table columns.

For example, in a table with three columns, we can specify two rows of column labels by passing:

column_labels = [
    ["Column #1",    "Column #2",    "Column #3"],
    ["Subcolumn #1", "Subcolumn #2", "Subcolumn #3"]
]
Info

If the user wants only one row in the column labels, they can pass only a vector with the elements. The algorithm will encapsulate it inside another vector to match the API.

Adjacent column labels can be merged using the keyword merge_column_label_cells. It must contain a vector of MergeCells objects. Each object defines a new merged cell. The MergeCells object has the following fields:

  • i::Int: Row index of the merged cell.
  • j::Int: Column index of the merged cell.
  • column_span::Int: Number of columns spanned by the merged cell.
  • data::Any: Data of the merged cell.
  • alignment::Symbol: Alignment of the merged cell. The available options are :l for left, :c for center, and :r for right. (Default: :c)

Hence, in our example, if we want to merge the columns 2 and 3 of the first column label row, we must pass:

merge_column_label_cells = [
    MergeCells(1, 2, 2, "Merged Column", :c)
]

We can pass the helpers MultiColumn and EmptyCells to column_labels to create merged columns more easily. In this case, MultiColumn specify a set of columns that will be merged, and EmptyCells specify a set of empty columns. However, notice that in this case we must set merge_column_label_cells to :auto, which is the default.

MultiColumn has the following fields:

  • column_span::Int: Number of columns spanned by the merged cell.
  • data::Any: Data of the merged cell.
  • alignment::Symbol: Alignment of the merged cell. The available options are :l for left, :c for center, and :r for right. (Default: :c)

EmptyCells has the following field:

  • number_of_cells::Int: Number of columns that will be filled with empty cells.

For example, we can create the following column labels:

┌───────────────────────────────────┬─────────────────┐
│              Group #1             │     Group #2    │
├─────────────────┬─────────────────┼────────┬────────┤
│    Group #1.1   │    Group #1.2   │        │        │
├────────┬────────┼────────┬────────┼────────┼────────┤
│ Test 1 │ Test 2 │ Test 3 │ Test 4 │ Test 5 │ Test 6 │
└────────┴────────┴────────┴────────┴────────┴────────┘

by passing these arguments:

column_labels = [
    [MultiColumn(4, "Group #1"), MultiColumn(2, "Group #2")],
    [MultiColumn(2, "Group #1.1"), MultiColumn(2, "Group #1.2"), EmptyCells(2)],
    ["Test 1", "Test 2", "Test 3", "Test 4", "Test 5", "Test 6"]
]

merge_column_label_cells = :auto

Row Group Labels

The row group labels are specified by a Vector{Pair{Int, String}}. Each element defines a new row group label. The first element of the Pair is the row index of the row group and the second is the label. For example, [3 => "Row Group #1"] defines that before row 3, we have the row group label named "Row Group #1".

Summary Rows

The summary rows can be specified by a vector of Functions. Each element defines a summary row and the function must have one of the following signatures:

f(col)

f(data, j)

where col is the current column, data is the table data, and j is the column index. In the first case, it must return the summary cell value for the referenced column. In the second case, it must return the summary cell value for the jth column. The algorithm will check if there is an applicable method for the first signature and use it if it exists. Otherwise, it will use the second signature. This verification is performed using the method applicable and col is obtained by @view data[:, j].

If we want, for example, to create two summary rows, one with the sum of the column values and other with their mean, we can define:

summary_rows = [
    (data, j) -> sum(data[:, j]),
    (data, j) -> sum(data[:, j]) / length(data[:, j])
]

We can also use the first signature to simplify the code:

using Statistics
summary_rows = [sum, mean]
Note

If both signatures are available, the algorithm will prioritize the first one. To force the usage of the second, we can create an anonymous functions as follows: (data, i) -> f(data, i). This ensures that only the second method is available.

Footnotes

The footnotes are specified by a vector of Pair{FootnoteTuple, String}. Each element defines a new footnote. The FootnoteTuple is a Tuple with the following elements:

  • section::Symbol: Section to which the footnote must be applied. The available options are :column_label, :data, :row_label, :summary_row_label, and :summary_row_cell.
  • i::Int: Row index of the footnote considering the desired section.
  • j::Int: Column index of the footnote considering the desired section.

The second element of the Pair is the footnote text.

Hence, if we want to apply a foot note to a column label, a data cell, and a summary cell, we can define:

footnotes = [
    (:column_label, 1, 2) => "Footnote in column label",
    (:data, 2, 2) => "Footnote in data",
    (:summary_row_cell, 1, 2) => "Footnote in summary cell"
]

Formatters

The keyword formatters can be used to pass functions to format the values in the columns. It must be a Vector{Function} in which each function has the following signature:

f(v, i, j)

where v is the value in the cell, i is the row number, and j is the column number. It must return the formatted value of the cell (i, j) that has the value v. Notice that the returned value will be converted to string after using the function sprint.

This keyword can also be nothing, meaning that no formatter will be used.

For example, if we want to multiply all values in odd rows of the column 2 by π, the formatter should look like:

formatters = [(v, i, j) -> (j == 2 && isodd(i)) ? v * π : v]

If multiple formatters are available, they will be applied in the same order as they are located in the vector. Thus, for the following formatters:

formatters = [f1, f2, f3]

each element v in the table (ith row and jth column) will be formatted by:

v = f1(v, i, j)
v = f2(v, i, j)
v = f3(v, i, j)

Thus, the user must ensure that the type of v between the calls is compatible.

PrettyTables.jl provides some predefined formatters for common tasks. For more information, see fmt__printf, fmt__round, and fmt__latex_sn.

source
PrettyTables.pretty_table_excel_backendFunction

Excel Backend

The Excel backend can be selected by passing the keyword backend = :excel to the function pretty_table. This will allow you to create a pretty table in a newly created Excel file or to add a pretty table to a new or existing sheet in an existing Excel file.

The Excel backend's return value depends on the following combination of keywords:

  • nothing when sheet is an XLSX.Worksheet (the worksheet is updated in place).
  • XLSX.XLSXFile when filename is nothing and sheet is a String.
  • String (the filename) when filename is a String and mode = "w".
  • XLSX.XLSXFile when filename is a String and mode = "rw".
Note

This backend uses the functions of XLSX.jl, particularly the functions setFont, setFill, setBorder and setFormat. For more information, refer to the documentation of this package.

Keywords

  • anchor_cell::String: Top-left cell of the table in A1 notation (e.g. "B3"). (Default: "A1")
  • data_column_widths::Union{Float64, Vector{Float64}}: Explicit width for each data column in Excel units, overriding auto-calculated widths. A scalar applies to all columns; a vector sets per-column widths. When set (> 0), minimum_data_column_widths and maximum_data_column_widths are ignored for that column. (Default: 0.0)
  • excel_formatters::Vector{ExcelFormatter}: Number-format rules applied to data and summary cells. (Default: ExcelFormatter[])
  • filename::Union{Nothing, String}: Path of the Excel file to write. When nothing, no file is created and an in-memory XLSX.XLSXFile is returned instead. When a string, behavior depends on mode. (Default: nothing)
  • highlighters::Vector{<:AbstractHighlighter}: Highlighters to apply to the table. For more information, see the section Excel Highlighters in the Extended Help.
  • maximum_data_column_widths::Union{Float64, Vector{Float64}}: Maximum width for each data column in Excel units. A scalar applies to all columns; a vector sets per-column maximums. (Default: 0.0)
  • minimum_data_column_widths::Union{Float64, Vector{Float64}}: Minimum width for each data column in Excel units. A scalar applies to all columns; a vector sets per-column minimums. (Default: 0.0)
  • mode::String: "w" to create a new file or "rw" (or its alias "wr") to open and update an existing one. (Default: "w")
  • overwrite::Bool: Allow overwriting an existing file when mode = "w". (Default: false)
  • sheet::Union{String, XLSX.Worksheet}: When a String, the name of the worksheet tab. If no sheet with that name exists it will be created. When an XLSX.Worksheet, that worksheet is updated in place and nothing is returned. (Default: "prettytable")
  • style::Union{TableStyle, ExcelTableStyle}: Style of the table. The fields of the backend-agnostic TableStyle override the ones of the default Excel table style. For more information, see the section Excel Table Style in the Extended Help.
  • table_format::Union{TableFormat, ExcelTableFormat}: Excel table format used to render the table. The backend-agnostic TableFormat is fully supported: its line presence and design fields override the ones of the default Excel table format. For more information, see the section Excel Table Format in the Extended Help.

Extended Help

Excel Highlighters

A set of highlighters can be passed as a vector of AbstractHighlighter to the highlighters keyword. A highlighter can be an instance of the structure ExcelHighlighter, specific to this back end, or of the general Highlighter, which is defined by a Face and works with every back end (see Faces). The face is converted with excel_decoration. The structure ExcelHighlighter contains the following two public fields:

  • f::Function: Function with the signature f(data, i, j), which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature f(h, data, i, j) in which h is the highlighter. This function must return a Vector{ExcelPair} with the styling attributes to apply to the highlighted cell.

An Excel highlighter can be constructed using the following helpers:

ExcelHighlighter(f::Function, decoration::ExcelPair)
ExcelHighlighter(f::Function, decoration::Vector{ExcelPair})
ExcelHighlighter(f::Function, fd::Function)

The decoration uses the same Vector{ExcelPair} format as ExcelTableStyle fields. Font attributes are specified directly; fill attributes use the "cell_fill_" key prefix (stripped before calling XLSX.setFill). Border attributes are not supported.

Note

If multiple highlighters are valid for the element (i, j), the applied style will be equal to the first match considering the order in the vector highlighters.

Note

If the highlighters are used together with Formatters, the change in the format will not affect the parameter data passed to the highlighter function f. It will always receive the original, unformatted value.

For example, if we want to highlight the cells in the third data column with a value greater than 10 in red with a grey fill, and those in the fourth column in blue:

highlighters = [
    ExcelHighlighter((data, i, j) -> (j == 3) && (data[i, j] > 10), [
        "color" => "red", "bold" => "true",
        "cell_fill_pattern" => "solid", "cell_fill_fgColor" => "grey90",
    ]),
    ExcelHighlighter((data, i, j) -> (j == 4) && (data[i, j] > 10),
        ["color" => "blue", "bold" => "true"],
    ),
]

Excel Formatters

It is possible to apply a set of native Excel formats by passing a Vector{ExcelFormatter} to the excel_formatters keyword. Each Excel formatter is an instance of the structure ExcelFormatter.

The first formatter (in the order they are specified) that satisfies the specified condition in the given table cell is applied, and the remainder of the formatters in the list are skipped. If none matches, no ExcelFormatter is applied.

By default, an ExcelFormatter matches the data cells and the value of i passed to its function is the data row index. An ExcelFormatter can be applied in the summary row, too, by setting the keyword region = :summary_row. In this case, the value of i relates to the summary row index (1 for the first summary row, 2 for the second, and so on), rather than the data table row. The value of j has the same meaning/values (column specifier) as in the data table itself.

Excel formatters may be applied in addition to the standard formatters. The standard formatters control the literal values written to Excel while the Excel formatters control how Excel displays the literal cell values.

For example, to apply Excel-native formatting to different columns of a table:

excel_formatters = [
    ExcelFormatter((v, i, j) -> (j==1), ["format" => "#,##0_0_0"])
    ExcelFormatter((v, i, j) -> (j==2), ["format" => "#,##0.??_0_0"])
    ExcelFormatter((v, i, j) -> (j==3), ["format" => "#,##0.???"])
    ExcelFormatter((v, i, j) -> (j==4), ["format" => "0_0_0_0"])
]

Excel formatters apply native Excel formatting to native Excel values. However, PrettyTables.jl can handle Julia types that can't be represented natively in Excel. If these are passed natively, then XLSX.jl will fail. To circumvent this, a predefined formatter has been provided which converts any unhandled types to strings (using string()). For more information, see fmt__excel_stringify.

Styled strings of StyledStrings.jl (Julia 1.11 or newer) are converted to Excel's rich text format, where each region of the string becomes a run with the font attributes of its face (see Faces).

Excel Table Format

The Excel table format is defined using an object of type ExcelTableFormat that contains the following fields:

  • borders::ExcelTableBorders: Border style configuration (see below).
  • horizontal_line_at_beginning::Bool: Draw a horizontal line at the first table row after the title/subtitle section (i.e., the top of the column labels or the first data row). Title and subtitle rows are never bordered.
  • horizontal_line_after_column_labels::Bool: Draw a line under the column header section.
  • horizontal_line_between_column_labels::Bool: Draw a line between column header rows.
  • horizontal_line_at_merged_column_labels::Bool: Draw a line under merged column headers.
  • horizontal_lines_at_data_rows::Union{Symbol, Vector{Int}}: Draw underlines after data rows. :all draws after every row, :none draws none, a Vector{Int} draws only after the specified row indices (e.g., [1, 3] draws after rows 1 and 3).
  • horizontal_line_after_data_rows::Bool: Draw a line under the data table section.
  • horizontal_line_before_row_group_label::Bool: Draw a line above each row group divider.
  • horizontal_line_after_row_group_label::Bool: Draw a line below each row group divider.
  • horizontal_line_before_summary_rows::Bool: Draw a line between the data rows and the summary rows.
  • horizontal_line_after_summary_rows::Bool: Draw a line under the last summary row.
  • vertical_line_at_beginning::Bool: Draw a vertical line on the left side of the content area (excludes title/subtitle and footnotes).
  • vertical_line_after_row_number_column::Bool: Draw a vertical line after the row number column.
  • vertical_line_after_row_label_column::Bool: Draw a vertical line after the row label column.
  • vertical_lines_at_data_columns::Union{Symbol, Vector{Int}}: Draw dividers between data columns. :all draws after every column, :none draws none, a Vector{Int} draws only after the specified column indices (e.g., [1, 3] draws after columns 1 and 3).
  • vertical_line_after_data_columns::Bool: Draw a vertical line on the right side of the content area (excludes title/subtitle and footnotes).
  • vertical_line_after_continuation_column::Bool: Draw a vertical line after the continuation column when the table is horizontally cropped.

We provide a few helpers to configure the table format. For more information, see the documentation of the following macros:

Border styles are specified using an ExcelTableBorders object with these fields:

Horizontal lines:

  • top_line: Top of the outside border. (Default: thick black).
  • header_line: Line drawn under the column label section. (Default: medium black).
  • merged_header_cell_line: Line below merged header cells (Default: thin black).
  • middle_line: All other internal horizontal lines — data row underlines, lines around row groups, lines around summary rows, between-header lines — and vertical lines between data columns. (Default: thin black).
  • bottom_line: Bottom of the outside border (Default: thick black).

Vertical lines:

  • left_line: Left of the outside border. (Default: thick black).
  • center_line: Structural vertical lines — after row numbers and after row labels. (Default: thin black).
  • right_line: Right of the outside border. (Default: thick black).

Examples

Apply a preset:

table_format = ExcelTableFormat(; @excel__no_vertical_lines)

Apply a preset and override one of its fields. Notice that the keyword must come after the macro, since the last binding wins:

table_format = ExcelTableFormat(;
    @excel__no_vertical_lines,
    vertical_line_at_beginning = true,
)

Draw section-separator lines in red:

table_format = ExcelTableFormat(;
    borders = ExcelTableBorders(; header_line = ["style" => "thin", "color" => "red"]),
)

To combine a preset with customized border styles:

table_format = ExcelTableFormat(;
    @excel__no_vertical_lines,
    borders = ExcelTableBorders(;
        header_line = ["style" => "thick", "color" => "red"],
        middle_line = ["style" => "thick", "color" => "red"],
    ),
)

When more than one preset is applied, they take effect in order, with the later ones taking precedence. Any keyword argument provided after them takes precedence over all of them.

Excel Table Style

The Excel table style is defined using an object of type ExcelTableStyle that contains the following fields:

  • title::Vector{ExcelPair}: Style for the title.
  • subtitle::Vector{ExcelPair}: Style for the subtitle.
  • row_number_label::Vector{ExcelPair}: Style for the row number label.
  • row_number::Vector{ExcelPair}: Style for the row number.
  • stubhead_label::Vector{ExcelPair}: Style for the stubhead label.
  • row_label::Vector{ExcelPair}: Style for the row label.
  • row_group_label::Vector{ExcelPair}: Style for the row group label.
  • first_line_column_label::Union{Vector{ExcelPair}, Vector{Vector{ExcelPair}}}: Style for the first line of the column labels. If a vector of Vector{ExcelPair} is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{Vector{ExcelPair}, Vector{Vector{ExcelPair}}}: Style for the rest of the column labels. If a vector of Vector{ExcelPair} is provided, each column label will use the corresponding style.
  • first_line_merged_column_label::Vector{ExcelPair}: Style for the merged cells at the first column label line.
  • merged_column_label::Vector{ExcelPair}: Style for the merged cells at the rest of the column labels.
  • data_cell::Vector{ExcelPair}: Style for the table cells.
  • summary_row_label::Vector{ExcelPair}: Style for the summary row label.
  • summary_row_cell::Vector{ExcelPair}: Style for the summary row cell.
  • footnote::Vector{ExcelPair}: Style for the footnotes.
  • source_note::Vector{ExcelPair}: Style for the source notes.

Each field corresponds to a table element and should be a vector of ExcelPair, i.e. Pair{String, String}, describing properties and values compatible with the XLSX.setFont function.

Fill (background color) attributes for a cell can also be included in the same field by prefixing their keys with "cell_fill_". Any pair whose key starts with "cell_fill_" is routed to XLSX.setFill (with the prefix stripped) instead of XLSX.setFont. Font and fill pairs may be mixed freely within a single field.

It is only necessary to define those fields for which the default style needs to be overwritten. For example:

style = ExcelTableStyle(
    column_label                   = [["bold" => "true"], ["color" => "red"]], # assuming two columns
    summary_row_label              = ["size" => "8"],
    first_line_merged_column_label = ["bold" => "true", "color" => "orange"],
    footnote                       = ["italic" => "true", "color" => "cyan"],
    row_group_label                = ["bold" => "true", "color" => "magenta"],
    subtitle                       = ["italic" => "true"],
    title                          = ["bold" => "true", "cell_fill_pattern" => "solid", "cell_fill_fgColor" => "black"],
)

Every keyword of the constructor of ExcelTableStyle also accepts a Face, which is converted to Excel attributes with excel_decoration (see Faces).

source
PrettyTables.pretty_table_html_backendFunction

PrettyTables.jl HTML Backend

The HTML backend can be selected by passing the keyword backend = :html to the function pretty_table. In this case, we have the following additional keywords to configure the output.

Keywords

  • allow_html_in_cells::Bool: If true, the content of the cells can contain HTML code. This can be useful to render tables with more complex content, but it can also be a security risk if the content is not sanitized. (Default: false)
  • column_label_titles::Union{Nothing, AbstractVector}: Titles for the column labels. If nothing, no titles are added. If a vector is passed, it must have the same length as the number of column label rows. Each element in the vector can be nothing (no title for that row) or an element with the title for that row. Notice that this element will be converted to string using the function string. (Default: nothing)
  • highlighters::Vector{<:AbstractHighlighter}: Highlighters to apply to the table. For more information, see the section HTML Highlighters in the Extended Help.
  • line_breaks::Bool: If true, line breaks in the content of the cells (\n) are replaced by the HTML tag <br>. (Default: false)
  • maximum_column_width::String: CSS width string for the maximum column width. (Default: "")
  • minify::Bool: If true, the output HTML code is minified. (Default: false)
  • stand_alone::Bool: If true, the output HTML code is a complete HTML document. (Default: false)
  • style::Union{TableStyle, HtmlTableStyle}: Style of the table. The fields of the backend-agnostic TableStyle override the ones of the default HTML table style. For more information, see the section HTML Table Style in the Extended Help.
  • table_class::String: Class for the table. (Default: "")
  • table_div_class::String: Class for the div containing the table. It is only used if wrap_table_in_div is true. (Default: "")
  • table_format::Union{TableFormat, HtmlTableFormat}: HTML table format used to render the table. The fields of the backend-agnostic TableFormat override the ones of the default HTML table format. For more information, see the section HTML Table Format in the Extended Help.
  • top_left_string::String: String to put in the top left corner div. (Default: "")
  • top_right_string::String: String to put in the top right corner div. Notice that this information is replaced if we are printing the omitted cell summary. (Default: "")
  • wrap_table_in_div::Bool: If true, the table is wrapped in a div. (Default: false)

Extended Help

HTML Highlighters

A set of highlighters can be passed as a vector of AbstractHighlighter to the highlighters keyword. A highlighter can be an instance of the structure HtmlHighlighter, specific to this back end, or of the general Highlighter, which is defined by a Face and works with every back end (see Faces). The face is converted with html_decoration. The structure HtmlHighlighter contains the following two public fields:

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature f(h, data, i, j) in which h is the highlighter. This function must return a Vector{Pair{String, String}} with properties compatible with the style field that will be applied to the highlighted cell.

An HTML highlighter can be constructed using three helpers:

HtmlHighlighter(f::Function, decoration::Vector{Pair{String, String}})

HtmlHighlighter(f::Function, decoration::HtmlPair)

HtmlHighlighter(f::Function, fd::Function)

The first two apply a fixed decoration to the highlighted cell, whereas the third lets the user select the desired decoration by specifying the function fd.

Note

If multiple highlighters are valid for the element (i, j), the applied style will be equal to the first match considering the order in the vector highlighters.

Note

If the highlighters are used together with Formatters, the change in the format will not affect the parameter data passed to the highlighter function f. It will always receive the original, unformatted value.

For example, if we want to highlight the cells with value greater than 5 in red, and all cells with values less than 5 in blue, we can define:

hl_gt5 = HtmlHighlighter(
    (data, i, j) -> data[i, j] > 5,
    ["color" => "red"]
)

hl_lt5 = HtmlHighlighter(
    (data, i, j) -> data[i, j] < 5,
    ["color" => "blue"]
)

highlighters = [hl_gt5, hl_lt5]

HTML Table Format

The HTML table format is defined using an object of type HtmlTableFormat. Besides the fields css and table_width, which are only applied if stand_alone = true, it contains the field borders, an object of type HtmlTableBorders with the CSS border shorthand value of each line role, and a set of boolean fields selecting which horizontal and vertical lines are drawn. For the list of fields, see the documentation of HtmlTableFormat.

By default, no lines are drawn and the emitted code has no border decoration, allowing the table appearance to be fully customized with CSS. When enabled, the table lines are emitted as inline styles in the table elements (the line at the beginning of the table is emitted in the <table> element). Hence, they are applied in any rendering mode, including when the table is embedded in another document (Jupyter, Pluto, Documenter, etc.). As in the text back end, the footnotes and source notes are outside the ruled area.

The following macros are available to help configuring the table lines:

  • @html__all_horizontal_lines: Return the keyword arguments to show all horizontal lines.
  • @html__all_vertical_lines: Return the keyword arguments to show all vertical lines.
  • @html__no_horizontal_lines: Return the keyword arguments to suppress all horizontal lines.
  • @html__no_vertical_lines: Return the keyword arguments to suppress all vertical lines.

For example, we can draw all the vertical lines as follows:

table_format = HtmlTableFormat(; @html__all_vertical_lines)

The backend-agnostic TableFormat is also supported: its line designs are converted to CSS border values with html_line_style, and its line presence fields override the corresponding fields of the default HTML table format.

HTML Table Style

The HTML table style is defined using an object of type HtmlTableStyle that contains the following fields:

  • top_left_string::Vector{HtmlPair}: Style for the top left string.
  • top_right_string::Vector{HtmlPair}: Style for the top right string.
  • table::Vector{HtmlPair}: Style for the table.
  • title::Vector{HtmlPair}: Style for the title.
  • subtitle::Vector{HtmlPair}: Style for the subtitle.
  • row_number_label::Vector{HtmlPair}: Style for the row number label.
  • row_number::Vector{HtmlPair}: Style for the row number.
  • stubhead_label::Vector{HtmlPair}: Style for the stubhead label.
  • row_label::Vector{HtmlPair}: Style for the row label.
  • row_group_label::Vector{HtmlPair}: Style for the row group label.
  • first_line_column_label::Union{Vector{HtmlPair}, Vector{Vector{HtmlPair}}}: Style for the first line of the column labels. If a vector of Vector{HtmlPair} is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{Vector{HtmlPair}, Vector{Vector{HtmlPair}}}: Style for the rest of the column labels. If a vector of Vector{HtmlPair} is provided, each column label will use the corresponding style.
  • first_line_merged_column_label::Vector{HtmlPair}: Style for the merged cells at the first column label line.
  • merged_column_label::Vector{HtmlPair}: Style for the merged cells at the rest of the column labels.
  • summary_row_cell::Vector{HtmlPair}: Style for the summary row cell.
  • summary_row_label::Vector{HtmlPair}: Style for the summary row label.
  • footnote::Vector{HtmlPair}: Style for the footnote.
  • source_note::Vector{HtmlPair}: Style for the source notes.

Each field is a vector of HtmlPair, i.e. Pair{String, String}, describing properties and values compatible with the HTML style attribute.

For example, if we want the stubhead label to be bold and red, we must define:

style = HtmlTableStyle(
    stubhead_label = ["font-weight" => "bold", "color" => "red"]
)

Every keyword of the constructor of HtmlTableStyle also accepts a Face, which is converted to CSS properties with html_decoration (see Faces).

source
PrettyTables.pretty_table_latex_backendFunction

PrettyTables.jl LaTeX Backend

The LaTeX backend can be selected by passing the keyword backend = :latex to the function pretty_table. In this case, we have the following additional keywords to configure the output.

Keywords

  • highlighters::Vector{<:AbstractHighlighter}: Highlighters to apply to the table. For more information, see the section LaTeX Highlighters in the Extended Help.
  • style::Union{TableStyle, LatexTableStyle}: Style of the table. The fields of the backend-agnostic TableStyle override the ones of the default LaTeX table style. For more information, see the section LaTeX Table Style in the Extended Help.
  • table_format::Union{TableFormat, LatexTableFormat}: LaTeX table format used to render the table. The line presence fields of the backend-agnostic TableFormat are fully supported, and the line design is converted by latex_line_style (best effort: width and color are ignored, and the vertical line designs cannot be changed). For more information, see the section LaTeX Table Format in the Extended Help.

Extended Help

LaTeX Highlighters

A set of highlighters can be passed as a vector of AbstractHighlighter to the highlighters keyword. A highlighter can be an instance of the structure LatexHighlighter, specific to this back end, or of the general Highlighter, which is defined by a Face and works with every back end (see Faces). The face is converted with latex_decoration. The structure LatexHighlighter contains the following two public fields:

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature f(h, data, i, j) in which h is the highlighter. This function must return a Vector{String} with the LaTeX environments to be applied to the cell.

A LaTeX highlighter can be constructed using two helpers:

LatexHighlighter(f::Function, envs::Vector{String})

where it will apply recursively all the LaTeX environments in envs to the highlighted text, and

LatexHighlighter(f::Function, fd::Function)

where the user selects the desired decoration by specifying the function fd.

Note

If multiple highlighters are valid for the element (i, j), the applied style will be equal to the first match considering the order in the vector highlighters.

Note

If the highlighters are used together with Formatters, the change in the format will not affect the parameter data passed to the highlighter function f. It will always receive the original, unformatted value.

For example, if we want to make the cells with value greater than 5 bold, and all the cells with value less than 5 small, we can define:

hl_gt5 = LatexHighlighter(
    (data, i, j) -> data[i, j] > 5,
    ["textbf"]
)

hl_lt5 = LatexHighlighter(
    (data, i, j) -> data[i, j] < 5,
    ["small"]
)

highlighters = [hl_gt5, hl_lt5]

LaTeX Table Format

The LaTeX table format is defined using an object of type LatexTableFormat that contains the following fields:

  • borders::LatexTableBorders: Format of the borders.
  • horizontal_line_at_beginning::Bool: If true, a horizontal line will be drawn at the beginning of the table.
  • horizontal_line_at_merged_column_labels::Bool: If true, a horizontal line will be drawn on bottom of the merged column labels using \cline.
  • horizontal_line_after_column_labels::Bool: If true, a horizontal line will be drawn after the column labels.
  • horizontal_lines_at_data_rows::Union{Symbol, Vector{Int}}: A horizontal line will be drawn after each data row index listed in this vector. If the symbol :all is passed, a horizontal line will be drawn after every data row. If the symbol :none is passed, no horizontal lines will be drawn after the data rows.
  • horizontal_line_before_row_group_label::Bool: If true, a horizontal line will be drawn before the row group label.
  • horizontal_line_after_row_group_label::Bool: If true, a horizontal line will be drawn after the row group label.
  • horizontal_line_after_data_rows::Bool: If true, a horizontal line will be drawn after the data rows.
  • horizontal_line_before_summary_rows::Bool: If true, a horizontal line will be drawn before the summary rows. Notice that this line is the same as the one drawn if horizontal_line_after_data_rows is true. However, in this case, the line is omitted if there are no summary rows.
  • horizontal_line_after_summary_rows::Bool: If true, a horizontal line will be drawn after the summary rows.
  • vertical_line_at_beginning::Bool: If true, a vertical line will be drawn at the beginning of the table.
  • vertical_line_after_row_number_column::Bool: If true, a vertical line will be drawn after the row number column.
  • vertical_line_after_row_label_column::Bool: If true, a vertical line will be drawn after the row label column.
  • vertical_lines_at_data_columns::Union{Symbol, Vector{Int}}: A vertical line will be drawn after each data column index listed in this vector. If the symbol :all is passed, a vertical line will be drawn after every data row. If the symbol :none is passed, no vertical lines will be drawn after the data columns.
  • vertical_line_after_data_columns::Bool: If true, a vertical line will be drawn after the data columns.
  • vertical_line_after_continuation_column::Bool: If true, a vertical line will be drawn after the continuation column.

We provide a few helpers to configure the table format. For more information, see the documentation of the following macros:

LaTeX Table Style

The LaTeX table style is defined using an object of type LatexTableStyle that contains the following fields:

  • title::LatexEnvironments: Latex environments with the style for the title.
  • subtitle::LatexEnvironments: Latex environments with the style for the subtitle.
  • row_number_label::LatexEnvironments: Latex environments with the style for the row number label.
  • row_number::LatexEnvironments: Latex environments with the style for the row numbers.
  • stubhead_label::LatexEnvironments: Latex environments with the style for the stubhead label.
  • row_label::LatexEnvironments: Latex environments with the style for the row labels.
  • row_group_label::LatexEnvironments: Latex environments with the style for the row group label.
  • first_line_column_label::Union{LatexEnvironments, Vector{LatexEnvironments}}: Latex environments with the style for the first line of the column labels. If a vector of LatexEnvironments is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{LatexEnvironments, Vector{LatexEnvironments}}: Latex environments with the style for the rest of the column labels. If a vector of LatexEnvironments is provided, each column label will use the corresponding style.
  • first_line_merged_column_label::LatexEnvironments: Latex environments with the style for the merged cells at the first column label line.
  • merged_column_label::LatexEnvironments: Latex environments with the style for the merged cells at the rest of the column labels.
  • summary_row_cell::LatexEnvironments: Latex environments with the style for the summary row cell.
  • summary_row_label::LatexEnvironments: Latex environments with the style for the summary row label.
  • footnote::LatexEnvironments: Latex environments with the style for the footnotes.
  • source_note::LatexEnvironments: Latex environments with the style for the source notes.
  • omitted_cell_summary::LatexEnvironments: Latex environments with the style for the omitted cell summary.

Each field is a LatexEnvironments object, which is a vector of strings with the LaTeX environments to be applied to the corresponding element.

For example, if we want to make the stubhead label bold and red, we must define:

style = LatexTableStyle(
    stubhead_label = ["textbf", "color{red}"]
)

Every keyword of the constructor of LatexTableStyle also accepts a Face, which is converted to LaTeX environments with latex_decoration (see Faces).

Note

The LaTeX back end does not write any preamble. Hence, the packages xcolor and ulem must be loaded in the document if a face has colors or a strikethrough.

source
PrettyTables.pretty_table_markdown_backendFunction

PrettyTables.jl Markdown Backend

The markdown backend can be selected by passing the keyword backend = :markdown to the function pretty_table. In this case, we have the following additional keywords to configure the output.

Keywords

  • allow_markdown_in_cells::Bool: If true, the content of the cells can contain markdown code. (Default: false)
  • highlighters::Vector{<:AbstractHighlighter}: Highlighters to apply to the table. For more information, see the section Markdown Highlighters in the Extended Help.
  • line_breaks::Bool: If true, line breaks in the content of the cells (\n) are replaced by <br>. (Default: false)
  • style::Union{TableStyle, MarkdownTableStyle}: Style of the table. The fields of the backend-agnostic TableStyle override the ones of the default Markdown table style, except for title, subtitle, first_line_merged_column_label, and merged_column_label, which are ignored. For more information, see the section Markdown Table Style in the Extended Help.
  • table_format::Union{TableFormat, MarkdownTableFormat}: Markdown table format used to render the table. From the backend-agnostic TableFormat, only horizontal_line_before_summary_rows is honored because Markdown tables cannot express the other lines. For more information, see the section Markdown Table Format in the Extended Help.

Extended Help

Markdown Highlighters

A set of highlighters can be passed as a vector of AbstractHighlighter to the highlighters keyword. A highlighter can be an instance of the structure MarkdownHighlighter, specific to this back end, or of the general Highlighter, which is defined by a Face and works with every back end (see Faces). The face is converted with markdown_decoration. The structure MarkdownHighlighter contains the following two public fields:

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature fd(h, data, i, j) in which h is the highlighter. This function must return the MarkdownStyle to be applied to the

cell that must be highlighted.

The function f has the following signature:

f(data, i, j)

in which data is a reference to the data that is being printed, and i and j are the element coordinates that are being tested. If this function returns true, the highlight style will be applied to the (i, j) element. Otherwise, the default style will be used.

If the function f returns true, the function fd(h, data, i, j) will be called and must return an element of type MarkdownStyle that contains the decoration to be applied to the cell.

A markdown highlighter can be constructed using two helpers:

MarkdownHighlighter(f::Function, decoration::MarkdownStyle)

MarkdownHighlighter(f::Function, fd::Function)

The first will apply a fixed decoration to the highlighted cell specified in decoration, whereas the second lets the user select the desired decoration by specifying the function fd.

Note

If multiple highlighters are valid for the element (i, j), the applied style will be equal to the first match considering the order in the vector highlighters.

Note

If the highlighters are used together with Formatters, the change in the format will not affect the parameter data passed to the highlighter function f. It will always receive the original, unformatted value.

Markdown Table Format

The markdown table format is defined using an object of type MarkdownTableFormat that contains the following fields:

  • title_heading_level::Int: Title heading level.
  • subtitle_heading_level::Int: Subtitle heading level.
  • horizontal_line_char::Char: Character used to draw the horizontal line.
  • line_before_summary_rows::Bool: Whether to draw a line before the summary rows.
  • compact_table::Bool: If true, the table is printed in a compact format without extra spaces between columns.

Markdown Table Style

The markdown table style is defined using an object of type MarkdownTableStyle that contains the following fields:

  • row_number_label::MarkdownStyle: Style for the row number label.
  • row_number::MarkdownStyle: Style for the row number.
  • stubhead_label::MarkdownStyle: Style for the stubhead label.
  • row_label::MarkdownStyle: Style for the row label.
  • row_group_label::MarkdownStyle: Style for the row group label.
  • first_line_column_label::Union{MarkdownStyle, Vector{MarkdownStyle}}: Style for the first line of the column label. If a vector of MarkdownStyle is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{MarkdownStyle, Vector{MarkdownStyle}}: Style for the column label. If a vector of MarkdownStyle is provided, each column label will use the corresponding style.
  • summary_row_label::MarkdownStyle: Style for the summary row label.
  • summary_row_cell::MarkdownStyle: Style for the summary row cell.
  • footnote::MarkdownStyle: Style for the footnote.
  • source_note::MarkdownStyle: Style for the source note.
  • omitted_cell_summary::MarkdownStyle: Style for the omitted cell summary.

Each field is an instance of the structure MarkdownStyle describing the style to be applied to the corresponding element.

For example, if we want the stubhead label to be bold and italic, we must define:

style = MarkdownTableStyle(
    stubhead_label = MarkdownStyle(bold = true, italic = true)
)

Every keyword of the constructor of MarkdownTableStyle also accepts a Face, which is converted to MarkdownStyle with markdown_decoration (see Faces).

source
PrettyTables.pretty_table_text_backendFunction

PrettyTables.jl Text Backend

The text backend can be selected by passing the keyword backend = :text to the function pretty_table. In this case, we have the following additional keywords to configure the output.

Keywords

  • alignment_anchor_fallback::Symbol: This keyword controls the line alignment when using the regex alignment anchors if a match is not found. If it is :l, the left of the line will be aligned with the anchor. If it is :c, the line center will be aligned with the anchor. Otherwise, the end of the line will be aligned with the anchor. (Default = :l)
  • alignment_anchor_regex::Union{Vector{Regex}, Vector{Pair{Int, Vector{Regex}}}}: This keyword can be used to provide regexes to align the data values in the table columns. If it is Vector{Regex}, the regexes will be used to align all the columns. If it is Vector{Pair{Int, Vector{Regex}}}, the Int element specifies the column to which the regexes in Vector{Regex} will be applied. The regex match is searched in the same order as the regexes appear on the vector. The regex matching is applied after the cell conversion to string, which includes the formatters. If no match is found for a specific line, the alignment of this line depends on the option alignment_anchor_fallback. Example: [2 => [r"\."]] aligns the decimal point of the cells in the second column. (Default = Regex[])
  • apply_alignment_regex_to_summary_rows::Bool: If true, the alignment regexes in alignment_anchor_regex will also be applied to the summary rows. (Default = false)
  • auto_wrap::Bool: If true, the text will be wrapped on spaces to fit the column. Note that this option automatically enables line_breaks and the column must have a fixed size (see fixed_data_column_widths). (Default = false)
  • column_label_width_based_on_first_line_only::Bool: If true, the column label width is based on the first line of the column. Hence, if the other column labels have text width larger than the computed column width, they will be cropped to fit. (Default = false)
  • display_size::Tuple{Int, Int}: A tuple of two integers that defines the display size (num. of rows, num. of columns) that is available to print the table. It is used to crop the data depending on the values of the keywords fit_table_in_display_horizontally and fit_table_in_display_vertically. Notice that if a dimension is not positive, it will be treated as unlimited. (Default = displaysize(io))
  • equal_data_column_widths::Bool: If true, the data columns will have the same width. (Default = false)
  • fit_table_in_display_horizontally::Bool: If true, the table will be cropped to fit the display horizontally. (Default = true)
  • fit_table_in_display_vertically::Bool: If true, the table will be cropped to fit the display vertically. (Default = true)
  • fixed_data_column_widths::Union{Int, Vector{Int}}: If it is a Vector{Int}, this vector specifies the width of each column. If it is a Int, this number will be used as the width of all columns. If the width is equal to or lower than 0, it will be automatically computed to fit the largest cell in the column. (Default = 0)
  • highlighters::Vector{<:AbstractHighlighter}: Highlighters to apply to the table. For more information, see the section Text Highlighters in the Extended Help.
  • line_breaks::Bool: If true, a new line character will break the line inside the cells. (Default = false)
  • maximum_data_column_widths::Union{Int, Vector{Int}}: If it is a Vector{Int}, this vector specifies the maximum width of each column. If it is an Int, this number will be used as the maximum width of all columns. If the maximum width is equal to or lower than 0, it will be ignored. Notice that the parameter fixed_data_column_widths has precedence over this one. (Default = 0)
  • minimum_data_column_widths::Union{Int, Vector{Int}}: If it is a Vector{Int}, this vector specifies the minimum width of each column. If it is an Int, this number will be used as the minimum width of all columns. If the minimum width is equal to or lower than 0, it will be ignored. Notice that the parameter fixed_data_column_widths has precedence over this one. (Default = 0)
  • overwrite_display::Bool: If true, the same number of lines in the printed table will be deleted from the output io. This can be used to update the table in the display continuously. (Default = false)
  • reserved_display_lines::Int: Number of lines to be left at the beginning of the printing when vertically cropping the output. (Default = 0)
  • shrinkable_column_minimum_width::Int: If it is a positive integer (> 0), this is the minimum width of the shrinkable column (see shrinkable_data_column). (Default = 0)
  • shrinkable_data_column::Int: If it is a positive integer, this column will be shrinkable. This means that if the table does not fit in the display, this column will be shrunk to fit the table in the display. If it is 0 or negative, no column will be shrinkable. (Default = 0)
  • style::Union{TableStyle, TextTableStyle}: Style of the table. The fields of the backend-agnostic TableStyle override the ones of the default text table style. For more information, see the section Text Table Style in the Extended Help.
  • table_format::Union{TableFormat, TextTableFormat}: Text table format used to render the table. The line presence and line design fields of the backend-agnostic TableFormat are fully supported, where the line designs are mapped to box-drawing characters. For more information, see the section Text Table Format in the Extended Help.

Extended Help

Text highlighters

A set of highlighters can be passed as a vector of AbstractHighlighter to the highlighters keyword. A highlighter is an instance of the structure TextHighlighter, specific to this back end, or of the general Highlighter, which works with every back end (see Faces). A TextHighlighter contains the following fields:

  • f::Function: Function with the signature f(data, i, j) which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature fd(h, data, i, j) in which h is the highlighter. This function must return the Face (or Crayon) to be applied to the cell that must be highlighted.
  • _decoration::Face: The Face to be applied to the highlighted cell if the default fd is used.

The function f has the following signature:

f(data, i, j)

in which data is a reference to the data that is being printed, and i and j are the element coordinates that are being tested. If this function returns true, the cell (i, j) will be highlighted.

If the function f returns true, the function fd(h, data, i, j) will be called and must return a Face (or a Crayon, converted to a face) that will be applied to the cell.

A highlighter can be constructed using the following helpers:

TextHighlighter(f::Function; kwargs...)

where it will construct a Face using the keywords in kwargs and apply it to the highlighted cell. The keywords can be the ones of Face (weight, slant, foreground, background, underline, strikethrough, inverse, ...) or the ones of Crayon (bold, faint, italics, negative, foreground, background, underline, strikethrough), which are translated to the equivalent face attributes,

TextHighlighter(f::Function, face::Face)
TextHighlighter(f::Function, crayon::Crayon)

where it will apply the face (or the crayon, converted to a face) to the highlighted cell, and

TextHighlighter(f::Function, fd::Function)

where it will apply the Face (or Crayon) returned by the function fd to the highlighted cell.

Note

If multiple highlighters are valid for the element (i, j), the applied style will be equal to the first match considering the order in the vector highlighters.

Note

If the highlighters are used together with Formatters, the change in the format will not affect the parameter data passed to the highlighter function f. It will always receive the original, unformatted value.

For example, if we want to highlight the cells with value greater than 5 in red, and all the cells with value less than 5 in blue, we can define:

hl_gt5 = TextHighlighter(
    (data, i, j) -> data[i, j] > 5,
    Face(; foreground = :red)
)

hl_lt5 = TextHighlighter(
    (data, i, j) -> data[i, j] < 5,
    crayon"blue"
)

highlighters = [hl_gt5, hl_lt5]

Text Table Format

The text table format is defined using an object of type TextTableFormat that contains the following fields:

  • borders::TextTableBorders: Format of the borders.
  • top_line::Union{Nothing, TextTableLine}: Characters of the top line.
  • header_line::Union{Nothing, TextTableLine}: Characters of the lines at the column labels.
  • merged_header_cell_line::Union{Nothing, TextTableLine}: Characters of the lines under the merged column labels.
  • middle_line::Union{Nothing, TextTableLine}: Characters of the lines inside the table.
  • bottom_line::Union{Nothing, TextTableLine}: Characters of the bottom line.
  • left_line::Union{Nothing, Char}: Character of the vertical line at the left of the table.
  • center_line::Union{Nothing, Char}: Character of the vertical lines inside the table.
  • right_line::Union{Nothing, Char}: Character of the vertical line at the right of the table.
  • horizontal_line_at_beginning::Bool: If true, a horizontal line will be drawn at the beginning of the table.
  • horizontal_lines_at_column_labels::Union{Symbol, Vector{Int}}: A horizontal line will be drawn after each column label row index listed in this vector. If the symbol :all is passed, a horizontal line will be drawn after every column label. If the symbol :none is passed, no horizontal lines will be drawn.
  • horizontal_line_at_merged_column_labels::Bool: If true, a horizontal line will be drawn at the merged column labels. Notice that the horizontal line drawn using the option horizontal_lines_at_column_labels has precedence over this one.
  • horizontal_line_after_column_labels::Bool: If true, a horizontal line will be drawn after the column labels.
  • horizontal_lines_at_data_rows::Union{Symbol, Vector{Int}}: A horizontal line will be drawn after each data row index listed in this vector. If the symbol :all is passed, a horizontal line will be drawn after every data row. If the symbol :none is passed, no horizontal lines will be drawn.
  • horizontal_line_before_row_group_label::Bool: If true, a horizontal line will be drawn before the row group label.
  • horizontal_line_after_row_group_label::Bool: If true, a horizontal line will be drawn after the row group label.
  • horizontal_line_after_data_rows::Bool: If true, a horizontal line will be drawn after the data rows.
  • horizontal_line_before_summary_rows::Bool: If true, a horizontal line will be drawn before the summary rows. Notice that this line is the same as the one drawn if horizontal_line_after_data_rows is true. However, in this case, the line is omitted if there are no summary rows.
  • horizontal_line_after_summary_rows::Bool: If true, a horizontal line will be drawn after the summary rows.
  • vertical_line_at_beginning::Bool: If true, a vertical line will be drawn at the beginning of the table.
  • vertical_line_after_row_number_column::Bool: If true, a vertical line will be drawn after the row number column.
  • vertical_line_after_row_label_column::Bool: If true, a vertical line will be drawn after the row label column.
  • vertical_lines_at_data_columns::Union{Symbol, Vector{Int}}: A vertical line will be drawn after each data column index listed in this vector. If the symbol :all is passed, a vertical line will be drawn after every data column. If the symbol :none is passed, no vertical lines will be drawn after the data columns.
  • vertical_line_after_data_columns::Bool: If true, a vertical line will be drawn after the data columns.
  • vertical_line_after_continuation_column::Bool: If true, a vertical line will be drawn after the continuation column.
  • suppress_vertical_lines_at_column_labels::Bool: If true, the vertical lines inside the column label rows will be suppressed.
  • ellipsis_line_skip::Integer: Number of lines to skip when printing an ellipsis.

The line character fields allow the user to customize the characters of each table line independently, sparsely overriding the characters in borders for that line (see TextTableLine). When printing with the backend-agnostic TableFormat, each LineStyle is mapped to Unicode box-drawing characters, where the intersections between the lines are selected automatically from the crossing designs.

We provide a few helpers to configure the table format. For more information, see the documentation of the following macros:

Text Table Style

The text table style is defined using an object of type TextTableStyle that contains the following fields:

  • title::Face: Face with the style for the title.
  • subtitle::Face: Face with the style for the subtitle.
  • row_number_label::Face: Face with the style for the row number label.
  • row_number::Face: Face with the style for the row numbers.
  • stubhead_label::Face: Face with the style for the stubhead label.
  • row_label::Face: Face with the style for the row labels.
  • row_group_label::Face: Face with the style for the row group label.
  • first_line_column_label::Union{Face, Vector{Face}}: Face or faces with the style for the first column label lines. If a vector of faces is passed, it must have the same length as the number of columns in the table.
  • column_label::Union{Face, Vector{Face}}: Face or faces with the style for the rest of the column labels. If a vector of faces is passed, it must have the same length as the number of columns in the table.
  • first_line_merged_column_label::Face: Face with the style for the merged cells at the first column label line.
  • merged_column_label::Face: Face with the style for the merged cells at the rest of the column labels.
  • summary_row_cell::Face: Face with the style for the summary row cell.
  • summary_row_label::Face: Face with the style for the summary row label.
  • footnote::Face: Face with the style for the footnotes.
  • source_note::Face: Face with the style for the source notes.
  • omitted_cell_summary::Face: Face with the style for the omitted cell summary.
  • table_border::Face: Face with the style for the table border.
  • top_line::Union{Nothing, Face}: Face with the style for the top line.
  • header_line::Union{Nothing, Face}: Face with the style for the lines at the column labels.
  • merged_header_cell_line::Union{Nothing, Face}: Face with the style for the lines under the merged column labels.
  • middle_line::Union{Nothing, Face}: Face with the style for the lines inside the table.
  • bottom_line::Union{Nothing, Face}: Face with the style for the bottom line.
  • left_line::Union{Nothing, Face}: Face with the style for the vertical line at the left of the table.
  • center_line::Union{Nothing, Face}: Face with the style for the vertical lines inside the table.
  • right_line::Union{Nothing, Face}: Face with the style for the vertical line at the right of the table.

Each field is a Face describing the style for the corresponding element in the table. The keyword constructor also accepts a Crayon (or a vector of crayons) in every field, which is converted to the equivalent face (see Faces).

The line faces default to nothing, meaning that the corresponding line is rendered with the face in table_border. When printing with the backend-agnostic TableFormat, the color of each line design is converted to the corresponding line face, unless the line face is explicitly set, which has the highest precedence.

For example, if we want that the stubhead label is bold and red, we must define:

style = TextTableStyle(
    stubhead_label = Face(; weight = :bold, foreground = :red)
)

or, equivalently, using a crayon:

style = TextTableStyle(
    stubhead_label = crayon"bold red"
)
source
PrettyTables.pretty_table_typst_backendFunction

PrettyTables.jl Typst Backend

The Typst backend can be selected by passing the keyword backend = :typst to the function pretty_table. In this case, we have the following additional keywords to configure the output:

Keywords

  • annotate::Bool: Boolean indicating whether Typst code should be annotated.
  • caption::Union{Nothing, String, TypstCaption}: Table caption to be used by the Typst #figure function. The user can provide additional configuration to the caption by using the TypstCaption structure.
  • data_column_widths::Union{Nothing, String, Vector{String}, Vector{Pair{Int, String}}}: Column widths for the data columns. The information must be a valid length information in Typst, such as "10fr" or "30pt". If a single string is provided, it will be repeated for all columns. If a vector of strings is provided, its length must be equal to or larger than the number of printed columns. Alternatively, a vector of pairs can be provided, where the first element of the pair is the column index and the second element is the width for that column. In this case, columns that are not specified will have width auto. (Default = nothing)
  • highlighters::Vector{<:AbstractHighlighter}: Highlighters to apply to the table. For more information, see the section Typst Highlighters in the Extended Help. (Default = TypstHighlighter[])
  • minify::Bool: If true, the generated Typst code will be minified by ignoring wrap_column and printing the table columns in the same line. (Default = false)
  • style::Union{TableStyle, TypstTableStyle}: Style of the table. The fields of the backend-agnostic TableStyle override the ones of the default Typst table style. For more information, see the section Typst Table Style in the Extended Help. (Default = TypstTableStyle())
  • table_format::Union{TableFormat, TypstTableFormat}: Typst table format used to render the table. The backend-agnostic TableFormat is fully supported: its line presence fields override the ones of the default Typst table format, and the line design is converted to strokes by typst_line_style. For more information, see the section Typst Table Format in the Extended Help.
  • wrap_column::Integer: Indicates the column where the output will be wrapped. (Default = 92)
Note

The content in the cells is always escaped. If you want to use a raw Typst component as cell, load the package Typstry.jl and pass the cell content as a TypstString. In this case, the content will not be escaped and will be treated as a raw Typst component.

Extended Help

Typst Highlighters

A set of highlighters can be passed as a vector of AbstractHighlighter to the highlighters keyword. A highlighter can be an instance of the structure TypstHighlighter, specific to this back end, or of the general Highlighter, which is defined by a Face and works with every back end (see Faces). The face is converted with typst_decoration. The structure TypstHighlighter contains the following two public fields:

  • f::Function: Function with the signature f(data, i, j), which should return true if the element (i, j) in data must be highlighted, or false otherwise.
  • fd::Function: Function with the signature f(h, data, i, j), where h is the highlighter. This function must return a Vector{Pair{String, String}} with properties compatible with the style field that will be applied to the highlighted cell.

A Typst highlighter can be constructed using three helpers:

TypstHighlighter(f::Function, decoration::Vector{Pair{String, String}})

TypstHighlighter(f::Function, decoration::TypstPair)

TypstHighlighter(f::Function, fd::Function)

The first two apply a fixed decoration to the highlighted cell specified in decoration, whereas the third lets the user select the desired decoration by specifying the function fd.

Note

If multiple highlighters are valid for element (i, j), the applied style is the first match according to the order in the vector highlighters.

Note

If highlighters are used together with Formatters, formatting changes will not affect the parameter data passed to the highlighter function f. It will always receive the original, unformatted value.

For example, if we want to highlight the cells with value greater than 5 in red, and all cells with values less than 5 in blue, we can define:

hl_gt5 = TypstHighlighter(
    (data, i, j) -> data[i, j] > 5,
    ["text-fill" => "red"]
)

hl_lt5 = TypstHighlighter(
    (data, i, j) -> data[i, j] < 5,
    ["text-fill" => "blue"]
)

highlighters = [hl_gt5, hl_lt5]

Each cell with properties is rendered with one call to #text inside a table.cell function, as shown below:

table.cell()[#text()[Cell Content]]
Note

Since table.cell and #text() share some attribute names, attributes used by the #text function must be defined with the text- prefix. For example, to create a table style (or highlighter) that sets a blue background and white font color:

["fill" => "blue", "text-fill" => "white"]

Typst Table Format

The Typst table format is defined using an object of type TypstTableFormat that contains the following fields:

  • borders::TypstTableBorders: Format of the borders.
  • horizontal_line_at_beginning::Bool: If true, a horizontal line will be drawn at the beginning of the table.
  • horizontal_line_at_merged_column_labels::Bool: If true, a horizontal line will be drawn at the bottom of the merged column labels using table.hline.
  • horizontal_line_after_column_labels::Bool: If true, a horizontal line will be drawn after the column labels.
  • horizontal_lines_at_data_rows::Union{Symbol, Vector{Int}}: A horizontal line will be drawn after each data row index listed in this vector. If the symbol :all is passed, a horizontal line will be drawn after every data row. If the symbol :none is passed, no horizontal lines will be drawn after the data rows.
  • horizontal_line_before_row_group_label::Bool: If true, a horizontal line will be drawn before the row group label.
  • horizontal_line_after_row_group_label::Bool: If true, a horizontal line will be drawn after the row group label.
  • horizontal_line_after_data_rows::Bool: If true, a horizontal line will be drawn after the data rows.
  • horizontal_line_before_summary_rows::Bool: If true, a horizontal line will be drawn before the summary rows. Notice that this line is the same as the one drawn if horizontal_line_after_data_rows is true. However, in this case, the line is omitted if there are no summary rows.
  • horizontal_line_after_summary_rows::Bool: If true, a horizontal line will be drawn after the summary rows.
  • vertical_line_at_beginning::Bool: If true, a vertical line will be drawn at the beginning of the table.
  • vertical_line_after_row_number_column::Bool: If true, a vertical line will be drawn after the row number column.
  • vertical_line_after_row_label_column::Bool: If true, a vertical line will be drawn after the row label column.
  • vertical_lines_at_data_columns::Union{Symbol, Vector{Int}}: A vertical line will be drawn after each data column index listed in this vector. If the symbol :all is passed, a vertical line will be drawn after every data column. If the symbol :none is passed, no vertical lines will be drawn after the data columns.
  • vertical_line_after_data_columns::Bool: If true, a vertical line will be drawn after the data columns.
  • vertical_line_after_continuation_column::Bool: If true, a vertical line will be drawn after the continuation column.

We provide a few helpers to configure the table format. For more information, see the documentation of the following macros:

Typst Table Style

The Typst table style is defined using an object of type TypstTableStyle that contains the following fields:

  • table::Vector{TypstPair}: Style for the table.
  • title::Vector{TypstPair}: Style for the title.
  • subtitle::Vector{TypstPair}: Style for the subtitle.
  • row_number_label::Vector{TypstPair}: Style for the row number label.
  • row_number::Vector{TypstPair}: Style for the row number.
  • stubhead_label::Vector{TypstPair}: Style for the stubhead label.
  • row_label::Vector{TypstPair}: Style for the row label.
  • row_group_label::Vector{TypstPair}: Style for the row group label.
  • first_line_column_label::Union{Vector{TypstPair}, Vector{Vector{TypstPair}}}: Style for the first line of the column labels. If a vector of Vector{TypstPair} is provided, each column label in the first line will use the corresponding style.
  • column_label::Union{Vector{TypstPair}, Vector{Vector{TypstPair}}}: Style for the rest of the column labels. If a vector of Vector{TypstPair} is provided, each column label will use the corresponding style.
  • first_line_merged_column_label::Vector{TypstPair}: Style for the merged cells at the first column label line.
  • merged_column_label::Vector{TypstPair}: Style for the merged cells at the rest of the column labels.
  • summary_row_cell::Vector{TypstPair}: Style for the summary row cell.
  • summary_row_label::Vector{TypstPair}: Style for the summary row label.
  • footnote::Vector{TypstPair}: Style for the footnote.
  • omitted_cell_summary::Vector{TypstPair}: Style for the omitted cell summary.
  • source_note::Vector{TypstPair}: Style for the source notes.

Each field is a vector of TypstPair, i.e. Pair{String, String}, describing properties and values compatible with the Typst style attribute.

For example, if we want the stubhead label to be bold and red, we must define:

style = TypstTableStyle(
    stubhead_label = ["text-weight" => "bold", "text-fill" => "red"]
)

The user can pass any property compatible with the Typst style attribute. If the prefix text- is used, the property will be applied to the text of the cell. Otherwise, it will be applied to the cell itself.

Every keyword of the constructor of TypstTableStyle also accepts a Face, which is converted to Typst properties with typst_decoration (see Faces).

source
PrettyTables.typst_decorationMethod
typst_decoration(face::Face) -> Vector{TypstPair}

Convert the face of StyledStrings.jl into the Typst properties used by the Typst back end, which can be passed to a TypstHighlighter or to a field of TypstTableStyle.

The conversion is:

Face AttributeTypst Property
fonttext-font
height (Int, deci-points)text-size: <pt>pt
height (Float64, factor)text-size: <factor>em
weighttext-weight (:normalregular, :semilightlight)
slanttext-style: normal, italic, or oblique
foregroundtext-fill: rgb("#rrggbb")
backgroundfill: rgb("#rrggbb") (cell property)

The colors are resolved with StringManipulation.face_color_rgb, so that the default color of the terminal and unknown names are ignored. The attributes underline and strikethrough are ignored because Typst renders them with the functions underline and strike instead of text properties, as well as inverse and inherit.

Examples

julia> typst_decoration(Face(; weight = :bold, foreground = "#ff0000"))
2-element Vector{Pair{String, String}}:
 "text-weight" => "bold"
   "text-fill" => "rgb(\"#ff0000\")"
source
PrettyTables.typst_line_styleMethod
typst_line_style(line_style::LineStyle; default::String = "1pt") -> String

Convert line_style into a Typst stroke.

The width is converted to the thickness "0.5pt" (:thin), "1pt" (:medium), or "1.5pt" (:thick). If it is unset, the thickness is default when the latter is a bare length (for example, "1.5pt"), which is the form of the default strokes of TypstTableBorders; otherwise, the thickness is omitted and Typst uses its own default. The style is converted to the dash pattern "solid", "dashed", or "dotted"; :double has no Typst counterpart and falls back to "solid". The color is converted to the paint rgb("#rrggbb"); a color that cannot be resolved to a 24-bit value is omitted.

If only the thickness is available, the function returns the bare thickness (for example, "1.5pt"). Otherwise, it returns the dictionary stroke form with the available components (for example, "(thickness: 1.5pt, paint: rgb(\"#ff0000\"), dash: \"dashed\")").

source
PrettyTables.@all_horizontal_linesMacro
@all_horizontal_lines() -> Keywords for `TableFormat`

Return the keyword arguments to be passed to TableFormat to show all horizontal lines in any back end.

We can use the output of this function when creating the backend-agnostic table format object. For example, the following code creates a table format with all horizontal lines:

tf = TableFormat(; @all_horizontal_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the horizontal lines but the first one:

tf = TableFormat(; @all_horizontal_lines, horizontal_line_at_beginning = false)
source
PrettyTables.@all_vertical_linesMacro
@all_vertical_lines() -> Keywords for `TableFormat`

Return the keyword arguments to be passed to TableFormat to show all vertical lines in any back end.

We can use the output of this function when creating the backend-agnostic table format object. For example, the following code creates a table format with all vertical lines:

tf = TableFormat(; @all_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the vertical lines but the first one:

tf = TableFormat(; @all_vertical_lines, vertical_line_at_beginning = false)
source
PrettyTables.@excel__all_horizontal_linesMacro
@excel__all_horizontal_lines

Return the keyword arguments to be splatted into ExcelTableFormat to enable all horizontal lines.

Examples

# Enable all horizontal lines.
table_format = ExcelTableFormat(; @excel__all_horizontal_lines)

# Enable all horizontal lines but suppress data-row underlines.
table_format = ExcelTableFormat(; @excel__all_horizontal_lines, horizontal_lines_at_data_rows = :none)
source
PrettyTables.@excel__all_vertical_linesMacro
@excel__all_vertical_lines

Return the keyword arguments to be splatted into ExcelTableFormat to enable all vertical lines.

Examples

# Enable all vertical lines.
table_format = ExcelTableFormat(; @excel__all_vertical_lines)

# Enable all vertical lines but suppress the row-number column divider.
table_format = ExcelTableFormat(; @excel__all_vertical_lines, vertical_line_after_row_number_column = false)
source
PrettyTables.@excel__no_horizontal_linesMacro
@excel__no_horizontal_lines

Return the keyword arguments to be splatted into ExcelTableFormat to suppress all horizontal lines.

Examples

# Suppress all horizontal lines.
table_format = ExcelTableFormat(; @excel__no_horizontal_lines)

# Suppress all horizontal lines except the one after the column labels.
table_format = ExcelTableFormat(; @excel__no_horizontal_lines, horizontal_line_after_column_labels = true)
source
PrettyTables.@excel__no_vertical_linesMacro
@excel__no_vertical_lines

Return the keyword arguments to be splatted into ExcelTableFormat to suppress all vertical lines.

Examples

# Suppress all vertical lines.
table_format = ExcelTableFormat(; @excel__no_vertical_lines)

# Suppress all vertical lines except the one at the beginning.
table_format = ExcelTableFormat(; @excel__no_vertical_lines, vertical_line_at_beginning = true)
source
PrettyTables.@html__all_horizontal_linesMacro
@html__all_horizontal_lines() -> Keywords for `HtmlTableFormat`

Return the keyword arguments to be passed to HtmlTableFormat to show all horizontal lines.

We can use the output of this function when creating the HTML table format object. For example, the following code creates an HTML table format with all horizontal lines:

tf = HtmlTableFormat(; @html__all_horizontal_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the horizontal lines but the first one:

tf = HtmlTableFormat(; @html__all_horizontal_lines, horizontal_line_at_beginning = false)
source
PrettyTables.@html__all_vertical_linesMacro
@html__all_vertical_lines() -> Keywords for `HtmlTableFormat`

Return the keyword arguments to be passed to HtmlTableFormat to show all vertical lines.

We can use the output of this function when creating the HTML table format object. For example, the following code creates an HTML table format with all vertical lines:

tf = HtmlTableFormat(; @html__all_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the vertical lines but the first one:

tf = HtmlTableFormat(; @html__all_vertical_lines, vertical_line_at_beginning = false)
source
PrettyTables.@html__no_horizontal_linesMacro
@html__no_horizontal_lines() -> Keywords for `HtmlTableFormat`

Return the keyword arguments to be passed to HtmlTableFormat to suppress all horizontal lines.

We can use the output of this function when creating the HTML table format object. For example, the following code creates an HTML table format without horizontal lines:

tf = HtmlTableFormat(; @html__no_horizontal_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the horizontal line at the beginning of the table:

tf = HtmlTableFormat(; @html__no_horizontal_lines, horizontal_line_at_beginning = true)
source
PrettyTables.@html__no_vertical_linesMacro
@html__no_vertical_lines() -> Keywords for `HtmlTableFormat`

Return the keyword arguments to be passed to HtmlTableFormat to suppress all vertical lines.

We can use the output of this function when creating the HTML table format object. For example, the following code creates an HTML table format without vertical lines:

tf = HtmlTableFormat(; @html__no_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the vertical line at the beginning of the table:

tf = HtmlTableFormat(; @html__no_vertical_lines, vertical_line_at_beginning = true)
source
PrettyTables.@latex__all_horizontal_linesMacro
@latex__all_horizontal_lines() -> Keywords for `LatexTableFormat`

Return the keyword arguments to be passed to LatexTableFormat to show all horizontal lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a LaTeX table format with all horizontal lines:

tf = LatexTableFormat(; @latex__all_horizontal_lines())

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the horizontal lines but the first one:

tf = LatexTableFormat(; @latex__all_horizontal_lines, horizontal_line_at_beginning = false)

Extended Help

Example

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = LatexTableFormat(; @latex__all_horizontal_lines))
\begin{tabular}{|r|r|r|}
  \hline
  \textbf{Col. 1} & \textbf{Col. 2} & \textbf{Col. 3} \\
  \hline
  1.0 & 1.0 & 1.0 \\
  \hline
  1.0 & 1.0 & 1.0 \\
  \hline
  1.0 & 1.0 & 1.0 \\
  \hline
\end{tabular}

julia> pretty_table(
           A;
           table_format = LatexTableFormat(;
               @latex__all_horizontal_lines,
               horizontal_line_after_column_labels = false
           )
       )
\begin{tabular}{|r|r|r|}
  \hline
  \textbf{Col. 1} & \textbf{Col. 2} & \textbf{Col. 3} \\
  1.0 & 1.0 & 1.0 \\
  \hline
  1.0 & 1.0 & 1.0 \\
  \hline
  1.0 & 1.0 & 1.0 \\
  \hline
\end{tabular}
source
PrettyTables.@latex__all_vertical_linesMacro
@latex__all_vertical_lines() -> Keywords for `LatexTableFormat`

Return the keyword arguments to be passed to LatexTableFormat to show all vertical lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a LaTeX table format with all vertical lines:

tf = LatexTableFormat(; @latex__all_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the vertical lines but the first one:

tf = LatexTableFormat(; @latex__all_vertical_lines, vertical_line_at_beginning = false)

Extended Help

Examples

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = LatexTableFormat(; @latex__all_vertical_lines))
\begin{tabular}{|r|r|r|}
  \hline
  \textbf{Col. 1} & \textbf{Col. 2} & \textbf{Col. 3} \\
  \hline
  1.0 & 1.0 & 1.0 \\
  1.0 & 1.0 & 1.0 \\
  1.0 & 1.0 & 1.0 \\
  \hline
\end{tabular}

julia> pretty_table(
           A;
           show_row_number_column = true,
           table_format = LatexTableFormat(;
               @latex__all_vertical_lines,
               vertical_line_after_row_number_column = false
           )
       )
\begin{tabular}{|rr|r|r|}
  \hline
  \textbf{Row} & \textbf{Col. 1} & \textbf{Col. 2} & \textbf{Col. 3} \\
  \hline
  1 & 1.0 & 1.0 & 1.0 \\
  2 & 1.0 & 1.0 & 1.0 \\
  3 & 1.0 & 1.0 & 1.0 \\
  \hline
\end{tabular}
source
PrettyTables.@latex__no_horizontal_linesMacro
@latex__no_horizontal_lines() -> Keywords for `LatexTableFormat`

Return the keyword arguments to be passed to LatexTableFormat to suppress all horizontal lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a LaTeX table format without horizontal lines:

tf = LatexTableFormat(; @latex__no_horizontal_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the horizontal line at the beginning of the table:

tf = LatexTableFormat(; @latex__no_horizontal_lines, horizontal_line_at_beginning = true)

Extended Help

Example

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = LatexTableFormat(; @latex__no_horizontal_lines))
\begin{tabular}{|r|r|r|}
  \textbf{Col. 1} & \textbf{Col. 2} & \textbf{Col. 3} \\
  1.0 & 1.0 & 1.0 \\
  1.0 & 1.0 & 1.0 \\
  1.0 & 1.0 & 1.0 \\
\end{tabular}

julia> pretty_table(
           A;
           table_format = LatexTableFormat(;
               @latex__no_horizontal_lines,
               horizontal_line_after_column_labels = true
           )
       )
\begin{tabular}{|r|r|r|}
  \textbf{Col. 1} & \textbf{Col. 2} & \textbf{Col. 3} \\
  \hline
  1.0 & 1.0 & 1.0 \\
  1.0 & 1.0 & 1.0 \\
  1.0 & 1.0 & 1.0 \\
\end{tabular}
source
PrettyTables.@latex__no_vertical_linesMacro
@latex__no_vertical_lines() -> Keywords for `LatexTableFormat`

Return the keyword arguments to be passed to LatexTableFormat to suppress all vertical lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a LaTeX table format without vertical lines:

tf = LatexTableFormat(; @latex__no_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the vertical line at the beginning of the table:

tf = LatexTableFormat(; @latex__no_vertical_lines, vertical_line_at_beginning = true)

Extended Help

Examples

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = LatexTableFormat(; @latex__no_vertical_lines))
\begin{tabular}{rrr}
  \hline
  \textbf{Col. 1} & \textbf{Col. 2} & \textbf{Col. 3} \\
  \hline
  1.0 & 1.0 & 1.0 \\
  1.0 & 1.0 & 1.0 \\
  1.0 & 1.0 & 1.0 \\
  \hline
\end{tabular}

julia> pretty_table(
           A;
           show_row_number_column = true,
           table_format = LatexTableFormat(;
               @latex__no_vertical_lines,
               vertical_line_after_row_number_column = true
           )
       )
\begin{tabular}{r|rrr}
  \hline
  \textbf{Row} & \textbf{Col. 1} & \textbf{Col. 2} & \textbf{Col. 3} \\
  \hline
  1 & 1.0 & 1.0 & 1.0 \\
  2 & 1.0 & 1.0 & 1.0 \\
  3 & 1.0 & 1.0 & 1.0 \\
  \hline
\end{tabular}
source
PrettyTables.@no_horizontal_linesMacro
@no_horizontal_lines() -> Keywords for `TableFormat`

Return the keyword arguments to be passed to TableFormat to suppress all horizontal lines in any back end.

We can use the output of this function when creating the backend-agnostic table format object. For example, the following code creates a table format without horizontal lines:

tf = TableFormat(; @no_horizontal_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the horizontal line at the beginning of the table:

tf = TableFormat(; @no_horizontal_lines, horizontal_line_at_beginning = true)
source
PrettyTables.@no_vertical_linesMacro
@no_vertical_lines() -> Keywords for `TableFormat`

Return the keyword arguments to be passed to TableFormat to suppress all vertical lines in any back end.

We can use the output of this function when creating the backend-agnostic table format object. For example, the following code creates a table format without vertical lines:

tf = TableFormat(; @no_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the vertical line at the beginning of the table:

tf = TableFormat(; @no_vertical_lines, vertical_line_at_beginning = true)
source
PrettyTables.@text__all_horizontal_linesMacro
@text__all_horizontal_lines() -> Keywords for `TextTableFormat`

Return the keyword arguments to be passed to TextTableFormat to show all horizontal lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a text table format with all horizontal lines:

tf = TextTableFormat(; @text__all_horizontal_lines())

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the horizontal lines but the first one:

tf = TextTableFormat(; @text__all_horizontal_lines, horizontal_line_at_beginning = false)

Extended Help

Example

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = TextTableFormat(; @text__all_horizontal_lines))
┌────────┬────────┬────────┐
│ Col. 1 │ Col. 2 │ Col. 3 │
├────────┼────────┼────────┤
│    1.0 │    1.0 │    1.0 │
├────────┼────────┼────────┤
│    1.0 │    1.0 │    1.0 │
├────────┼────────┼────────┤
│    1.0 │    1.0 │    1.0 │
└────────┴────────┴────────┘

julia> pretty_table(
    A;
    table_format = TextTableFormat(
        ;
        @text__all_horizontal_lines,
        horizontal_line_after_column_labels = false
    )
)
┌────────┬────────┬────────┐
│ Col. 1 │ Col. 2 │ Col. 3 │
│    1.0 │    1.0 │    1.0 │
├────────┼────────┼────────┤
│    1.0 │    1.0 │    1.0 │
├────────┼────────┼────────┤
│    1.0 │    1.0 │    1.0 │
└────────┴────────┴────────┘
source
PrettyTables.@text__all_vertical_linesMacro
@text__all_vertical_lines() -> Keywords for `TextTableFormat`

Return the keyword arguments to be passed to TextTableFormat to show all vertical lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a text table format with all vertical lines:

tf = TextTableFormat(; @text__all_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the vertical lines but the first one:

tf = TextTableFormat(; @text__all_vertical_lines, vertical_line_at_beginning = false)

Extended Help

Examples

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = TextTableFormat(; @text__all_vertical_lines))
┌────────┬────────┬────────┐
│ Col. 1 │ Col. 2 │ Col. 3 │
├────────┼────────┼────────┤
│    1.0 │    1.0 │    1.0 │
│    1.0 │    1.0 │    1.0 │
│    1.0 │    1.0 │    1.0 │
└────────┴────────┴────────┘

julia> pretty_table(
    A;
    show_row_number_column = true,
    table_format = TextTableFormat(
        ;
        @text__all_vertical_lines,
        vertical_line_after_row_number_column = false
    )
)
┌─────────────┬────────┬────────┐
│ Row  Col. 1 │ Col. 2 │ Col. 3 │
├─────────────┼────────┼────────┤
│   1     1.0 │    1.0 │    1.0 │
│   2     1.0 │    1.0 │    1.0 │
│   3     1.0 │    1.0 │    1.0 │
└─────────────┴────────┴────────┘
source
PrettyTables.@text__no_horizontal_linesMacro
@text__no_horizontal_lines() -> Keywords for `TextTableFormat`

Return the keyword arguments to be passed to TextTableFormat to suppress all horizontal lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a text table format without horizontal lines:

tf = TextTableFormat(; @text__no_horizontal_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the horizontal line at the beginning of the table:

tf = TextTableFormat(; @text__no_horizontal_lines, horizontal_line_at_beginning = true)

Extended Help

Example

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = TextTableFormat(; @text__no_horizontal_lines))
│ Col. 1 │ Col. 2 │ Col. 3 │
│    1.0 │    1.0 │    1.0 │
│    1.0 │    1.0 │    1.0 │
│    1.0 │    1.0 │    1.0 │

julia> pretty_table(
    A;
    table_format = TextTableFormat(
        ;
        @text__no_horizontal_lines,
        horizontal_line_after_column_labels = true
    )
)
│ Col. 1 │ Col. 2 │ Col. 3 │
├────────┼────────┼────────┤
│    1.0 │    1.0 │    1.0 │
│    1.0 │    1.0 │    1.0 │
│    1.0 │    1.0 │    1.0 │
source
PrettyTables.@text__no_vertical_linesMacro
@text__no_vertical_lines() -> Keywords for `TextTableFormat`

Return the keyword arguments to be passed to TextTableFormat to suppress all vertical lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a text table format without vertical lines:

tf = TextTableFormat(; @text__no_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the vertical line at the beginning of the table:

tf = TextTableFormat(; @text__no_vertical_lines, vertical_line_at_beginning = true)

Extended Help

Examples

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = TextTableFormat(; @text__no_vertical_lines))
────────────────────────
 Col. 1  Col. 2  Col. 3
────────────────────────
    1.0     1.0     1.0
    1.0     1.0     1.0
    1.0     1.0     1.0
────────────────────────

julia> pretty_table(
    A;
    show_row_number_column = true,
    table_format = TextTableFormat(
        ;
        @text__no_vertical_lines,
        vertical_line_after_row_number_column = true
    )
)
─────┬────────────────────────
 Row │ Col. 1  Col. 2  Col. 3
─────┼────────────────────────
   1 │    1.0     1.0     1.0
   2 │    1.0     1.0     1.0
   3 │    1.0     1.0     1.0
─────┴────────────────────────
source
PrettyTables.@typst__all_horizontal_linesMacro
@typst__all_horizontal_lines() -> Keywords for `TypstTableFormat`

Return the keyword arguments to be passed to TypstTableFormat to show all horizontal lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a Typst table format with all horizontal lines:

tf = TypstTableFormat(; @typst__all_horizontal_lines())

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the horizontal lines but the first one:

tf = TypstTableFormat(; @typst__all_horizontal_lines, horizontal_line_at_beginning = false)

Extended Help

Example

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = TypstTableFormat(; @typst__all_horizontal_lines))
#{
  table(
    align: (right, right, right,),
    columns: (auto, auto, auto,),
    stroke: none,
    // == Horizontal Lines =================================================================
    table.hline(y: 0, stroke: 1.5pt,),
    table.hline(y: 1, stroke: 0.8pt,),
    table.hline(y: 2, stroke: 0.5pt,),
    table.hline(y: 3, stroke: 0.5pt,),
    table.hline(y: 4, stroke: 1.5pt,),
    // == Vertical Lines ===================================================================
    table.vline(x: 0, end: 4, stroke: 1.5pt),
    table.vline(x: 1, end: 4, stroke: 0.8pt),
    table.vline(x: 2, end: 4, stroke: 0.8pt),
    table.vline(x: 3, end: 4, stroke: 1.5pt),
    // == Table Header =====================================================================
    table.header(
      // -- Column Labels: Row 1 -----------------------------------------------------------
      [#text(weight: "bold",)[Col. 1]],
      [#text(weight: "bold",)[Col. 2]],
      [#text(weight: "bold",)[Col. 3]],
    ),
    // == Table Body =======================================================================
    // -- Data: Row 1 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 2 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 3 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
  )
}

julia> pretty_table(
           A;
           table_format = TypstTableFormat(;
               @typst__all_horizontal_lines,
               horizontal_line_after_column_labels = false
           )
       )
#{
  table(
    align: (right, right, right,),
    columns: (auto, auto, auto,),
    stroke: none,
    // == Horizontal Lines =================================================================
    table.hline(y: 0, stroke: 1.5pt,),
    table.hline(y: 2, stroke: 0.5pt,),
    table.hline(y: 3, stroke: 0.5pt,),
    table.hline(y: 4, stroke: 1.5pt,),
    // == Vertical Lines ===================================================================
    table.vline(x: 0, end: 4, stroke: 1.5pt),
    table.vline(x: 1, end: 4, stroke: 0.8pt),
    table.vline(x: 2, end: 4, stroke: 0.8pt),
    table.vline(x: 3, end: 4, stroke: 1.5pt),
    // == Table Header =====================================================================
    table.header(
      // -- Column Labels: Row 1 -----------------------------------------------------------
      [#text(weight: "bold",)[Col. 1]],
      [#text(weight: "bold",)[Col. 2]],
      [#text(weight: "bold",)[Col. 3]],
    ),
    // == Table Body =======================================================================
    // -- Data: Row 1 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 2 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 3 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
  )
}
source
PrettyTables.@typst__all_vertical_linesMacro
@typst__all_vertical_lines() -> Keywords for `TypstTableFormat`

Return the keyword arguments to be passed to TypstTableFormat to show all vertical lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a Typst table format with all vertical lines:

tf = TypstTableFormat(; @typst__all_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code shows all the vertical lines but the first one:

tf = TypstTableFormat(; @typst__all_vertical_lines, vertical_line_at_beginning = false)

Extended Help

Examples

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = TypstTableFormat(; @typst__all_vertical_lines))
#{
  table(
    align: (right, right, right,),
    columns: (auto, auto, auto,),
    stroke: none,
    // == Horizontal Lines =================================================================
    table.hline(y: 0, stroke: 1.5pt,),
    table.hline(y: 1, stroke: 0.8pt,),
    table.hline(y: 4, stroke: 1.5pt,),
    // == Vertical Lines ===================================================================
    table.vline(x: 0, end: 4, stroke: 1.5pt),
    table.vline(x: 1, end: 4, stroke: 0.8pt),
    table.vline(x: 2, end: 4, stroke: 0.8pt),
    table.vline(x: 3, end: 4, stroke: 1.5pt),
    // == Table Header =====================================================================
    table.header(
      // -- Column Labels: Row 1 -----------------------------------------------------------
      [#text(weight: "bold",)[Col. 1]],
      [#text(weight: "bold",)[Col. 2]],
      [#text(weight: "bold",)[Col. 3]],
    ),
    // == Table Body =======================================================================
    // -- Data: Row 1 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 2 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 3 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
  )
}

julia> pretty_table(
           A;
           show_row_number_column = true,
           table_format = TypstTableFormat(;
               @typst__all_vertical_lines,
               vertical_line_after_row_number_column = false
           )
       )
#{
  table(
    align: (right, right, right, right,),
    columns: (auto, auto, auto, auto,),
    stroke: none,
    // == Horizontal Lines =================================================================
    table.hline(y: 0, stroke: 1.5pt,),
    table.hline(y: 1, stroke: 0.8pt,),
    table.hline(y: 4, stroke: 1.5pt,),
    // == Vertical Lines ===================================================================
    table.vline(x: 0, end: 4, stroke: 1.5pt),
    table.vline(x: 2, end: 4, stroke: 0.8pt),
    table.vline(x: 3, end: 4, stroke: 0.8pt),
    table.vline(x: 4, end: 4, stroke: 1.5pt),
    // == Table Header =====================================================================
    table.header(
      // -- Column Labels: Row 1 -----------------------------------------------------------
      [#text(weight: "bold",)[Row]],
      [#text(weight: "bold",)[Col. 1]],
      [#text(weight: "bold",)[Col. 2]],
      [#text(weight: "bold",)[Col. 3]],
    ),
    // == Table Body =======================================================================
    // -- Data: Row 1 ----------------------------------------------------------------------
    [#text(weight: "bold",)[1]],
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 2 ----------------------------------------------------------------------
    [#text(weight: "bold",)[2]],
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 3 ----------------------------------------------------------------------
    [#text(weight: "bold",)[3]],
    [1.0],
    [1.0],
    [1.0],
  )
}
source
PrettyTables.@typst__no_horizontal_linesMacro
@typst__no_horizontal_lines() -> Keywords for `TypstTableFormat`

Return the keyword arguments to be passed to TypstTableFormat to suppress all horizontal lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a Typst table format without horizontal lines:

tf = TypstTableFormat(; @typst__no_horizontal_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the horizontal line at the beginning of the table:

tf = TypstTableFormat(; @typst__no_horizontal_lines, horizontal_line_at_beginning = true)

Extended Help

Example

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = TypstTableFormat(; @typst__no_horizontal_lines))
#{
  table(
    align: (right, right, right,),
    columns: (auto, auto, auto,),
    stroke: none,
    // == Horizontal Lines =================================================================
    // == Vertical Lines ===================================================================
    table.vline(x: 0, end: 4, stroke: 1.5pt),
    table.vline(x: 1, end: 4, stroke: 0.8pt),
    table.vline(x: 2, end: 4, stroke: 0.8pt),
    table.vline(x: 3, end: 4, stroke: 1.5pt),
    // == Table Header =====================================================================
    table.header(
      // -- Column Labels: Row 1 -----------------------------------------------------------
      [#text(weight: "bold",)[Col. 1]],
      [#text(weight: "bold",)[Col. 2]],
      [#text(weight: "bold",)[Col. 3]],
    ),
    // == Table Body =======================================================================
    // -- Data: Row 1 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 2 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 3 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
  )
}

julia> pretty_table(
           A;
           table_format = TypstTableFormat(;
               @typst__no_horizontal_lines,
               horizontal_line_after_column_labels = true
           )
       )
#{
  table(
    align: (right, right, right,),
    columns: (auto, auto, auto,),
    stroke: none,
    // == Horizontal Lines =================================================================
    table.hline(y: 1, stroke: 0.8pt,),
    // == Vertical Lines ===================================================================
    table.vline(x: 0, end: 4, stroke: 1.5pt),
    table.vline(x: 1, end: 4, stroke: 0.8pt),
    table.vline(x: 2, end: 4, stroke: 0.8pt),
    table.vline(x: 3, end: 4, stroke: 1.5pt),
    // == Table Header =====================================================================
    table.header(
      // -- Column Labels: Row 1 -----------------------------------------------------------
      [#text(weight: "bold",)[Col. 1]],
      [#text(weight: "bold",)[Col. 2]],
      [#text(weight: "bold",)[Col. 3]],
    ),
    // == Table Body =======================================================================
    // -- Data: Row 1 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 2 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 3 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
  )
}
source
PrettyTables.@typst__no_vertical_linesMacro
@typst__no_vertical_lines() -> Keywords for `TypstTableFormat`

Return the keyword arguments to be passed to TypstTableFormat to suppress all vertical lines.

We can use the output of this function when creating the text table format object. For example, the following code creates a Typst table format without vertical lines:

tf = TypstTableFormat(; @typst__no_vertical_lines)

Any option can be overridden by merging the keyword arguments. For example, the following code draws only the vertical line at the beginning of the table:

tf = TypstTableFormat(; @typst__no_vertical_lines, vertical_line_at_beginning = true)

Extended Help

Examples

julia> A = ones(3, 3);

julia> pretty_table(A; table_format = TypstTableFormat(; @typst__no_vertical_lines))
#{
  table(
    align: (right, right, right,),
    columns: (auto, auto, auto,),
    stroke: none,
    // == Horizontal Lines =================================================================
    table.hline(y: 0, stroke: 1.5pt,),
    table.hline(y: 1, stroke: 0.8pt,),
    table.hline(y: 4, stroke: 1.5pt,),
    // == Vertical Lines ===================================================================
    // == Table Header =====================================================================
    table.header(
      // -- Column Labels: Row 1 -----------------------------------------------------------
      [#text(weight: "bold",)[Col. 1]],
      [#text(weight: "bold",)[Col. 2]],
      [#text(weight: "bold",)[Col. 3]],
    ),
    // == Table Body =======================================================================
    // -- Data: Row 1 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 2 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 3 ----------------------------------------------------------------------
    [1.0],
    [1.0],
    [1.0],
  )
}

julia> pretty_table(
           A;
           show_row_number_column = true,
           table_format = TypstTableFormat(;
               @typst__no_vertical_lines,
               vertical_line_after_row_number_column = true
           )
       )
#{
  table(
    align: (right, right, right, right,),
    columns: (auto, auto, auto, auto,),
    stroke: none,
    // == Horizontal Lines =================================================================
    table.hline(y: 0, stroke: 1.5pt,),
    table.hline(y: 1, stroke: 0.8pt,),
    table.hline(y: 4, stroke: 1.5pt,),
    // == Vertical Lines ===================================================================
    table.vline(x: 1, end: 4, stroke: 0.8pt),
    // == Table Header =====================================================================
    table.header(
      // -- Column Labels: Row 1 -----------------------------------------------------------
      [#text(weight: "bold",)[Row]],
      [#text(weight: "bold",)[Col. 1]],
      [#text(weight: "bold",)[Col. 2]],
      [#text(weight: "bold",)[Col. 3]],
    ),
    // == Table Body =======================================================================
    // -- Data: Row 1 ----------------------------------------------------------------------
    [#text(weight: "bold",)[1]],
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 2 ----------------------------------------------------------------------
    [#text(weight: "bold",)[2]],
    [1.0],
    [1.0],
    [1.0],
    // -- Data: Row 3 ----------------------------------------------------------------------
    [#text(weight: "bold",)[3]],
    [1.0],
    [1.0],
    [1.0],
  )
}
source