mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-13 06:58:40 +00:00
* Use JS for spacing between atoms instead of CSS Summary: This is the first step towards creating an intermediate representation that can be used to generate HTML, SVG, and Canvas commands for rendering. By generating spans that contain the width of the spaces instead of relying on CSS sibling rules we'll be able to one day replaces the spans with intermeidate 'Glue' nodes (in a later PR). An added benefit of this approach is that is enables us to programmatically change the values for thinspace, mediumspace, and thickspace which will allow us to implement the \setlength command. Test Plan: - npm test - dockers/Screenshotter/screenshotter.sh --verify * fixed failures in BinCancellation, BoldSymbol, and OperatorName * update screenshots * don't use current size when determining size of spaces, update more screenshots * fix spacing in SizingBaseline and StyleSwitching * actually do the right thing for sizing groups * fix \not for Chrome and Firefox * do TODOs * address feedback from the code review * fix issue in delimsizing.js * add TODO to think about a better solution in href.js * fix typos, simplify href, be honest about paddingLeft for \not
550 lines
11 KiB
Plaintext
550 lines
11 KiB
Plaintext
@import "fonts.less";
|
|
|
|
// The mu unit is defined as 1/18 em
|
|
@mu: 1.0/18.0em;
|
|
|
|
.katex-display {
|
|
display: block;
|
|
margin: 1em 0;
|
|
text-align: center;
|
|
|
|
> .katex {
|
|
display: inline-block;
|
|
text-align: initial;
|
|
}
|
|
}
|
|
|
|
.katex {
|
|
font: normal 1.21em KaTeX_Main, Times New Roman, serif;
|
|
line-height: 1.2;
|
|
white-space: nowrap;
|
|
|
|
// Protect elements inside .katex from inheriting text-indent.
|
|
text-indent: 0;
|
|
|
|
// Prevent a rendering bug that misplaces \vec in Chrome.
|
|
text-rendering: auto;
|
|
|
|
// Prevent background resetting on elements in Windows's high-contrast
|
|
// mode, while still allowing background/foreground setting on root .katex
|
|
* { -ms-high-contrast-adjust: none !important; }
|
|
|
|
.katex-html {
|
|
// Making .katex inline-block allows line breaks before and after,
|
|
// which is undesireable ("to $x$,"). Instead, adjust the .katex-html
|
|
// style and put nowrap on the inline .katex element.
|
|
display: inline-block;
|
|
}
|
|
|
|
.katex-mathml {
|
|
// Accessibility hack to only show to screen readers
|
|
// Found at: http://a11yproject.com/posts/how-to-hide-content/
|
|
position: absolute;
|
|
clip: rect(1px, 1px, 1px, 1px);
|
|
padding: 0;
|
|
border: 0;
|
|
height: 1px;
|
|
width: 1px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.base {
|
|
position: relative;
|
|
display: inline-block;
|
|
}
|
|
|
|
.strut {
|
|
display: inline-block;
|
|
}
|
|
|
|
// Text font weights
|
|
.textbf {
|
|
font-weight: bold;
|
|
}
|
|
|
|
// Text font shapes.
|
|
.textit {
|
|
font-style: italic;
|
|
}
|
|
|
|
// Text font families.
|
|
.textrm {
|
|
font-family: KaTeX_Main;
|
|
}
|
|
|
|
.textsf {
|
|
font-family: KaTeX_SansSerif;
|
|
}
|
|
|
|
.texttt {
|
|
font-family: KaTeX_Typewriter;
|
|
}
|
|
|
|
// Math fonts.
|
|
.mathit {
|
|
font-family: KaTeX_Math;
|
|
font-style: italic;
|
|
}
|
|
|
|
.mathrm {
|
|
font-style: normal;
|
|
}
|
|
|
|
.mathbf {
|
|
font-family: KaTeX_Main;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.boldsymbol {
|
|
font-family: KaTeX_Math;
|
|
font-weight: bold;
|
|
font-style: italic;
|
|
}
|
|
|
|
.amsrm {
|
|
font-family: KaTeX_AMS;
|
|
}
|
|
|
|
.mathbb {
|
|
font-family: KaTeX_AMS;
|
|
}
|
|
|
|
.mathcal {
|
|
font-family: KaTeX_Caligraphic;
|
|
}
|
|
|
|
.mathfrak {
|
|
font-family: KaTeX_Fraktur;
|
|
}
|
|
|
|
.mathtt {
|
|
font-family: KaTeX_Typewriter;
|
|
}
|
|
|
|
.mathscr {
|
|
font-family: KaTeX_Script;
|
|
}
|
|
|
|
.mathsf {
|
|
font-family: KaTeX_SansSerif;
|
|
}
|
|
|
|
.mainit {
|
|
font-family: KaTeX_Main;
|
|
font-style: italic;
|
|
}
|
|
|
|
.mainrm {
|
|
font-family: KaTeX_Main;
|
|
font-style: normal;
|
|
}
|
|
|
|
// This value is also used in fontMetrics.js, if you change it make sure the
|
|
// values match.
|
|
@ptperem: 10.0;
|
|
@nulldelimiterspace: 1.2em / @ptperem;
|
|
|
|
@muspace: 0.055556em; // 1mu
|
|
@thinspace: 0.16667em; // 3mu
|
|
@mediumspace: 0.22222em; // 4mu
|
|
@thickspace: 0.27778em; // 5mu
|
|
|
|
.vlist-t {
|
|
display: inline-table;
|
|
table-layout: fixed;
|
|
}
|
|
|
|
.vlist-r {
|
|
display: table-row;
|
|
}
|
|
|
|
.vlist {
|
|
display: table-cell;
|
|
vertical-align: bottom;
|
|
position: relative;
|
|
|
|
> span {
|
|
display: block;
|
|
height: 0;
|
|
position: relative;
|
|
|
|
> span {
|
|
display: inline-block;
|
|
}
|
|
|
|
> .pstrut {
|
|
overflow: hidden;
|
|
width: 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
.vlist-t2 {
|
|
margin-right: -2px;
|
|
}
|
|
|
|
.vlist-s {
|
|
// This cell solves Safari rendering problems. It has text content, so
|
|
// its baseline is used for the table. A very small font avoids line-box
|
|
// issues; absolute units prevent user font-size overrides from breaking
|
|
// rendering. Safari refuses to make the box zero-width, so we give it
|
|
// a known width and compensate with negative right margin on the
|
|
// inline-table.
|
|
display: table-cell;
|
|
vertical-align: bottom;
|
|
font-size: 1px;
|
|
width: 2px;
|
|
}
|
|
|
|
.msupsub {
|
|
text-align: left;
|
|
}
|
|
|
|
.mfrac {
|
|
> span > span {
|
|
text-align: center;
|
|
}
|
|
|
|
.frac-line {
|
|
display: inline-block;
|
|
width: 100%;
|
|
}
|
|
}
|
|
|
|
.mspace {
|
|
display: inline-block;
|
|
|
|
&.negativethinspace {
|
|
margin-left: -@thinspace;
|
|
}
|
|
|
|
&.muspace {
|
|
width: @muspace;
|
|
}
|
|
|
|
&.thinspace {
|
|
width: @thinspace;
|
|
}
|
|
|
|
&.negativemediumspace {
|
|
margin-left: -@mediumspace;
|
|
}
|
|
|
|
&.mediumspace {
|
|
width: @mediumspace;
|
|
}
|
|
|
|
&.thickspace {
|
|
width: @thickspace;
|
|
}
|
|
|
|
&.sixmuspace {
|
|
width: 0.333333em;
|
|
}
|
|
|
|
&.eightmuspace {
|
|
width: 0.444444em;
|
|
}
|
|
|
|
&.enspace {
|
|
width: 0.5em;
|
|
}
|
|
|
|
&.twelvemuspace {
|
|
width: 0.666667em;
|
|
}
|
|
|
|
&.quad {
|
|
width: 1em;
|
|
}
|
|
|
|
&.qquad {
|
|
width: 2em;
|
|
}
|
|
}
|
|
|
|
.llap,
|
|
.rlap,
|
|
.clap {
|
|
width: 0;
|
|
position: relative;
|
|
|
|
> .inner {
|
|
position: absolute;
|
|
}
|
|
|
|
> .fix {
|
|
display: inline-block;
|
|
}
|
|
}
|
|
|
|
.llap > .inner {
|
|
right: 0;
|
|
}
|
|
|
|
.rlap > .inner,
|
|
.clap > .inner {
|
|
left: 0;
|
|
}
|
|
|
|
.clap > .inner > span {
|
|
margin-left: -50%;
|
|
margin-right: 50%;
|
|
}
|
|
|
|
.rule {
|
|
display: inline-block;
|
|
border: solid 0;
|
|
position: relative;
|
|
}
|
|
|
|
.overline .overline-line,
|
|
.underline .underline-line {
|
|
display: inline-block;
|
|
width: 100%;
|
|
}
|
|
|
|
.sqrt {
|
|
> .root {
|
|
// These values are taken from the definition of `\r@@t`,
|
|
// `\mkern 5mu` and `\mkern -10mu`.
|
|
margin-left: 5*@mu;
|
|
margin-right: -10*@mu;
|
|
}
|
|
}
|
|
|
|
.sizing, .fontsize-ensurer {
|
|
display: inline-block;
|
|
|
|
@size1: 0.5;
|
|
@size2: 0.6;
|
|
@size3: 0.7;
|
|
@size4: 0.8;
|
|
@size5: 0.9;
|
|
@size6: 1.0;
|
|
@size7: 1.2;
|
|
@size8: 1.44;
|
|
@size9: 1.728;
|
|
@size10: 2.074;
|
|
@size11: 2.488;
|
|
|
|
.generate-size-change(@from, @to) {
|
|
&.reset-size@{from}.size@{to} {
|
|
@sizeFromVariable: ~"size@{from}";
|
|
@sizeToVariable: ~"size@{to}";
|
|
font-size: (@@sizeToVariable / @@sizeFromVariable) * 1em;
|
|
}
|
|
}
|
|
|
|
.generate-to-size-change(@from, @currTo) when (@currTo =< 11) {
|
|
.generate-size-change(@from, @currTo);
|
|
|
|
.generate-to-size-change(@from, (@currTo + 1));
|
|
}
|
|
|
|
.generate-from-size-change(@currFrom) when (@currFrom =< 11) {
|
|
.generate-to-size-change(@currFrom, 1);
|
|
|
|
.generate-from-size-change((@currFrom + 1));
|
|
}
|
|
|
|
.generate-from-size-change(1);
|
|
}
|
|
|
|
.delimsizing {
|
|
&.size1 { font-family: KaTeX_Size1; }
|
|
&.size2 { font-family: KaTeX_Size2; }
|
|
&.size3 { font-family: KaTeX_Size3; }
|
|
&.size4 { font-family: KaTeX_Size4; }
|
|
|
|
&.mult {
|
|
.delim-size1 > span {
|
|
font-family: KaTeX_Size1;
|
|
}
|
|
.delim-size4 > span {
|
|
font-family: KaTeX_Size4;
|
|
}
|
|
}
|
|
}
|
|
|
|
.nulldelimiter {
|
|
display: inline-block;
|
|
width: @nulldelimiterspace;
|
|
}
|
|
|
|
.delimcenter {
|
|
position: relative;
|
|
}
|
|
|
|
.op-symbol {
|
|
position: relative;
|
|
|
|
&.small-op {
|
|
font-family: KaTeX_Size1;
|
|
}
|
|
&.large-op {
|
|
font-family: KaTeX_Size2;
|
|
}
|
|
}
|
|
|
|
.op-limits {
|
|
> .vlist-t {
|
|
text-align: center;
|
|
}
|
|
}
|
|
|
|
.accent {
|
|
> .vlist-t {
|
|
text-align: center;
|
|
}
|
|
|
|
.accent-body {
|
|
width: 0;
|
|
position: relative; // so that 'left' can shift the accent
|
|
}
|
|
}
|
|
|
|
.overlay {
|
|
display: block;
|
|
}
|
|
|
|
.mtable {
|
|
.vertical-separator {
|
|
display: inline-block;
|
|
margin: 0 -0.125em; // The ink in the rule is actually 0.05em wide.
|
|
width: 0.25em; // We put it in a 0.25em wide span to overcome
|
|
} // a Chrome rendering issue.
|
|
|
|
.arraycolsep {
|
|
display: inline-block;
|
|
}
|
|
|
|
.col-align-c > .vlist-t {
|
|
text-align: center;
|
|
}
|
|
|
|
.col-align-l > .vlist-t {
|
|
text-align: left;
|
|
}
|
|
|
|
.col-align-r > .vlist-t {
|
|
text-align: right;
|
|
}
|
|
}
|
|
|
|
.svg-align {
|
|
text-align: left;
|
|
}
|
|
|
|
svg {
|
|
display: block;
|
|
position: absolute; // absolute relative to parent
|
|
width: 100%;
|
|
|
|
path {
|
|
fill: currentColor;
|
|
}
|
|
|
|
line {
|
|
stroke: currentColor;
|
|
}
|
|
}
|
|
|
|
.vertical-separator svg {
|
|
width: 0.25em;
|
|
}
|
|
|
|
// Define CSS for image whose width will match its span width.
|
|
.stretchy {
|
|
width: 100%;
|
|
display: block;
|
|
|
|
&:before,
|
|
&:after {
|
|
content: "";
|
|
}
|
|
}
|
|
|
|
// Hide the long tail of a stretchy SVG.
|
|
.hide-tail {
|
|
width: 100%; // necessary only to get IE to work properly
|
|
position: relative; // ditto
|
|
overflow: hidden; // This line applies to all browsers.
|
|
}
|
|
|
|
.halfarrow-left {
|
|
position: absolute;
|
|
left: 0;
|
|
width: 50.1%;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.halfarrow-right {
|
|
position: absolute;
|
|
right: 0;
|
|
width: 50%;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.brace-left {
|
|
position: absolute;
|
|
left: 0;
|
|
width: 25.1%;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.brace-center {
|
|
position: absolute;
|
|
left: 25%;
|
|
width: 50%;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.brace-right {
|
|
position: absolute;
|
|
right: 0;
|
|
width: 25.1%;
|
|
overflow: hidden;
|
|
}
|
|
|
|
// Lengthen the extensible arrows via padding.
|
|
.x-arrow-pad {
|
|
padding: 0 0.5em;
|
|
}
|
|
|
|
.x-arrow,
|
|
.mover,
|
|
.munder {
|
|
text-align: center;
|
|
}
|
|
|
|
.boxpad {
|
|
padding: 0 0.3em 0 0.3em; // \fboxsep = 3pt
|
|
}
|
|
.fbox {
|
|
box-sizing: border-box;
|
|
border: 0.04em solid black; // \fboxrule = 0.4pt
|
|
}
|
|
.fcolorbox {
|
|
box-sizing: border-box;
|
|
border: 0.04em solid; // \fboxrule = 0.4pt
|
|
}
|
|
.cancel-pad {
|
|
padding: 0 0.2em 0 0.2em; // ref: cancel package \advance\dimen@ 2\p@ % "+2"
|
|
}
|
|
.mord + .cancel-lap,
|
|
.mbin + .cancel-lap {
|
|
margin-left: -0.2em;
|
|
}
|
|
.cancel-lap + .mord,
|
|
.cancel-lap + .mbin,
|
|
.cancel-lap + .msupsub {
|
|
margin-left: -0.2em;
|
|
}
|
|
.sout {
|
|
border-bottom-style: solid;
|
|
border-bottom-width: 0.08em;
|
|
}
|
|
|
|
}
|