Skip to content

[doc] A matrix CSS style for matrices in docs #496

@alugowski

Description

@alugowski

I think the docs would be both easier to understand and nicer to look at by styling the matrices a bit more.

The matrices appear to be tables using the 'inline' class, this may be as simple as applying a CSS style. Below is the one I wrote for matrepr. AFAIK you just have to copy it to the CSS file in the statics directory then just select the class. This style was written for Jupyter so may or may not be a drop-in for Sphinx.

table.matreprmatrix  {
    border-collapse: collapse;
}
/* remove thin black line under Jupyter table headers */
table.matreprmatrix > thead  {
    border: 0px;
}
/* row indices */
table.matreprmatrix > tbody tr th {
    font-size: smaller;
    vertical-align: middle;
    text-align: right;
}
/* col indices */
table.matreprmatrix > thead tr th {
    font-size: smaller;
    vertical-align: middle;
    text-align: center;
}
/* cells */
table.matreprmatrix > tbody tr td {
    vertical-align: middle;
    text-align: center;
    position: relative;
}
/* left border */
table.matreprmatrix > tbody tr td:first-of-type {
    border-left: solid 2px;
}
/* right border */
table.matreprmatrix > tbody tr td:last-of-type {
    border-right: solid 2px;
}
/* prevents empty cells from collapsing, especially empty rows */
table.matreprmatrix > tbody tr td:empty::before {
    content: "\00a0\00a0\00a0";
    visibility: hidden;
}
table.matreprmatrix > tbody tr td:empty::after {
    content: "\00a0\00a0\00a0";
    visibility: hidden;
}
/* matrix bracket ticks */
table.matreprmatrix > tbody > tr:first-child > td:first-of-type::before {
    content: "";
    width: 4px;
    position: absolute;
    top: 0;
    bottom: 0;
    visibility: visible;
    left: 0;
    right: auto;
    border-top: solid 2px;
}
table.matreprmatrix > tbody > tr:last-child > td:first-of-type::before {
    content: "";
    width: 4px;
    position: absolute;
    top: 0;
    bottom: 0;
    visibility: visible;
    left: 0;
    right: auto;
    border-bottom: solid 2px;
}
table.matreprmatrix > tbody > tr:first-child > td:last-of-type::after {
    content: "";
    width: 4px;
    position: absolute;
    top: 0;
    bottom: 0;
    visibility: visible;
    left: auto;
    right: 0;
    border-top: solid 2px;
}
table.matreprmatrix > tbody > tr:last-child > td:last-of-type::after {
    content: "";
    width: 4px;
    position: absolute;
    top: 0;
    bottom: 0;
    visibility: visible;
    left: auto;
    right: 0;
    border-bottom: solid 2px;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions