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{LatexHighlighter}
: Highlighters to apply to the table. For more information, see the section [LaTeX Highlighters]@(ref).style::LatexTableStyle
: Style of the table. For more information, see the section LaTeX Table Style.table_format::LatexTableFormat
: LaTeX table format used to render the table. For more information, see the section LaTeX Table Format.
LaTeX Highlighters
A set of highlighters can be passed as a Vector{LatexHighlighter}
to the highlighters
keyword. Each highlighter is an instance of the structure LatexHighlighter
. It contains the following two public fields:
f::Function
: Function with the signaturef(data, i, j)
in which should returntrue
if the element(i, j)
indata
must be highlighted, orfalse
otherwise.fd::Function
: Function with the signaturef(h, data, i, j)
in whichh
is the highlighter. This function must return aVector{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 select the desired decoration by specifying the function fd
.
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
.
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, we if want to make the cells with value greater than 5 in bold, and all the cells with value less than 5 to be 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
: Iftrue
, a horizontal line will be drawn at the beginning of the table.horizontal_line_after_column_labels::Bool
: Iftrue
, 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 column. If the symbol:none
is passed, no horizontal lines will be drawn after the data rows.horizontal_line_before_row_group_label::Bool
: Iftrue
, a horizontal line will be drawn before the row group label.horizontal_line_after_row_group_label::Bool
: Iftrue
, a horizontal line will be drawn after the row group label.horizontal_line_after_data_rows::Bool
: Iftrue
, a horizontal line will be drawn after the data rows.horizontal_line_after_summary_rows::Bool
: Iftrue
, a horizontal line will be drawn after the summary rows.vertical_line_at_beginning::Bool
: Iftrue
, a vertical line will be drawn at the beginning of the table.vertical_line_after_row_number_column::Bool
: Iftrue
, a vertical line will be drawn after the row number column.vertical_line_after_row_label_column::Bool
: Iftrue
, 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
: Iftrue
, a vertical line will be drawn after the data columns.vertical_line_after_continuation_column::Bool
: Iftrue
, 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__all_horizontal_lines
.@latex__all_vertical_lines
.@latex__no_horizontal_lines
.@latex__no_vertical_lines
.
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::LatexEnvironments
: Latex environments with the style for the first column label lines.column_label::LatexEnvironments
: Latex environments with the style for the rest of the column labels.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}"]
)