mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 19:28:39 +00:00
build: use semantic-release to automate release (#2830)
* Link to previous deploys of releases instead of versioned docs * Use semantic-release to automate release * Use an environment for release job * Run release only on push event
This commit is contained in:
32
.github/workflows/ci.yml
vendored
32
.github/workflows/ci.yml
vendored
@@ -54,3 +54,35 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
directory: ./coverage/
|
directory: ./coverage/
|
||||||
timeout-minutes: 3
|
timeout-minutes: 3
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
environment: release
|
||||||
|
needs: test
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Use Node.js 12.x
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
.yarn/cache
|
||||||
|
.pnp.js
|
||||||
|
key: yarn-deps-v1-${{ hashFiles('yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
yarn-deps-v1-
|
||||||
|
- name: Run semantic-release
|
||||||
|
run: yarn run semantic-release --debug
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,6 +18,7 @@ coverage/
|
|||||||
docs/cli.md
|
docs/cli.md
|
||||||
lib/core/metadata.js
|
lib/core/metadata.js
|
||||||
lib/core/MetadataBlog.js
|
lib/core/MetadataBlog.js
|
||||||
|
website/prev-versions.json
|
||||||
website/translated_docs
|
website/translated_docs
|
||||||
website/build/
|
website/build/
|
||||||
website/node_modules
|
website/node_modules
|
||||||
|
25
.releaserc
Normal file
25
.releaserc
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
["@semantic-release/commit-analyzer", {
|
||||||
|
"releaseRules": [
|
||||||
|
{breaking: true, release: 'minor'},
|
||||||
|
{type: 'feat', release: 'patch'},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
"@semantic-release/release-notes-generator",
|
||||||
|
["@semantic-release/changelog", {
|
||||||
|
"changelogTitle": "# Changelog\nAll notable changes to this project will be documented in this file. This CHANGELOG roughly follows the guidelines from [www.keepachangelog.com](https://keepachangelog.com/en/1.0.0/).",
|
||||||
|
}],
|
||||||
|
"@semantic-release/npm",
|
||||||
|
["@semantic-release/git", {
|
||||||
|
"assets": ["dist", "docs", "package.json", "CHANGELOG.md", "README.md", "contrib/*/README.md", "website/pages/index.html"],
|
||||||
|
"message": "chore(release): ${nextRelease.version} [ci skip]\n\n${nextRelease.notes}",
|
||||||
|
}],
|
||||||
|
["@semantic-release/github", {
|
||||||
|
"assets": [
|
||||||
|
{path: 'katex.tar.gz', label: 'tarball'},
|
||||||
|
{path: 'katex.zip', label: 'zip'},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
}
|
@@ -145,6 +145,7 @@ Flow by running `yarn test:flow`. See [Flow](https://flow.org/) for more details
|
|||||||
|
|
||||||
## Pull Requests
|
## Pull Requests
|
||||||
|
|
||||||
|
- PR title and description should follow [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines)
|
||||||
- link back to the original issue(s) whenever possible
|
- link back to the original issue(s) whenever possible
|
||||||
- new commands should be added to `docs/support_table.md` and `docs/supported.md`
|
- new commands should be added to `docs/support_table.md` and `docs/supported.md`
|
||||||
- commits should be squashed before merging
|
- commits should be squashed before merging
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
# [<img src="https://katex.org/img/katex-logo-black.svg" width="130" alt="KaTeX">](https://katex.org/)
|
# [<img src="https://katex.org/img/katex-logo-black.svg" width="130" alt="KaTeX">](https://katex.org/)
|
||||||
[](https://www.npmjs.com/package/katex)
|
[](https://www.npmjs.com/package/katex)
|
||||||
|
[](https://github.com/semantic-release/semantic-release)
|
||||||
[](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI)
|
[](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI)
|
||||||
[](https://codecov.io/gh/KaTeX/KaTeX)
|
[](https://codecov.io/gh/KaTeX/KaTeX)
|
||||||
[](https://github.com/KaTeX/KaTeX/discussions)
|
[](https://github.com/KaTeX/KaTeX/discussions)
|
||||||
|
@@ -6,7 +6,7 @@ This is a list of TeX functions, sorted alphabetically. This list includes funct
|
|||||||
|
|
||||||
If you know the shape of a character, but not its name, [Detexify](http://detexify.kirelabs.org/classify.html) can help.
|
If you know the shape of a character, but not its name, [Detexify](http://detexify.kirelabs.org/classify.html) can help.
|
||||||
|
|
||||||
<link rel="stylesheet" href="/static/katex.min.css"/>
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.css" integrity="sha384-t5CR+zwDAROtph0PXGte6ia8heboACF9R5l/DiY+WZ3P2lxNgvJkQk5n7GPvLMYw" crossorigin="anonymous">
|
||||||
<style>
|
<style>
|
||||||
table tr,
|
table tr,
|
||||||
table td {
|
table td {
|
||||||
|
@@ -6,7 +6,7 @@ This is a list of TeX functions supported by KaTeX. It is sorted into logical gr
|
|||||||
|
|
||||||
There is a similar [Support Table](support_table.md), sorted alphabetically, that lists both supported and un-supported functions.
|
There is a similar [Support Table](support_table.md), sorted alphabetically, that lists both supported and un-supported functions.
|
||||||
|
|
||||||
<link rel="stylesheet" href="/static/katex.min.css"/>
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.css" integrity="sha384-t5CR+zwDAROtph0PXGte6ia8heboACF9R5l/DiY+WZ3P2lxNgvJkQk5n7GPvLMYw" crossorigin="anonymous">
|
||||||
<style>
|
<style>
|
||||||
p {overflow-wrap: break-word;}
|
p {overflow-wrap: break-word;}
|
||||||
table tr,
|
table tr,
|
||||||
|
11
package.json
11
package.json
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "katex",
|
"name": "katex",
|
||||||
"version": "0.13.0",
|
"version": "0.0.0-development",
|
||||||
"description": "Fast math typesetting for the web.",
|
"description": "Fast math typesetting for the web.",
|
||||||
"main": "dist/katex.js",
|
"main": "dist/katex.js",
|
||||||
"homepage": "https://katex.org",
|
"homepage": "https://katex.org",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/KaTeX/KaTeX.git"
|
"url": "https://github.com/KaTeX/KaTeX.git"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"katex.js",
|
"katex.js",
|
||||||
@@ -26,6 +26,8 @@
|
|||||||
"@babel/runtime": "^7.10.4",
|
"@babel/runtime": "^7.10.4",
|
||||||
"@rollup/plugin-alias": "^3.1.1",
|
"@rollup/plugin-alias": "^3.1.1",
|
||||||
"@rollup/plugin-babel": "^5.0.4",
|
"@rollup/plugin-babel": "^5.0.4",
|
||||||
|
"@semantic-release/changelog": "^5.0.1",
|
||||||
|
"@semantic-release/git": "^9.0.0",
|
||||||
"babel-eslint": "^10.1.0",
|
"babel-eslint": "^10.1.0",
|
||||||
"babel-jest": "^26.1.0",
|
"babel-jest": "^26.1.0",
|
||||||
"babel-loader": "^8.0.5",
|
"babel-loader": "^8.0.5",
|
||||||
@@ -71,6 +73,7 @@
|
|||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup": "^2.21.0",
|
"rollup": "^2.21.0",
|
||||||
"selenium-webdriver": "^3.6.0",
|
"selenium-webdriver": "^3.6.0",
|
||||||
|
"semantic-release": "^17.4.1",
|
||||||
"sri-toolbox": "^0.2.0",
|
"sri-toolbox": "^0.2.0",
|
||||||
"style-loader": "^2.0.0",
|
"style-loader": "^2.0.0",
|
||||||
"stylelint": "^13.6.1",
|
"stylelint": "^13.6.1",
|
||||||
@@ -101,7 +104,9 @@
|
|||||||
"analyze": "webpack --config webpack.analyze.js",
|
"analyze": "webpack --config webpack.analyze.js",
|
||||||
"build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c && webpack",
|
"build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c && webpack",
|
||||||
"watch": "yarn build --watch",
|
"watch": "yarn build --watch",
|
||||||
"dist": "yarn test && yarn build && yarn dist:zip",
|
"postversion": "yarn dist && node update-sri.js package README.md contrib/*/README.md docs/*.md website/pages/index.html",
|
||||||
|
"semantic-release": "semantic-release",
|
||||||
|
"dist": "yarn build && yarn dist:zip",
|
||||||
"dist:zip": "rimraf katex/ katex.tar.gz katex.zip && cp -R dist katex && tar czf katex.tar.gz katex && zip -rq katex.zip katex && rimraf katex/"
|
"dist:zip": "rimraf katex/ katex.tar.gz katex.zip && cp -R dist katex && tar czf katex.tar.gz katex && zip -rq katex.zip katex && rimraf katex/"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
219
release.sh
219
release.sh
@@ -1,219 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e -o pipefail
|
|
||||||
shopt -s extglob
|
|
||||||
|
|
||||||
VERSION=
|
|
||||||
NEXT_VERSION=
|
|
||||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
||||||
ORIGIN=${ORIGIN:-origin}
|
|
||||||
NARGS=0
|
|
||||||
DRY_RUN=
|
|
||||||
PUBLISH=
|
|
||||||
INSANE=0
|
|
||||||
|
|
||||||
# usage [ERROR-MESSAGES...] EXIT-CODE
|
|
||||||
usage() {
|
|
||||||
while [[ $# -gt 1 ]]; do
|
|
||||||
echo "$1" >&2
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
echo "Usage:"
|
|
||||||
echo "./release.sh [OPTIONS] <VERSION_TO_RELEASE> [NEXT_VERSION]"
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " --publish|-p: publish a release."
|
|
||||||
echo " --dry-run|-n: only print commands, do not execute them."
|
|
||||||
echo ""
|
|
||||||
echo "You may omit NEXT_VERSION in order to avoid updating the version field"
|
|
||||||
echo "of the package.json."
|
|
||||||
echo ""
|
|
||||||
echo "Run this on the master branch. This will create a release branch."
|
|
||||||
echo "Open a pull request and after it gets merged, run with --publish"
|
|
||||||
echo "option on the master branch."
|
|
||||||
echo ""
|
|
||||||
echo "To update SRI hashes, run this again on the generated release branch"
|
|
||||||
echo ""
|
|
||||||
echo "Examples:"
|
|
||||||
echo " When releasing a v0.6.3:"
|
|
||||||
echo " ./release.sh 0.6.3 0.6.4"
|
|
||||||
echo " Open a pull request from v0.6.3-release to master."
|
|
||||||
echo " After it's merged:"
|
|
||||||
echo " ./release.sh -p 0.6.3"
|
|
||||||
exit $1
|
|
||||||
}
|
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
--dry-run|-n|--just-print)
|
|
||||||
DRY_RUN=true
|
|
||||||
git() { echo "git $*"; }
|
|
||||||
npm() { echo "npm $*"; }
|
|
||||||
yarn() { echo "yarn $*"; }
|
|
||||||
;;
|
|
||||||
--publish|-p)
|
|
||||||
PUBLISH=true
|
|
||||||
;;
|
|
||||||
-h|-\?|--help)
|
|
||||||
usage 0
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
usage "Unknown option: $1" "" 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
case "$NARGS" in
|
|
||||||
0)
|
|
||||||
VERSION="$1"
|
|
||||||
NARGS=1
|
|
||||||
;;
|
|
||||||
1)
|
|
||||||
NEXT_VERSION="$1"
|
|
||||||
NARGS=2
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
usage "Too many arguments: $1" "" 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $NARGS = 0 ]]; then
|
|
||||||
usage "Missing argument: version number" "" 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Some sanity checks up front
|
|
||||||
if ! command git diff --stat --exit-code HEAD; then
|
|
||||||
echo "Please make sure you have no uncommitted changes" >&2
|
|
||||||
: $((++INSANE))
|
|
||||||
fi
|
|
||||||
if [[ $BRANCH != @(v*-release|master) ]]; then
|
|
||||||
echo "'$BRANCH' does not look like a release branch to me" >&2
|
|
||||||
: $((++INSANE))
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $PUBLISH ]]; then
|
|
||||||
echo "About to publish $VERSION from $BRANCH. "
|
|
||||||
elif [[ $BRANCH == @(v*-release) ]]; then
|
|
||||||
echo "About to update SRI hashes for $BRANCH. "
|
|
||||||
elif [[ ! $NEXT_VERSION ]]; then
|
|
||||||
echo "About to release $VERSION from $BRANCH. "
|
|
||||||
else
|
|
||||||
echo "About to release $VERSION from $BRANCH and bump to $NEXT_VERSION-pre."
|
|
||||||
fi
|
|
||||||
if [[ $INSANE != 0 ]]; then
|
|
||||||
read -r -p "$INSANE sanity check(s) failed, really proceed? [y/n] " CONFIRM
|
|
||||||
else
|
|
||||||
read -r -p "Look good? [y/n] " CONFIRM
|
|
||||||
fi
|
|
||||||
if [[ $CONFIRM != "y" ]]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
git checkout "$BRANCH"
|
|
||||||
git pull
|
|
||||||
|
|
||||||
if [[ ! $PUBLISH ]]; then
|
|
||||||
# Make a release branch
|
|
||||||
git checkout -B "v$VERSION-release"
|
|
||||||
|
|
||||||
# Edit package.json to the right version, as it's inlined (see
|
|
||||||
# http://stackoverflow.com/a/22084103 for why we need the .bak file to make
|
|
||||||
# this mac & linux compatible)
|
|
||||||
sed -i.bak -E 's|"version": "[^"]+",|"version": "'$VERSION'",|' package.json
|
|
||||||
rm -f package.json.bak
|
|
||||||
|
|
||||||
# Build generated files
|
|
||||||
yarn build
|
|
||||||
|
|
||||||
if [[ $BRANCH != @(v*-release) ]]; then
|
|
||||||
if [ ! -z "$NEXT_VERSION" ]; then
|
|
||||||
# Edit package.json to the next version
|
|
||||||
sed -i.bak -E 's|"version": "[^"]+",|"version": "'$NEXT_VERSION'-pre",|' package.json
|
|
||||||
rm -f package.json.bak
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Edit docs to use CSS from CDN
|
|
||||||
grep -l '/static/' docs/*.md | xargs sed -i.bak \
|
|
||||||
's|/static/\([^"]\+\)|https://cdn.jsdelivr.net/npm/katex@./dist/\1" integrity="sha384-\1" crossorigin="anonymous|'
|
|
||||||
|
|
||||||
# Update the version number in CDN URLs included in the README and the documentation,
|
|
||||||
# and regenerate the Subresource Integrity hash for these files.
|
|
||||||
yarn node update-sri.js "$VERSION" README.md contrib/*/README.md \
|
|
||||||
docs/*.md docs/*.md.bak website/pages/index.html
|
|
||||||
|
|
||||||
# Generate a new version of the docs
|
|
||||||
pushd website
|
|
||||||
yarn run version "$VERSION"
|
|
||||||
popd
|
|
||||||
|
|
||||||
# Restore docs to use local built CSS
|
|
||||||
for file in docs/*.md.bak; do
|
|
||||||
mv -f "$file" "${file%.bak}"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
# Restore package.json
|
|
||||||
git checkout package.json
|
|
||||||
|
|
||||||
# Regenerate the Subresource Integrity hash in the README and the documentation
|
|
||||||
yarn node update-sri.js "$VERSION" README.md contrib/*/README.md \
|
|
||||||
docs/*.md website/pages/index.html website/versioned_docs/version-$VERSION/*.md
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make the commit and push
|
|
||||||
git add package.json README.md contrib/*/README.md \
|
|
||||||
docs website/pages/index.html website/versioned_docs/ \
|
|
||||||
website/versioned_sidebars/ website/versions.json
|
|
||||||
if [[ $BRANCH == @(v*-release) ]]; then
|
|
||||||
git commit -n -m "Update SRI hashes"
|
|
||||||
elif [[ ! $NEXT_VERSION ]]; then
|
|
||||||
git commit -n -m "Release v$VERSION"
|
|
||||||
else
|
|
||||||
git commit -n -m "Release v$VERSION" -m "Bump $BRANCH to v$NEXT_VERSION-pre"
|
|
||||||
fi
|
|
||||||
git push -u "$ORIGIN" "v$VERSION-release"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "The automatic parts are done!"
|
|
||||||
echo "Now create a pull request against master from 'v$VERSION-release'"
|
|
||||||
echo "Visit https://github.com/KaTeX/KaTeX/pulls to open a pull request."
|
|
||||||
echo "After it gets merged, run './release.sh -p $VERSION'!"
|
|
||||||
echo "Note that if KaTeX source code is changed after running this script,"
|
|
||||||
echo "you have to run the release script again."
|
|
||||||
|
|
||||||
git diff --stat --exit-code # check for uncommitted changes
|
|
||||||
else
|
|
||||||
# Edit package.json to the right version
|
|
||||||
sed -i.bak -E 's|"version": "[^"]+",|"version": "'$VERSION'",|' package.json
|
|
||||||
rm -f package.json.bak
|
|
||||||
|
|
||||||
# Build generated files
|
|
||||||
yarn dist
|
|
||||||
|
|
||||||
# Check Subresource Integrity hashes
|
|
||||||
yarn node update-sri.js check README.md contrib/*/README.md
|
|
||||||
|
|
||||||
# Make the tag and push
|
|
||||||
git tag -a "v$VERSION" -m "v$VERSION"
|
|
||||||
git push "$ORIGIN" "v$VERSION"
|
|
||||||
|
|
||||||
# Update npm (cdnjs update automatically)
|
|
||||||
# Fallback to npm publish, if yarn cannot authenticate, e.g., 2FA
|
|
||||||
yarn publish --new-version "$VERSION" || npm publish
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "The automatic parts are done!"
|
|
||||||
echo "Now all that's left is to create the release on GitHub."
|
|
||||||
echo "Visit https://github.com/KaTeX/KaTeX/releases/new?tag=v$VERSION to edit the release notes."
|
|
||||||
echo "Don't forget to upload katex.tar.gz and katex.zip to the release!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $DRY_RUN ]]; then
|
|
||||||
echo ""
|
|
||||||
echo "This was a dry run."
|
|
||||||
echo "Operations using git or yarn were printed not executed."
|
|
||||||
echo "Some files got modified, though, so you might want to undo "
|
|
||||||
echo "these changes now, e.g. using \`git checkout -- .\` or similar."
|
|
||||||
echo ""
|
|
||||||
fi
|
|
@@ -1,10 +1,11 @@
|
|||||||
// Update badge and CDN urls and subresource integrity hashes
|
// Update badge and CDN urls and subresource integrity hashes
|
||||||
// Usage: node update-sri.js <VERSION> FILES...
|
// Usage: node update-sri.js <VERSION> FILES...
|
||||||
|
// To use the version from package.json, pass `package` as VERSION
|
||||||
// To check SRI hashes, pass `check` as VERSION
|
// To check SRI hashes, pass `check` as VERSION
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
const sriToolbox = require("sri-toolbox");
|
const sriToolbox = require("sri-toolbox");
|
||||||
|
|
||||||
const version = process.argv[2];
|
const version = process.argv[2] === "package" ? require("./package.json").version : process.argv[2];
|
||||||
|
|
||||||
Promise.all(process.argv.slice(3).map(file =>
|
Promise.all(process.argv.slice(3).map(file =>
|
||||||
fs.readFile(file, "utf8")
|
fs.readFile(file, "utf8")
|
||||||
|
@@ -21,6 +21,26 @@ fs.copySync('../dist/contrib/copy-tex.min.css', 'static/static/copy-tex.min.css'
|
|||||||
fs.copySync('../dist/contrib/copy-tex.min.js', 'static/static/copy-tex.min.js');
|
fs.copySync('../dist/contrib/copy-tex.min.js', 'static/static/copy-tex.min.js');
|
||||||
fs.copySync('../dist/contrib/mhchem.min.js', 'static/static/mhchem.min.js');
|
fs.copySync('../dist/contrib/mhchem.min.js', 'static/static/mhchem.min.js');
|
||||||
|
|
||||||
|
// get URLs for previous deployments of release commit
|
||||||
|
if (process.env.NETLIFY_API_KEY) {
|
||||||
|
const NetlifyAPI = require('netlify');
|
||||||
|
const client = new NetlifyAPI(process.env.NETLIFY_API_KEY);
|
||||||
|
|
||||||
|
client.listSiteDeploys({site_id: 'f868b1d7-3130-44e8-ae1b-640f4ed3e401'})
|
||||||
|
.then(deploys => {
|
||||||
|
const versions = deploys.reduce((list, deploy) => {
|
||||||
|
if (deploy.context === "production" && deploy.state === "ready") {
|
||||||
|
const m = /^Release v([\d.]+)|^chore\(release\): ([\d.]+)/
|
||||||
|
.exec(deploy.title);
|
||||||
|
if (m) {
|
||||||
|
list.push({name: m[1] || m[2], id: deploy.id});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}, []).reverse();
|
||||||
|
fs.writeFileSync('prev-versions.json', JSON.stringify(versions));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// use KaTeX from CDN on the main page for Netlify production deploy
|
// use KaTeX from CDN on the main page for Netlify production deploy
|
||||||
if (process.env.CONTEXT === 'production') {
|
if (process.env.CONTEXT === 'production') {
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"docusaurus": "^1.14.6",
|
"docusaurus": "^1.14.6",
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.0.1",
|
||||||
|
"netlify": "^6.1.14",
|
||||||
"react": "^16.8.4"
|
"react": "^16.8.4"
|
||||||
},
|
},
|
||||||
"dependenciesMeta": {
|
"dependenciesMeta": {
|
||||||
|
@@ -13,11 +13,11 @@ const {Container} = require('../../core/CompLibrary');
|
|||||||
const CWD = process.cwd();
|
const CWD = process.cwd();
|
||||||
|
|
||||||
const {title, baseUrl, repoUrl} = require(`${CWD}/siteConfig.js`);
|
const {title, baseUrl, repoUrl} = require(`${CWD}/siteConfig.js`);
|
||||||
const versions = fs.existsSync(`${CWD}/versions.json`)
|
const {version: latestVersion} = require(`${CWD}/../package.json`);
|
||||||
? require(`${CWD}/versions.json`) : [];
|
const prevVersions = fs.existsSync(`${CWD}/prev-versions.json`)
|
||||||
|
? require(`${CWD}/prev-versions.json`) : [];
|
||||||
|
|
||||||
function Versions(props) {
|
function Versions(props) {
|
||||||
const latestVersion = versions[0];
|
|
||||||
const language = props.language && props.language !== 'en' ?
|
const language = props.language && props.language !== 'en' ?
|
||||||
props.language + '/' : '';
|
props.language + '/' : '';
|
||||||
return (
|
return (
|
||||||
@@ -47,47 +47,26 @@ function Versions(props) {
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<h3 id="rc">Latest Version</h3>
|
|
||||||
<p>
|
|
||||||
Here you can find the latest documentation and unreleased code.
|
|
||||||
</p>
|
|
||||||
<table className="versions">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th>master</th>
|
|
||||||
<td>
|
|
||||||
<a
|
|
||||||
href={`${baseUrl}docs/${language}next/node.html`}>
|
|
||||||
Documentation
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href={repoUrl}>Source Code</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<h3 id="archive">Past Versions</h3>
|
<h3 id="archive">Past Versions</h3>
|
||||||
<p>
|
<p>
|
||||||
Here you can find documentation for previous versions of KaTeX.
|
Here you can find documentation for previous versions of KaTeX.
|
||||||
</p>
|
</p>
|
||||||
<table className="versions">
|
<table className="versions">
|
||||||
<tbody>
|
<tbody>
|
||||||
{versions.map(
|
{prevVersions.map(
|
||||||
version =>
|
version =>
|
||||||
version !== latestVersion && (
|
version.name !== latestVersion && (
|
||||||
<tr key={version}>
|
<tr key={version.name}>
|
||||||
<th>{version}</th>
|
<th>{version.name}</th>
|
||||||
<td>
|
<td>
|
||||||
<a
|
<a href={`https://${
|
||||||
href={`${baseUrl}docs/${
|
version.id
|
||||||
language
|
}--katex.netlify.app/docs/${language}`}>
|
||||||
}${version}/node.html`}>
|
|
||||||
Documentation
|
Documentation
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href={`${repoUrl}/releases/tag/v${version}`}>
|
<a href={`${repoUrl}/releases/tag/v${version.name}`}>
|
||||||
Release Notes
|
Release Notes
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
@@ -157,6 +157,8 @@ const users = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const {version} = require('../package.json');
|
||||||
|
|
||||||
const siteConfig = {
|
const siteConfig = {
|
||||||
title: 'KaTeX',
|
title: 'KaTeX',
|
||||||
tagline: 'The fastest math typesetting library for the web',
|
tagline: 'The fastest math typesetting library for the web',
|
||||||
@@ -170,6 +172,8 @@ const siteConfig = {
|
|||||||
headerLinks: [
|
headerLinks: [
|
||||||
{href: '/#demo', label: 'Try'},
|
{href: '/#demo', label: 'Try'},
|
||||||
{doc: 'node', label: 'Docs'},
|
{doc: 'node', label: 'Docs'},
|
||||||
|
// always link to the latest version page
|
||||||
|
{href: 'https://katex.org/versions.html', label: 'v' + version},
|
||||||
{page: 'users', label: 'Users'},
|
{page: 'users', label: 'Users'},
|
||||||
{href: 'https://github.com/KaTeX/KaTeX', label: 'GitHub'},
|
{href: 'https://github.com/KaTeX/KaTeX', label: 'GitHub'},
|
||||||
{search: true},
|
{search: true},
|
||||||
@@ -216,7 +220,7 @@ const siteConfig = {
|
|||||||
apiKey: '46ecd80046d78d4e5d9a5c06f559dfaa',
|
apiKey: '46ecd80046d78d4e5d9a5c06f559dfaa',
|
||||||
indexName: 'katex',
|
indexName: 'katex',
|
||||||
algoliaOptions: {
|
algoliaOptions: {
|
||||||
facetFilters: ['language:LANGUAGE', 'version:VERSION'],
|
facetFilters: ['language:LANGUAGE'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-api
|
|
||||||
title: API
|
|
||||||
original_id: api
|
|
||||||
---
|
|
||||||
## In-browser rendering
|
|
||||||
Call `katex.render` with a TeX expression and a DOM element to render into:
|
|
||||||
|
|
||||||
```js
|
|
||||||
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
|
|
||||||
throwOnError: false
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
To avoid escaping the backslash (double backslash), you can use
|
|
||||||
[`String.raw`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
|
|
||||||
(but beware that `${`, `\u` and `\x` may still need escaping):
|
|
||||||
```js
|
|
||||||
katex.render(String.raw`c = \pm\sqrt{a^2 + b^2}`, element, {
|
|
||||||
throwOnError: false
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Server-side rendering or rendering to a string
|
|
||||||
To generate HTML on the server or to generate an HTML string of the rendered math, you can use `katex.renderToString`:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
|
|
||||||
throwOnError: false
|
|
||||||
});
|
|
||||||
// '<span class="katex">...</span>'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Handling errors
|
|
||||||
|
|
||||||
The examples above use the `throwOnError: false` option, which renders invalid
|
|
||||||
inputs as the TeX source code in red (by default), with the error message as
|
|
||||||
hover text. Without this option, invalid LaTeX will cause a
|
|
||||||
`katex.ParseError` exception to be thrown. See [handling errors](error.md).
|
|
||||||
|
|
||||||
## Configuring KaTeX
|
|
||||||
|
|
||||||
The last argument to `katex.render` and `katex.renderToString` can contain
|
|
||||||
[a variety of rendering options](options.md).
|
|
@@ -1,96 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-autorender
|
|
||||||
title: Auto-render Extension
|
|
||||||
original_id: autorender
|
|
||||||
---
|
|
||||||
This is an extension to automatically render all of the math inside of text. It
|
|
||||||
searches all of the text nodes within a given element for the given delimiters,
|
|
||||||
ignoring certain tags like `<pre>`, and renders the math in place.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
This extension isn't part of KaTeX proper, so the script needs to be included
|
|
||||||
(via a `<script>` tag) in the page along with KaTeX itself. For example,
|
|
||||||
using a CDN:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above, the [`defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
indicates that the script doesn't need to execute until the page has loaded,
|
|
||||||
speeding up page rendering; and the `onload` attribute calls
|
|
||||||
`renderMathInElement` once the auto-render script loads.
|
|
||||||
|
|
||||||
Alternatively, you can call the `renderMathInElement` when (or after) the
|
|
||||||
[`DOMContentLoaded` event](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded)
|
|
||||||
fires on the document or in another deferred script.
|
|
||||||
This approach is useful for specifying or computing options, or if you don't
|
|
||||||
want to use a `defer` or `onload` attribute.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
renderMathInElement(document.body, {
|
|
||||||
// ...options...
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
This extension exposes a single function, `window.renderMathInElement`, with
|
|
||||||
the following API:
|
|
||||||
|
|
||||||
```js
|
|
||||||
function renderMathInElement(elem, options)
|
|
||||||
```
|
|
||||||
|
|
||||||
`elem` is an HTML DOM element. The function will recursively search for text
|
|
||||||
nodes inside this element and render the math in them.
|
|
||||||
|
|
||||||
`options` is an optional object argument that can have the same keys as [the
|
|
||||||
object passed to `katex.render`](https://github.com/KaTeX/KaTeX/#rendering-options),
|
|
||||||
in addition to several auto-render-specific keys:
|
|
||||||
|
|
||||||
- `delimiters`: This is a list of delimiters to look for math. Each delimiter
|
|
||||||
has three properties:
|
|
||||||
|
|
||||||
- `left`: A string which starts the math expression (i.e. the left delimiter).
|
|
||||||
- `right`: A string which ends the math expression (i.e. the right delimiter).
|
|
||||||
- `display`: A boolean of whether the math in the expression should be
|
|
||||||
rendered in display mode or not.
|
|
||||||
|
|
||||||
The default value is:
|
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{left: "$$", right: "$$", display: true},
|
|
||||||
{left: "\\(", right: "\\)", display: false},
|
|
||||||
{left: "\\[", right: "\\]", display: true}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
- `ignoredTags`: This is a list of DOM node types to ignore when recursing
|
|
||||||
through. The default value is
|
|
||||||
`["script", "noscript", "style", "textarea", "pre", "code"]`.
|
|
||||||
|
|
||||||
- `ignoredClasses`: This is a list of DOM node class names to ignore when
|
|
||||||
recursing through. By default, this value is not set.
|
|
||||||
|
|
||||||
- `errorCallback`: A callback method returning a message and an error stack
|
|
||||||
in case of an critical error during rendering. The default uses `console.error`.
|
|
||||||
|
|
||||||
The `displayMode` property of the options object is ignored, and is
|
|
||||||
instead taken from the `display` key of the corresponding entry in the
|
|
||||||
`delimiters` key.
|
|
||||||
|
|
||||||
The same `options.macros` object (which defaults to an empty object `{}`)
|
|
||||||
is passed into several calls to `katex.render`, so that consecutive equations
|
|
||||||
can build up shared macros by `\gdef`.
|
|
@@ -1,99 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-browser
|
|
||||||
title: Browser
|
|
||||||
original_id: browser
|
|
||||||
---
|
|
||||||
> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11.
|
|
||||||
|
|
||||||
## Global
|
|
||||||
If you include the `katex.js` directly, the `katex` object will be available as
|
|
||||||
a global variable.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.css" integrity="sha384-xNwWFq3SIvM4dq/1RUyWumk8nj/0KFg4TOnNcfzUU4X2gNn3WoRML69gO7waf3xh" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.js" integrity="sha384-UP7zD+aGyuDvxWQEDSRYcvoTxJSD82C6VvuEBktJZGo25CVhDstY9sCDHvyceo9L" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides minified versions:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
The loading of scripts are [deferred using `defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to speed up page rendering. The `katex` object will be available after
|
|
||||||
[`DOMContentLoaded` event is fired on the `document`](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded).
|
|
||||||
If you do not use `defer`, `katex` object will be available after corresponding
|
|
||||||
`script` tag.
|
|
||||||
|
|
||||||
If KaTeX is not used immediately or not critical, it is possible to load KaTeX
|
|
||||||
asynchronously. Add [`async` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to `script` and use [`rel="preload"` and `onload` attribute](https://github.com/filamentgroup/loadCSS)
|
|
||||||
on `link`.
|
|
||||||
|
|
||||||
You can prefetch KaTeX fonts to prevent FOUT or FOIT. Use [Font Loading API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API)
|
|
||||||
or [Web Font Loader](https://github.com/typekit/webfontloader):
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
window.WebFontConfig = {
|
|
||||||
custom: {
|
|
||||||
families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7',
|
|
||||||
'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script',
|
|
||||||
'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3',
|
|
||||||
'KaTeX_Size4', 'KaTeX_Typewriter'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use [`rel="preload"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content).
|
|
||||||
Add `<link rel="preload" href=(path to WOFF2 font) as="font" type="font/woff2" crossorigin="anonymous">`
|
|
||||||
to `head`. Note that [only few browsers support it](https://caniuse.com/#feat=link-rel-preload)
|
|
||||||
and they all support WOFF2 so preloading WOFF2 fonts is enough.
|
|
||||||
|
|
||||||
See [Google Web Fundamentals - Web Font Optimization](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/webfont-optimization)
|
|
||||||
for more detail.
|
|
||||||
|
|
||||||
## Module Loaders
|
|
||||||
### AMD
|
|
||||||
```html
|
|
||||||
<script type="text/javascript">
|
|
||||||
require([
|
|
||||||
"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.js",
|
|
||||||
], katex => {
|
|
||||||
...
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.css" integrity="sha384-xNwWFq3SIvM4dq/1RUyWumk8nj/0KFg4TOnNcfzUU4X2gNn3WoRML69gO7waf3xh" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
### ECMAScript module
|
|
||||||
```html
|
|
||||||
<script type="module" type="text/javascript">
|
|
||||||
import katex from 'https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.mjs';
|
|
||||||
...
|
|
||||||
</script>
|
|
||||||
<script nomodule defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.js" integrity="sha384-UP7zD+aGyuDvxWQEDSRYcvoTxJSD82C6VvuEBktJZGo25CVhDstY9sCDHvyceo9L" crossorigin="anonymous"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.css" integrity="sha384-xNwWFq3SIvM4dq/1RUyWumk8nj/0KFg4TOnNcfzUU4X2gNn3WoRML69gO7waf3xh" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
> Use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules.
|
|
||||||
|
|
||||||
## Download & Host Things Yourself
|
|
||||||
Download a [KaTeX release](https://github.com/KaTeX/KaTeX/releases),
|
|
||||||
copy `katex.js`, `katex.css`
|
|
||||||
(or `katex.min.js` and `katex.min.css` to use minified versions),
|
|
||||||
and the `fonts` directory, and include or import it like above.
|
|
||||||
|
|
||||||
You can also build from source. See [Building from Source](node.md#building-from-source)
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
## Bundler
|
|
||||||
[Use Node.js package managers to install KaTeX and import it](node.md) in your
|
|
||||||
project. Then bundle using bundlers like [webpack](https://webpack.js.org/) or
|
|
||||||
[rollup.js](https://rollupjs.org/). Note that you have to bundle the stylesheet
|
|
||||||
(`katex.css`) or include it manually.
|
|
@@ -1,61 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-cli
|
|
||||||
title: CLI
|
|
||||||
original_id: cli
|
|
||||||
---
|
|
||||||
|
|
||||||
KaTeX installed [using Node.js package managers](node.md) comes with a
|
|
||||||
built-in command-line interface (CLI) which can be used to render TeX to HTML.
|
|
||||||
By default, CLI will take the input from standard input.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npx katex
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above uses the `npx` command to run the locally installed executable
|
|
||||||
after `npm install katex`. You can also execute with the relative path:
|
|
||||||
`./node_modules/.bin/katex`
|
|
||||||
|
|
||||||
> To use the CLI from local Git clone, you need to build the project first.
|
|
||||||
See [Building from Source](node.md#building-from-source) for more details.
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### `-V, --version`
|
|
||||||
output the version number
|
|
||||||
|
|
||||||
### `-d, --display-mode`
|
|
||||||
Render math in display mode, which puts the math in display style (so \int and \sum are large, for example), and centers the math on the page on its own line.
|
|
||||||
|
|
||||||
### `-t, --no-throw-on-error`
|
|
||||||
Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.
|
|
||||||
|
|
||||||
### `-c, --error-color <color>`
|
|
||||||
A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option. (default: #cc0000)
|
|
||||||
|
|
||||||
### `-b, --color-is-text-color`
|
|
||||||
Makes \color behave like LaTeX's 2-argument \textcolor, instead of LaTeX's one-argument \color mode change.
|
|
||||||
|
|
||||||
### `-S, --strict`
|
|
||||||
Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX
|
|
||||||
|
|
||||||
### `-s, --max-size <n>`
|
|
||||||
If non-zero, all user-specified sizes, e.g. in \rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large (default: Infinity)
|
|
||||||
|
|
||||||
### `-e, --max-expand <n>`
|
|
||||||
Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.
|
|
||||||
|
|
||||||
### `-m, --macro <def>`
|
|
||||||
Define custom macro of the form '\foo:expansion' (use multiple -m arguments for multiple macros). (default: )
|
|
||||||
|
|
||||||
### `-f, --macro-file <path>`
|
|
||||||
Read macro definitions, one per line, from the given file.
|
|
||||||
|
|
||||||
### `-i, --input <path>`
|
|
||||||
Read LaTeX input from the given file.
|
|
||||||
|
|
||||||
### `-o, --output <path>`
|
|
||||||
Write html output to the given file.
|
|
||||||
|
|
||||||
### `-h, --help`
|
|
||||||
Output usage information
|
|
@@ -1,36 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-error
|
|
||||||
title: Handling Errors
|
|
||||||
original_id: error
|
|
||||||
---
|
|
||||||
If KaTeX encounters an error (invalid or unsupported LaTeX) and `throwOnError`
|
|
||||||
hasn't been set to `false`, then `katex.render` and `katex.renderToString`
|
|
||||||
will throw an exception of type `katex.ParseError`.
|
|
||||||
The message in this error includes some of the LaTeX source code,
|
|
||||||
so needs to be escaped if you want to render it to HTML. For example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
try {
|
|
||||||
var html = katex.renderToString(texString);
|
|
||||||
// '<span class="katex">...</span>'
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof katex.ParseError) {
|
|
||||||
// KaTeX can't parse the expression
|
|
||||||
html = ("Error in LaTeX '" + texString + "': " + e.message)
|
|
||||||
.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
||||||
} else {
|
|
||||||
throw e; // other error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
In particular, you should convert `&`, `<`, `>` characters to
|
|
||||||
`&`, `<`, `>` before including either LaTeX source code or
|
|
||||||
exception messages in your HTML/DOM.
|
|
||||||
(This can also be done using `_.escape`.)
|
|
||||||
Failure to escape in this way makes a `<script>` injection attack possible
|
|
||||||
if your LaTeX source is untrusted.
|
|
||||||
|
|
||||||
Alternatively, you can set `throwOnError` to `false` to use built-in behavior
|
|
||||||
of rendering the LaTeX source code with hover text stating the error.
|
|
||||||
See [rendering options](options.md).
|
|
@@ -1,49 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-font
|
|
||||||
title: Font
|
|
||||||
original_id: font
|
|
||||||
---
|
|
||||||
By changing the variables in the `fonts.less` file at the [katex-fonts submodule](https://github.com/KaTeX/katex-fonts/),
|
|
||||||
several properties of the way fonts are used can be changed.
|
|
||||||
|
|
||||||
## Font size and lengths
|
|
||||||
By default, KaTeX math is rendered in a 1.21× larger font than the surrounding
|
|
||||||
context, which makes super- and subscripts easier to read. You can control
|
|
||||||
this using CSS, for example, to set to 1.1×:
|
|
||||||
|
|
||||||
```css
|
|
||||||
.katex { font-size: 1.1em; }
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX supports all TeX units, including absolute units like `cm` and `in`.
|
|
||||||
Absolute units are currently scaled relative to the default TeX font size of
|
|
||||||
10pt, so that `\kern1cm` produces the same results as `\kern2.845275em`.
|
|
||||||
As a result, relative and absolute units are both uniformly scaled relative
|
|
||||||
to LaTeX with a 10pt font; for example, the rectangle `\rule{1cm}{1em}` has
|
|
||||||
the same aspect ratio in KaTeX as in LaTeX. However, because most browsers
|
|
||||||
default to a larger font size, this typically means that a 1cm kern in KaTeX
|
|
||||||
will appear larger than 1cm in browser units.
|
|
||||||
|
|
||||||
## Kinds of fonts used
|
|
||||||
|
|
||||||
The default build of KaTeX includes each of the needed fonts in three different formats: `ttf`, `woff`, and `woff2`.
|
|
||||||
|
|
||||||
- `ttf`s are included to support old versions of Chrome, Safari, Firefox, etc. (Here "old" means Firefox 3.5, Chrome < 5, and Safari <= 5.1, all of which are no longer supported: see [woff](https://caniuse.com/#search=woff) vs. [ttf](https://caniuse.com/#search=ttf)).
|
|
||||||
- `woff` is the format that is most widely supported (all modern browsers support it), so it probably provides the most benefit to being included.
|
|
||||||
- `woff2`s are included for very new versions of Chrome, because they are much smaller and faster to load.
|
|
||||||
|
|
||||||
Based on this information and what you want to support with your website, you might decide to include different versions of the fonts besides what comes with the standard installation.
|
|
||||||
|
|
||||||
For example, if you wanted to create a trimmed down version of KaTeX, you could only include the `woff` files and gain the most support with the least number of files. To do this:
|
|
||||||
|
|
||||||
1. Set `@use-ttf`, and `@use-woff2` to `false` at the top of [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less).
|
|
||||||
2. Rebuild KaTeX by running `yarn build` from the top-level directory.
|
|
||||||
3. Include only the `build/fonts/*.woff` files in your distribution.
|
|
||||||
|
|
||||||
## Location of font files
|
|
||||||
|
|
||||||
The default build of KaTeX expects the KaTeX fonts to be located in a directory called `fonts` which is a sibling of the `katex.min.css` stylesheet. This can be changed as follows:
|
|
||||||
|
|
||||||
1. At the top of the [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less) file, set `@font-folder` to the location of your fonts. You can use relative or absolute paths, so setting it to `"/fonts"` would cause it to search for the fonts in a root `fonts` folder, while `"../fonts"` would search in a `fonts` directory one level above the `katex.min.css` file.
|
|
||||||
2. Rebuild KaTeX by running `yarn build` from the top-level directory.
|
|
||||||
3. Use the newly generated `build/katex.min.css` file, and place the fonts where you indicated.
|
|
@@ -1,42 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-issues
|
|
||||||
title: Common Issues
|
|
||||||
original_id: issues
|
|
||||||
---
|
|
||||||
- Many Markdown preprocessors, such as the one that Jekyll and GitHub Pages use,
|
|
||||||
have a "smart quotes" feature. This changes `'` to `’` which is an issue for
|
|
||||||
math containing primes, e.g. `f'`. This can be worked around by defining a
|
|
||||||
single character macro which changes them back, e.g. `{"’", "'"}`.
|
|
||||||
- KaTeX follows LaTeX's rendering of `aligned` and `matrix` environments unlike
|
|
||||||
MathJax. When displaying fractions one above another in these vertical
|
|
||||||
layouts there may not be enough space between rows for people who are used to
|
|
||||||
MathJax's rendering. The distance between rows can be adjusted by using
|
|
||||||
`\\[0.1em]` instead of the standard line separator distance.
|
|
||||||
- KaTeX does not support the `align` environment because LaTeX doesn't support
|
|
||||||
`align` in math mode. The `aligned` environment offers the same functionality
|
|
||||||
but in math mode, so use that instead.
|
|
||||||
- MathJax defines `\color` to be like `\textcolor` by default; set KaTeX's
|
|
||||||
`colorIsTextColor` option to `true` for this behavior. KaTeX's default
|
|
||||||
behavior matches MathJax with its `color.js` extension enabled.
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
To check the stylesheet (katex.css) is properly loaded, add following code to
|
|
||||||
anywhere in the document:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<style>
|
|
||||||
.katex-version {display: none;}
|
|
||||||
.katex-version::after {content:"0.10.2 or earlier";}
|
|
||||||
</style>
|
|
||||||
<span class="katex">
|
|
||||||
<span class="katex-mathml">The KaTeX stylesheet is not loaded!</span>
|
|
||||||
<span class="katex-version rule">KaTeX stylesheet version: </span>
|
|
||||||
</span>
|
|
||||||
```
|
|
||||||
|
|
||||||
If it is loaded properly, it'll show its version. Make sure its version matches
|
|
||||||
the version of the JavaScript file (katex.js), which is defined in `katex.version`.
|
|
||||||
If it is not loaded properly, it'll show:
|
|
||||||
|
|
||||||
> The KaTeX stylesheet is not loaded!
|
|
@@ -1,41 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-libs
|
|
||||||
title: Extensions & Libraries
|
|
||||||
original_id: libs
|
|
||||||
---
|
|
||||||
## Extensions
|
|
||||||
|
|
||||||
These extensions are provided by KaTeX.
|
|
||||||
|
|
||||||
- [Auto-render](autorender.md): Automatically renders all of the math inside text
|
|
||||||
- [Copy-tex](https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex): When selecting and copying KaTeX-rendered elements, copies their LaTeX source to the clipboard
|
|
||||||
- [`math/tex` Custom Script Type](https://github.com/KaTeX/KaTeX/tree/master/contrib/mathtex-script-type): Automatically displays LaTeX math inside `script` tags with `type=math/tex`
|
|
||||||
|
|
||||||
## Libraries
|
|
||||||
|
|
||||||
These libraries are maintained by third-parties.
|
|
||||||
|
|
||||||
### Angular2+
|
|
||||||
- [ng-katex](https://github.com/garciparedes/ng-katex): Angular module to write beautiful math expressions with TeX syntax boosted by KaTeX library
|
|
||||||
|
|
||||||
### iOS
|
|
||||||
- [KaTeX-iOS](https://github.com/ianarawjo/KaTeX-iOS): iOS UIView that renders TeX expressions with KaTeX
|
|
||||||
|
|
||||||
### React
|
|
||||||
- [react-latex](https://github.com/zzish/react-latex): React component to render latex strings, based on KaTeX
|
|
||||||
- [react-katex](https://github.com/talyssonoc/react-katex): React components that use KaTeX to typeset math expressions
|
|
||||||
|
|
||||||
### Ruby
|
|
||||||
|
|
||||||
- [katex-ruby](https://github.com/glebm/katex-ruby): Provides server-side rendering and integration with popular Ruby web frameworks (Rails, Hanami, and anything that uses Sprockets).
|
|
||||||
|
|
||||||
### AsciiMath
|
|
||||||
|
|
||||||
If you want to render math written in [AsciiMath](http://asciimath.org/),
|
|
||||||
you'll need to first convert AsciiMath into LaTeX input, then call KaTeX.
|
|
||||||
|
|
||||||
- [asciimath2tex](https://github.com/christianp/asciimath2tex): Converts AsciiMath to TeX, with KaTeX in mind
|
|
||||||
|
|
||||||
### Canvas LaTeX
|
|
||||||
|
|
||||||
- [canvas-latex](https://github.com/CurriculumAssociates/canvas-latex): Renders mathematical expressions on HTML5's canvas element. Supports popular libraries like: CreateJS, and PIXI.
|
|
@@ -1,69 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-node
|
|
||||||
title: Node.js
|
|
||||||
original_id: node
|
|
||||||
---
|
|
||||||
## Installation
|
|
||||||
### npm
|
|
||||||
Install with `npm`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install katex
|
|
||||||
# or globally
|
|
||||||
npm install -g katex
|
|
||||||
```
|
|
||||||
|
|
||||||
### Yarn
|
|
||||||
Install with `Yarn`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn add katex
|
|
||||||
# or globally
|
|
||||||
yarn global add katex
|
|
||||||
```
|
|
||||||
|
|
||||||
### Building from Source
|
|
||||||
To build you will need Git, Node.js 6.9 or later, and Yarn.
|
|
||||||
|
|
||||||
Clone a copy of the GitHub source repository:
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/KaTeX/KaTeX.git
|
|
||||||
cd KaTeX
|
|
||||||
```
|
|
||||||
|
|
||||||
Then install dependencies and run `build` script:
|
|
||||||
```bash
|
|
||||||
yarn
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
If you'd like to use the built KaTeX in other projects, install the package by
|
|
||||||
specifying the path:
|
|
||||||
```bash
|
|
||||||
yarn add /path/to/KaTeX
|
|
||||||
# or using npm
|
|
||||||
npm install /path/to/KaTeX
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can manually download the package and source code from
|
|
||||||
[GitHub releases](https://github.com/KaTeX/KaTeX/releases).
|
|
||||||
|
|
||||||
## Importing
|
|
||||||
KaTeX is exported as a CommonJS module, which can be imported using `require`:
|
|
||||||
```js
|
|
||||||
const katex = require('katex');
|
|
||||||
```
|
|
||||||
|
|
||||||
If you're using a module loader, transpiler, or bundler that supports interoperability
|
|
||||||
between ECMAScript module and CommonJS module, you can use `import`:
|
|
||||||
```js
|
|
||||||
import katex from 'katex';
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides an ECMAScript module:
|
|
||||||
```js
|
|
||||||
import katex from 'katex/dist/katex.mjs'
|
|
||||||
```
|
|
||||||
|
|
||||||
> The ES module contains ES6 syntaxes and features, and may need transpiling to
|
|
||||||
use in old environments:
|
|
@@ -1,40 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-options
|
|
||||||
title: Options
|
|
||||||
original_id: options
|
|
||||||
---
|
|
||||||
You can provide an object of options as the last argument to [`katex.render` and `katex.renderToString`](api.md). Available options are:
|
|
||||||
|
|
||||||
- `displayMode`: `boolean`. If `true` the math will be rendered in display mode, which will put the math in display style (so `\int` and `\sum` are large, for example), and will center the math on the page on its own line. If `false` the math will be rendered in inline mode. (default: `false`)
|
|
||||||
- `throwOnError`: `boolean`. If `true` (the default), KaTeX will throw a `ParseError` when it encounters an unsupported command or invalid LaTeX. If `false`, KaTeX will render unsupported commands as text, and render invalid LaTeX as its source code with hover text giving the error, in the color given by `errorColor`.
|
|
||||||
- `errorColor`: `string`. A color string given in the format `"#XXX"` or `"#XXXXXX"`. This option determines the color that unsupported commands and invalid LaTeX are rendered in when `throwOnError` is set to `false`. (default: `#cc0000`)
|
|
||||||
- `macros`: `object`. A collection of custom macros. Each macro is a property with a name like `\name` (written `"\\name"` in JavaScript) which maps to a string that describes the expansion of the macro, or a function that accepts an instance of `MacroExpander` as first argument and returns the expansion as a string. `MacroExpander` is an internal API and subject to non-backwards compatible changes. See [`src/macros.js`](https://github.com/KaTeX/KaTeX/blob/master/src/macros.js) for its usage. Single-character keys can also be included in which case the character will be redefined as the given macro (similar to TeX active characters). *This object will be modified* if the LaTeX code defines its own macros via `\gdef`, which enables consecutive calls to KaTeX to share state.
|
|
||||||
- `colorIsTextColor`: `boolean`. If `true`, `\color` will work like LaTeX's `\textcolor`, and take two arguments (e.g., `\color{blue}{hello}`), which restores the old behavior of KaTeX (pre-0.8.0). If `false` (the default), `\color` will work like LaTeX's `\color`, and take one argument (e.g., `\color{blue}hello`). In both cases, `\textcolor` works as in LaTeX (e.g., `\textcolor{blue}{hello}`).
|
|
||||||
- `maxSize`: `number`. All user-specified sizes, e.g. in `\rule{500em}{500em}`, will be capped to `maxSize` ems. If set to `Infinity` (the default), users can make elements and spaces arbitrarily large.
|
|
||||||
- `maxExpand`: `number`. Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to `Infinity`, the macro expander will try to fully expand as in LaTeX. (default: 1000)
|
|
||||||
- `allowedProtocols`: `string[]`. Allowed protocols in `\href`. Use `_relative` to allow relative urls, and `*` to allow all protocols. (default: `["http", "https", "mailto", "_relative"]`)
|
|
||||||
- `strict`: `boolean` or `string` or `function` (default: `"warn"`). If `false` or `"ignore`", allow features that make writing LaTeX convenient but are not actually supported by (Xe)LaTeX (similar to MathJax). If `true` or `"error"` (LaTeX faithfulness mode), throw an error for any such transgressions. If `"warn"` (the default), warn about such behavior via `console.warn`. Provide a custom function `handler(errorCode, errorMsg, token)` to customize behavior depending on the type of transgression (summarized by the string code `errorCode` and detailed in `errorMsg`); this function can also return `"ignore"`, `"error"`, or `"warn"` to use a built-in behavior. A list of such features and their `errorCode`s:
|
|
||||||
- `"unknownSymbol"`: Use of unknown Unicode symbol, which will likely also
|
|
||||||
lead to warnings about missing character metrics, and layouts may be
|
|
||||||
incorrect (especially in terms of vertical heights).
|
|
||||||
- `"unicodeTextInMathMode"`: Use of Unicode text characters in math mode.
|
|
||||||
- `"mathVsTextUnits"`: Mismatch of math vs. text commands and units/mode.
|
|
||||||
- `"commentAtEnd"`: Use of `%` comment without a terminating newline.
|
|
||||||
LaTeX would thereby comment out the end of math mode (e.g. `$`),
|
|
||||||
causing an error.
|
|
||||||
A second category of `errorCode`s never throw errors, but their strictness
|
|
||||||
affects the behavior of KaTeX:
|
|
||||||
- `"newLineInDisplayMode"`: Use of `\\` or `\newline` in display mode
|
|
||||||
(outside an array/tabular environment). In strict mode, no line break
|
|
||||||
results, as in LaTeX.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
katex.render("c = \\pm\\sqrt{a^2 + b^2}\\in\\RR", element, {
|
|
||||||
displayMode: true,
|
|
||||||
macros: {
|
|
||||||
"\\RR": "\\mathbb{R}"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-security
|
|
||||||
title: Security
|
|
||||||
original_id: security
|
|
||||||
---
|
|
||||||
Any HTML generated by KaTeX *should* be safe from `<script>` or other code
|
|
||||||
injection attacks.
|
|
||||||
|
|
||||||
Of course, it is always a good idea to sanitize the HTML, though you will need
|
|
||||||
a rather generous whitelist (including some of SVG and MathML) to support
|
|
||||||
all of KaTeX.
|
|
||||||
|
|
||||||
Use `maxSize` option for preventing large width/height visual affronts,
|
|
||||||
use `maxExpand` for preventing infinite macro loop attacks, and
|
|
||||||
use `allowedProtocols` for preventing certain protocols in `\href`. Please
|
|
||||||
refer to [Options](options.md) for more details.
|
|
||||||
|
|
||||||
The error message thrown by KaTeX may contain unescaped LaTeX source code.
|
|
||||||
See [Handling Errors](error.md) for more details.
|
|
||||||
|
|
||||||
> If you discovered a security issue, please let us know via https://hackerone.com/khanacademy
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,637 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.0-supported
|
|
||||||
title: Supported Functions
|
|
||||||
original_id: supported
|
|
||||||
---
|
|
||||||
This is a list of TeX functions supported by KaTeX. It is sorted into logical groups.
|
|
||||||
|
|
||||||
There is a similar [Support Table](./support_table.md), sorted alphabetically, that lists both supported and un-supported functions.
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous"/>
|
|
||||||
<style>
|
|
||||||
p {overflow-wrap: break-word;}
|
|
||||||
table tr,
|
|
||||||
table td {
|
|
||||||
vertical-align: middle;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Accents
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------------------------|:----------------------------------------------------|:-----
|
|
||||||
|$a'$ `a'` |$\tilde{a}$ `\tilde{a}`|$\mathring{g}$ `\mathring{g}`
|
|
||||||
|$a''$ `a''`|$\widetilde{ac}$ `\widetilde{ac}` |$\overgroup{AB}$ `\overgroup{AB}`
|
|
||||||
|$a^{\prime}$ `a^{\prime}` |$\utilde{AB}$ `\utilde{AB}` |$\undergroup{AB}$ `\undergroup{AB}`
|
|
||||||
|$\acute{a}$ `\acute{a}`|$\vec{F}$ `\vec{F}` |$\Overrightarrow{AB}$ `\Overrightarrow{AB}`
|
|
||||||
|$\bar{y}$ `\bar{y}` |$\overleftarrow{AB}$ `\overleftarrow{AB}`|$\overrightarrow{AB}$ `\overrightarrow{AB}`
|
|
||||||
|$\breve{a}$ `\breve{a}`|$\underleftarrow{AB}$ `\underleftarrow{AB}` |$\underrightarrow{AB}$ `\underrightarrow{AB}`
|
|
||||||
|$\check{a}$ `\check{a}`|$\overleftharpoon{ac}$ `\overleftharpoon{ac}` |$\overrightharpoon{ac}$ `\overrightharpoon{ac}`
|
|
||||||
|$\dot{a}$ `\dot{a}` |$\overleftrightarrow{AB}$ `\overleftrightarrow{AB}` |$\overbrace{AB}$ `\overbrace{AB}`
|
|
||||||
|$\ddot{a}$ `\ddot{a}` |$\underleftrightarrow{AB}$ `\underleftrightarrow{AB}`|$\underbrace{AB}$ `\underbrace{AB}`
|
|
||||||
|$\grave{a}$ `\grave{a}`|$\overline{AB}$ `\overline{AB}` |$\overlinesegment{AB}$ `\overlinesegment{AB}`
|
|
||||||
|$\hat{\theta}$ `\hat{\theta}`|$\underline{AB}$ `\underline{AB}` |$\underlinesegment{AB}$ `\underlinesegment{AB}`
|
|
||||||
|$\widehat{ac}$ `\widehat{ac}`|$\widecheck{ac}$ `\widecheck{ac}` |
|
|
||||||
|
|
||||||
***Accent functions inside \\text{…}***
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:-----
|
|
||||||
|$\text{\'{a}}$ `\'{a}`|$\text{\~{a}}$ `\~{a}`|$\text{\.{a}}$ `\.{a}`|$\text{\H{a}}$ `\H{a}`
|
|
||||||
|$\text{\`{a}}$ <code>\\`{a}</code>|$\text{\={a}}$ `\={a}`|$\text{\"{a}}$ `\"{a}`|$\text{\v{a}}$ `\v{a}`
|
|
||||||
|$\text{\^{a}}$ `\^{a}`|$\text{\u{a}}$ `\u{a}`|$\text{\r{a}}$ `\r{a}`|
|
|
||||||
|
|
||||||
See also [letters](#letters)
|
|
||||||
|
|
||||||
## Delimiters
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:-----------------------------------|:---------------------------------------|:----------|:-------------------------------------------------------|:-----
|
|
||||||
|$(~)$ `( )` |$\lparen~\rparen$ `\lparen`<br>$~~~~$`\rparen`|$⌈~⌉$ `⌈ ⌉`|$\lceil~\rceil$ `\lceil`<br>$~~~~~$`\rceil` |$\uparrow$ `\uparrow`
|
|
||||||
|$[~]$ `[ ]` |$\lbrack~\rbrack$ `\lbrack`<br>$~~~~$`\rbrack`|$⌊~⌋$ `⌊ ⌋`|$\lfloor~\rfloor$ `\lfloor`<br>$~~~~~$`\rfloor` |$\downarrow$ `\downarrow`
|
|
||||||
|$\{ \}$ `\{ \}`|$\lbrace \rbrace$ `\lbrace`<br>$~~~~$`\rbrace`|$⎰⎱$ `⎰⎱` |$\lmoustache \rmoustache$ `\lmoustache`<br>$~~~~$`\rmoustache`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$⟨~⟩$ `⟨ ⟩` |$\langle~\rangle$ `\langle`<br>$~~~~$`\rangle`|$⟮~⟯$ `⟮ ⟯`|$\lgroup~\rgroup$ `\lgroup`<br>$~~~~~$`\rgroup` |$\Uparrow$ `\Uparrow`
|
|
||||||
|$\vert$ <code>|</code> |$\vert$ `\vert` |$┌ ┐$ `┌ ┐`|$\ulcorner \urcorner$ `\ulcorner`<br>$~~~~$`\urcorner` |$\Downarrow$ `\Downarrow`
|
|
||||||
|$\Vert$ <code>\|</code> |$\Vert$ `\Vert` |$└ ┘$ `└ ┘`|$\llcorner \lrcorner$ `\llcorner`<br>$~~~~$`\lrcorner` |$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\lvert~\rvert$ `\lvert`<br>$~~~~$`\rvert`|$\lVert~\rVert$ `\lVert`<br>$~~~~~$`\rVert` |`\left.`| `\right.` |$\backslash$ `\backslash`
|
|
||||||
|$\lang~\rang$ `\lang`<br>$~~~~$`\rang`|$\lt~\gt$ `\lt \gt`|$⟦~⟧$ `⟦ ⟧`|
|
|
||||||
|
|
||||||
**Delimiter Sizing**
|
|
||||||
|
|
||||||
$\left(\LARGE{AB}\right)$ `\left(\LARGE{AB}\right)`
|
|
||||||
|
|
||||||
$( \big( \Big( \bigg( \Bigg($ `( \big( \Big( \bigg( \Bigg(`
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:--------|:------|:--------|:-------|:------|
|
|
||||||
|`\left` |`\big` |`\bigl` |`\bigm` |`\bigr`
|
|
||||||
|`\middle`|`\Big` |`\Bigl` |`\Bigm` | `\Bigr`
|
|
||||||
|`\right` |`\bigg`|`\biggl` |`\biggm`|`\biggr`
|
|
||||||
| |`\Bigg`|`\Biggl` |`\Biggm`|`\Biggr`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Environments
|
|
||||||
|
|
||||||
<div class="katex-cards" id="environments">
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:--------
|
|
||||||
|$\begin{matrix} a & b \\ c & d \end{matrix}$ | `\begin{matrix}`<br> `a & b \\`<br> `c & d`<br>`\end{matrix}` |$\begin{array}{cc}a & b\\c & d\end{array}$ | `\begin{array}{cc}`<br> `a & b \\`<br> `c & d`<br>`\end{array}`
|
|
||||||
|$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$ |`\begin{pmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{pmatrix}` |$\begin{bmatrix} a & b \\ c & d \end{bmatrix}$ | `\begin{bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{bmatrix}`
|
|
||||||
|$\begin{vmatrix} a & b \\ c & d \end{vmatrix}$ |`\begin{vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{vmatrix}` |$\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}$ |`\begin{Vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Vmatrix}`
|
|
||||||
|$\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}$ |`\begin{Bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Bmatrix}`|$\def\arraystretch{1.5}\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}$|`\def\arraystretch{1.5}`<br> `\begin{array}{c:c:c}`<br> `a & b & c \\ \hline`<br> `d & e & f \\`<br> `\hdashline`<br> `g & h & i`<br>`\end{array}`
|
|
||||||
|$\begin{aligned} a&=b+c \\ d+e&=f \end{aligned}$ |`\begin{aligned}`<br> `a&=b+c \\`<br> `d+e&=f`<br>`\end{aligned}`|$\begin{alignedat}{2}10&x+&3&y=2\\3&x+&13&y=4\end{alignedat}$ |`\begin{alignedat}{2}`<br> `10&x+ &3&y = 2 \\`<br> ` 3&x+&13&y = 4`<br>`\end{alignedat}`
|
|
||||||
|$\begin{gathered} a=b \\ e=b+c \end{gathered}$ |`\begin{gathered}`<br> `a=b \\ `<br> `e=b+c`<br>`\end{gathered}`|$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$ |`x = \begin{cases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{cases}`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
KaTeX also supports `darray` and `dcases`.
|
|
||||||
|
|
||||||
Acceptable line separators include: `\\`, `\cr`, `\\[distance]`, and `\cr[distance]`. *Distance* can be written with any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
The `{array}` environment supports `|` and `:` vertical separators.
|
|
||||||
|
|
||||||
The `{array}` environment does not yet support `\cline` or `\multicolumn`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## HTML
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------|:-------------------|
|
|
||||||
| $\href{https://katex.org/}{\KaTeX}$ | `\href{https://katex.org/}{\KaTeX}` |
|
|
||||||
| $\url{https://katex.org/}$ | `\url{https://katex.org/}` |
|
|
||||||
|
|
||||||
## Letters and Unicode
|
|
||||||
|
|
||||||
**Greek Letters**
|
|
||||||
|
|
||||||
Direct Input: $Α Β Γ Δ Ε Ζ Η Θ Ι \allowbreak Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω$
|
|
||||||
$\allowbreak α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π \allowbreak ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ$
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|---------------|-------------|-------------|---------------|
|
|
||||||
| $\Alpha$ `\Alpha` | $\Beta$ `\Beta` | $\Gamma$ `\Gamma`| $\Delta$ `\Delta`
|
|
||||||
| $\Epsilon$ `\Epsilon` | $\Zeta$ `\Zeta` | $\Eta$ `\Eta` | $\Theta$ `\Theta`
|
|
||||||
| $\Iota$ `\Iota` | $\Kappa$ `\Kappa` | $\Lambda$ `\Lambda` | $\Mu$ `\Mu`
|
|
||||||
| $\Nu$ `\Nu` | $\Xi$ `\Xi` | $\Omicron$ `\Omicron` | $\Pi$ `\Pi`
|
|
||||||
| $\Sigma$ `\Sigma` | $\Tau$ `\Tau` | $\Upsilon$ `\Upsilon` | $\Phi$ `\Phi`
|
|
||||||
| $\Chi$ `\Chi` | $\Psi$ `\Psi`| $\Omega$ `\Omega`
|
|
||||||
| $\varGamma$ `\varGamma`| $\varDelta$ `\varDelta` | $\varTheta$ `\varTheta` | $\varLambda$ `\varLambda` |
|
|
||||||
| $\varXi$ `\varXi`| $\varPi$ `\varPi` | $\varSigma$ `\varSigma` | $\varUpsilon$ `\varUpsilon` |
|
|
||||||
| $\varPhi$ `\varPhi` | $\varPsi$ `\varPsi`| $\varOmega$ `\varOmega` ||
|
|
||||||
| $\alpha$ `\alpha`| $\beta$ `\beta` | $\gamma$ `\gamma` | $\delta$ `\delta`|
|
|
||||||
| $\epsilon$ `\epsilon` | $\zeta$ `\zeta` | $\eta$ `\eta`| $\theta$ `\theta`|
|
|
||||||
| $\iota$ `\iota` | $\kappa$ `\kappa` | $\lambda$ `\lambda`| $\mu$ `\mu`|
|
|
||||||
| $\nu$ `\nu`| $\xi$ `\xi` | $\omicron$ `\omicron` | $\pi$ `\pi`|
|
|
||||||
| $\rho$ `\rho` | $\sigma$ `\sigma` | $\tau$ `\tau`| $\upsilon$ `\upsilon` |
|
|
||||||
| $\phi$ `\phi` | $\chi$ `\chi`| $\psi$ `\psi`| $\omega$ `\omega`|
|
|
||||||
| $\varepsilon$ `\varepsilon` | $\varkappa$ `\varkappa` | $\vartheta$ `\vartheta` | $\thetasym$ `\thetasym`
|
|
||||||
| $\varpi$ `\varpi`| $\varrho$ `\varrho` | $\varsigma$ `\varsigma` | $\varphi$ `\varphi`
|
|
||||||
| $\digamma $ `\digamma`
|
|
||||||
|
|
||||||
**Other Letters**
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:----------|:----------|:----------|:----------|:----------|
|
|
||||||
|$\imath$ `\imath`|$\nabla$ `\nabla`|$\Im$ `\Im`|$\Reals$ `\Reals`|$\text{\OE}$ `\text{\OE}`
|
|
||||||
|$\jmath$ `\jmath`|$\partial$ `\partial`|$\image$ `\image`|$\wp$ `\wp`|$\text{\o}$ `\text{\o}`
|
|
||||||
|$\aleph$ `\aleph`|$\Game$ `\Game`|$\Bbbk$ `\Bbbk`|$\weierp$ `\weierp`|$\text{\O}$ `\text{\O}`
|
|
||||||
|$\alef$ `\alef`|$\Finv$ `\Finv`|$\N$ `\N`|$\Z$ `\Z`|$\text{\ss}$ `\text{\ss}`
|
|
||||||
|$\alefsym$ `\alefsym`|$\cnums$ `\cnums`|$\natnums$ `\natnums`|$\text{\aa}$ `\text{\aa}`|$\text{\i}$ `\text{\i}`
|
|
||||||
|$\beth$ `\beth`|$\Complex$ `\Complex`|$\R$ `\R`|$\text{\AA}$ `\text{\AA}`|$\text{\j}$ `\text{\j}`
|
|
||||||
|$\gimel$ `\gimel`|$\ell$ `\ell`|$\Re$ `\Re`|$\text{\ae}$ `\text{\ae}`
|
|
||||||
|$\daleth$ `\daleth`|$\hbar$ `\hbar`|$\real$ `\real`|$\text{\AE}$ `\text{\AE}`
|
|
||||||
|$\eth$ `\eth`|$\hslash$ `\hslash`|$\reals$ `\reals`|$\text{\oe}$ `\text{\oe}`
|
|
||||||
|
|
||||||
Direct Input: $∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð$
|
|
||||||
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåçèéêëìíîïðñòóôöùúûüýþÿ
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="math-alpha">
|
|
||||||
|
|
||||||
**Unicode Mathematical Alphanumeric Symbols**
|
|
||||||
|
|
||||||
| Item | Range | Item | Range |
|
|
||||||
|-------------|---------------------|-------------------|---------------|
|
|
||||||
| Bold | $\text{𝐀-𝐙 𝐚-𝐳 𝟎-𝟗}$ | Double-struck | $\text{𝔸-}ℤ\ 𝕜$
|
|
||||||
| Italic | $\text{𝐴-𝑍 𝑎-𝑧}$ | Sans serif | $\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}$
|
|
||||||
| Bold Italic | $\text{𝑨-𝒁 𝒂-𝒛}$ | Sans serif bold | $\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}$
|
|
||||||
| Script | $\text{𝒜-𝒵}$ | Sans serif italic | $\text{𝘈-𝘡 𝘢-𝘻}$
|
|
||||||
| Fractur | $\text{𝔄-}ℨ\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
**Unicode**
|
|
||||||
|
|
||||||
The letters listed above will render in any KaTeX rendering mode.
|
|
||||||
|
|
||||||
If the KaTeX rendering mode is set to `strict: false` or `strict:"warn"` (default), then KaTeX will accept all Unicode letters. The letters not listed above will be rendered from system fonts, not KaTeX-supplied fonts, so their typography may clash. They may also cause small vertical alignment issues. KaTeX has detailed metrics for glyphs in Latin, Greek, and Cyrillic, but other glyphs are treated as if they are each as tall as the letter M.
|
|
||||||
|
|
||||||
For Persian composite characters, a user-supplied [plug-in](https://github.com/HosseinAgha/persian-katex-plugin) is under development.
|
|
||||||
|
|
||||||
## Layout
|
|
||||||
|
|
||||||
### Annotation
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:------------------------------|:-----
|
|
||||||
|$\cancel{5}$ `\cancel{5}`|$\overbrace{a+b+c}^{\text{note}}$ `\overbrace{a+b+c}^{\text{note}}`
|
|
||||||
|$\bcancel{5}$ `\bcancel{5}` |$\underbrace{a+b+c}_{\text{note}}$ `\underbrace{a+b+c}_{\text{note}}`
|
|
||||||
|$\xcancel{ABC}$ `\xcancel{ABC}`|$\not =$ `\not =`
|
|
||||||
|$\sout{abc}$ `\sout{abc}`|$\boxed{\pi=\frac c d}$ `\boxed{\pi=\frac c d}`
|
|
||||||
|
|
||||||
`\tag{hi} x+y^{2x}`
|
|
||||||
$$\tag{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
`\tag*{hi} x+y^{2x}`
|
|
||||||
$$\tag*{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
### Line Breaks
|
|
||||||
|
|
||||||
KaTeX 0.10.0+ will insert automatic line breaks in inline math after relations or binary operators such as “=” or “+”. These can be suppressed by `\nobreak` or by placing math inside a pair of braces, as in `{F=ma}`. `\allowbreak` will allow automatic line breaks at locations other than relations or operators.
|
|
||||||
|
|
||||||
Hard line breaks are `\\` and `\newline`.
|
|
||||||
|
|
||||||
In display math, KaTeX does not insert automatic line breaks. It ignores display math hard line breaks when rendering option `strict: true`.
|
|
||||||
|
|
||||||
### Vertical Layout
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------|:----------------------------------------|:-----
|
|
||||||
|$x_n$ `x_n` |$\stackrel{!}{=}$ `\stackrel{!}{=}` |$a \atop b$ `a \atop b`
|
|
||||||
|$e^x$ `e^x` |$\overset{!}{=}$ `\overset{!}{=}` |$a\raisebox{0.25em}{b}c$ `a\raisebox{0.25em}{b}c`
|
|
||||||
|$_u^o $ `_u^o `|$\underset{!}{=}$ `\underset{!}{=}`
|
|
||||||
|
|
||||||
The second argument of `\raisebox` can contain math if it is nested within `$…$` delimiters, as in `\raisebox{0.25em}{$\frac a b$}`
|
|
||||||
|
|
||||||
### Overlap and Spacing
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------|:-------|
|
|
||||||
|${=}\mathllap{/\,}$ `{=}\mathllap{/\,}` | $\left(x^{\smash{2}}\right)$ `\left(x^{\smash{2}}\right)`
|
|
||||||
|$\mathrlap{\,/}{=}$ `\mathrlap{\,/}{=}` | $\sqrt{\smash[b]{y}}$ `\sqrt{\smash[b]{y}} `
|
|
||||||
|
|
||||||
$\displaystyle\sum_{\mathclap{1\le i\le j\le n}} x_{ij}$ `\sum_{\mathclap{1\le i\le j\le n}} x_{ij}`
|
|
||||||
|
|
||||||
KaTeX also supports `\llap`, `\rlap`, and `\clap`, but they will take only text, not math, as arguments.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="spacing-tbl">
|
|
||||||
|
|
||||||
**Spacing**
|
|
||||||
|
|
||||||
| Function | Produces | Function | Produces|
|
|
||||||
|:----------------|:-------------------|:---------------------|:--------------------------------------|
|
|
||||||
| `\,` | ³∕₁₈ em space | `\kern{distance}` | space, width = *distance*
|
|
||||||
| `\thinspace` | ³∕₁₈ em space | `\mkern{distance}` | space, width = *distance*
|
|
||||||
| `\:` | ⁴∕₁₈ em space | `\mskip{distance}` | space, width = *distance*
|
|
||||||
| `\medspace` | ⁴∕₁₈ em space | `\hskip{distance}` | space, width = *distance*
|
|
||||||
| `\;` | ⁵∕₁₈ em space | `\hspace{distance}` | space, width = *distance*
|
|
||||||
| `\thickspace` | ⁵∕₁₈ em space | `\hspace*{distance}` | space, width = *distance*
|
|
||||||
| `\enspace` | ½ em space | `\phantom{content}` | space the width and height of content
|
|
||||||
| `\quad` | 1 em space | `\hphantom{content}` | space the width of content
|
|
||||||
| `\qquad` | 2 em space | `\vphantom{content}` | a strut the height of content
|
|
||||||
| `~` | non-breaking space | `\!` | – ³∕₁₈ em space
|
|
||||||
| `\<space>` | space | `\negthinspace` | – ³∕₁₈ em space
|
|
||||||
| `\nobreakspace` | non-breaking space | `\negmedspace` | – ⁴∕₁₈ em space
|
|
||||||
| `\space` | space | `\negthickspace` | – ⁵∕₁₈ em space
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
**Notes:**
|
|
||||||
|
|
||||||
`distance` will accept any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
`\kern`, `\mkern`, `\mskip`, and `\hspace` accept unbraced distances, as in: `\kern1em`.
|
|
||||||
|
|
||||||
`\mkern` and `\mskip` will not work in text mode and both will write a console warning for any unit except `mu`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Logic and Set Theory
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:--------------------|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\forall$ `\forall` |$\complement$ `\complement`|$\therefore$ `\therefore` |$\emptyset$ `\emptyset`
|
|
||||||
|$\exists$ `\exists` |$\subset$ `\subset` |$\because$ `\because` |$\empty$ `\empty`
|
|
||||||
|$\exist$ `\exist` |$\supset$ `\supset` |$\mapsto$ `\mapsto` |$\varnothing$ `\varnothing`
|
|
||||||
|$\nexists$ `\nexists`|$\mid$ `\mid` |$\to$ `\to` |$\implies$ `\implies`
|
|
||||||
|$\in$ `\in` |$\land$ `\land` |$\gets$ `\gets` |$\impliedby$ `\impliedby`
|
|
||||||
|$\isin$ `\isin` |$\lor$ `\lor` |$\leftrightarrow$ `\leftrightarrow`|$\iff$ `\iff`
|
|
||||||
|$\notin$ `\notin` |$\ni$ `\ni` |$\notni$ `\notni` |$\neg$ `\neg` or `\lnot`
|
|
||||||
|
|
||||||
Direct Input: $∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬$ ℂ ℍ ℕ ℙ ℚ ℝ
|
|
||||||
|
|
||||||
## Macros
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------------------------------------|:------
|
|
||||||
|$\def\foo{x^2} \foo + \foo$ | `\def\foo{x^2} \foo + \foo`
|
|
||||||
|$\gdef\bar#1{#1^2} \bar{y} + \bar{y}$ | `\gdef\bar#1{#1^2} \bar{y} + \bar{y}`
|
|
||||||
| | `\global\def\macroname#1#2…{definition}`
|
|
||||||
| | `\newcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\renewcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\providecommand\macroname[numargs]{definition}`
|
|
||||||
|
|
||||||
Macros can also be defined in the KaTeX [rendering options](options.md).
|
|
||||||
|
|
||||||
Macros accept up to nine arguments: #1, #2, etc.
|
|
||||||
|
|
||||||
`\gdef` and `\global\def` macros will persist between math expressions.
|
|
||||||
|
|
||||||
Available functions include:
|
|
||||||
|
|
||||||
`\char` `\mathchoice` `\TextOrMath` `\@ifstar` `\@ifnextchar` `\@firstoftwo` `\@secondoftwo` `\relax`
|
|
||||||
|
|
||||||
@ is a valid character for commands, as if `\makeatletter` were in effect.
|
|
||||||
|
|
||||||
## Operators
|
|
||||||
|
|
||||||
### Big Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|------------------|-------------------------|--------------------------|--------------|
|
|
||||||
| $\sum$ `\sum` | $\prod$ `\prod` | $\bigotimes$ `\bigotimes`| $\bigvee$ `\bigvee`
|
|
||||||
| $\int$ `\int` | $\coprod$ `\coprod` | $\bigoplus$ `\bigoplus` | $\bigwedge$ `\bigwedge`
|
|
||||||
| $\iint$ `\iint` | $\intop$ `\intop` | $\bigodot$ `\bigodot` | $\bigcap$ `\bigcap`
|
|
||||||
| $\iiint$ `\iiint`| $\smallint$ `\smallint` | $\biguplus$ `\biguplus` | $\bigcup$ `\bigcup`
|
|
||||||
| $\oint$ `\oint` | $\oiint$ `\oiint` | $\oiiint$ `\oiiint` | $\bigsqcup$ `\bigsqcup`
|
|
||||||
|
|
||||||
Direct Input: $∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆$
|
|
||||||
|
|
||||||
### Binary Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-------------|-------------------|-------------------|--------------------|
|
|
||||||
| $+$ `+`| $\cdot$ `\cdot` | $\gtrdot$ `\gtrdot`| $x \pmod a$ `x \pmod a`|
|
|
||||||
| $-$ `-`| $\cdotp$ `\cdotp` | $\intercal$ `\intercal` | $x \pod a$ `x \pod a` |
|
|
||||||
| $/$ `/`| $\centerdot$ `\centerdot`| $\land$ `\land` | $\rhd$ `\rhd` |
|
|
||||||
| $*$ `*`| $\circ$ `\circ` | $\leftthreetimes$ `\leftthreetimes` | $\rightthreetimes$ `\rightthreetimes` |
|
|
||||||
| $\amalg$ `\amalg` | $\circledast$ `\circledast` | $\ldotp$ `\ldotp` | $\rtimes$ `\rtimes` |
|
|
||||||
| $\And$ `\And`| $\circledcirc$ `\circledcirc` | $\lor$ `\lor`| $\setminus$ `\setminus` |
|
|
||||||
| $\ast$ `\ast`| $\circleddash$ `\circleddash` | $\lessdot$ `\lessdot` | $\smallsetminus$ `\smallsetminus`|
|
|
||||||
| $\barwedge$ `\barwedge` | $\Cup$ `\Cup`| $\lhd$ `\lhd`| $\sqcap$ `\sqcap` |
|
|
||||||
| $\bigcirc$ `\bigcirc` | $\cup$ `\cup`| $\ltimes$ `\ltimes`| $\sqcup$ `\sqcup` |
|
|
||||||
| $\bmod$ `\bmod` | $\curlyvee$ `\curlyvee` | $x \mod a$ `x\mod a`| $\times$ `\times` |
|
|
||||||
| $\boxdot$ `\boxdot`| $\curlywedge$ `\curlywedge` | $\mp$ `\mp` | $\unlhd$ `\unlhd` |
|
|
||||||
| $\boxminus$ `\boxminus` | $\div$ `\div`| $\odot$ `\odot` | $\unrhd$ `\unrhd` |
|
|
||||||
| $\boxplus$ `\boxplus` | $\divideontimes$ `\divideontimes` | $\ominus$ `\ominus`| $\uplus$ `\uplus` |
|
|
||||||
| $\boxtimes$ `\boxtimes` | $\dotplus$ `\dotplus` | $\oplus$ `\oplus` | $\vee$ `\vee` |
|
|
||||||
| $\bullet$ `\bullet`| $\doublebarwedge$ `\doublebarwedge` | $\otimes$ `\otimes`| $\veebar$ `\veebar` |
|
|
||||||
| $\Cap$ `\Cap`| $\doublecap$ `\doublecap`| $\oslash$ `\oslash`| $\wedge$ `\wedge` |
|
|
||||||
| $\cap$ `\cap`| $\doublecup$ `\doublecup`| $\pm$ `\pm` or `\plusmn` | $\wr$ `\wr` |
|
|
||||||
|
|
||||||
Direct Input: $+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝$
|
|
||||||
|
|
||||||
### Fractions and Binomials
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\frac{a}{b}$ `\frac{a}{b}`|$\tfrac{a}{b}$ `\tfrac{a}{b}`|$\genfrac ( ] {2pt}{1}a{a+1}$ `\genfrac ( ] {2pt}{1}a{a+1}`
|
|
||||||
|${a \over b}$ `{a \over b}`|$\dfrac{a}{b}$ `\dfrac{a}{b}`|${a \above{2pt} b+1}$ `{a \above{2pt} b+1}`
|
|
||||||
|$a/b$ `a/b` | |$\cfrac{a}{1 + \cfrac{1}{b}}$ `\cfrac{a}{1 + \cfrac{1}{b}}`
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:--------
|
|
||||||
|$\binom{n}{k}$ `\binom{n}{k}` |$\dbinom{n}{k}$ `\dbinom{n}{k}`|${n\brace k}$ `{n\brace k}`
|
|
||||||
|${n \choose k}$ `{n \choose k}`|$\tbinom{n}{k}$ `\tbinom{n}{k}`|${n\brack k}$ `{n\brack k}`
|
|
||||||
|
|
||||||
### Math Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-----------|---------|-----------------|-----------|
|
|
||||||
| $\arcsin$ `\arcsin` | $\cotg$ `\cotg` | $\ln$ `\ln` | $\det$ `\det` |
|
|
||||||
| $\arccos$ `\arccos` | $\coth$ `\coth` | $\log$ `\log` | $\gcd$ `\gcd` |
|
|
||||||
| $\arctan$ `\arctan` | $\csc$ `\csc` | $\sec$ `\sec` | $\inf$ `\inf` |
|
|
||||||
| $\arctg$ `\arctg` | $\ctg$ `\ctg` | $\sin$ `\sin` | $\lim$ `\lim` |
|
|
||||||
| $\arcctg$ `\arcctg` | $\cth$ `\cth` | $\sinh$ `\sinh`| $\liminf$ `\liminf` |
|
|
||||||
| $\arg$ `\arg` | $\deg$ `\deg` | $\sh$ `\sh` | $\limsup$ `\limsup` |
|
|
||||||
| $\ch$ `\ch` | $\dim$ `\dim` | $\tan$ `\tan` | $\max$ `\max` |
|
|
||||||
| $\cos$ `\cos` | $\exp$ `\exp` | $\tanh$ `\tanh`| $\min$ `\min` |
|
|
||||||
| $\cosec$ `\cosec` | $\hom$ `\hom` | $\tg$ `\tg` | $\Pr$ `\Pr` |
|
|
||||||
| $\cosh$ `\cosh`| $\ker$ `\ker` | $\th$ `\th` | $\sup$ `\sup` |
|
|
||||||
| $\cot$ `\cot` | $\lg$ `\lg`| $\operatorname{f}$ `\operatorname{f}` |
|
|
||||||
|
|
||||||
Functions on the right column of this table can take `\limits`.
|
|
||||||
|
|
||||||
### \sqrt
|
|
||||||
|
|
||||||
$\sqrt{x}$ `\sqrt{x}`
|
|
||||||
|
|
||||||
$\sqrt[3]{x}$ `\sqrt[3]{x}`
|
|
||||||
|
|
||||||
## Relations
|
|
||||||
|
|
||||||
$\stackrel{!}{=}$ `\stackrel{!}{=}`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:----------------------------|:--------------------------------|:--------------------------------|:-----
|
|
||||||
|$=$ `=` |$\eqcirc$ `\eqcirc` |$\lesseqgtr$ `\lesseqgtr` |$\sqsupset$ `\sqsupset`
|
|
||||||
|$<$ `<` |$\eqcolon$ `\eqcolon`|$\lesseqqgtr$ `\lesseqqgtr`|$\sqsupseteq$ `\sqsupseteq`
|
|
||||||
|$>$ `>` |$\Eqcolon$ `\Eqcolon`|$\lessgtr$ `\lessgtr`|$\Subset$ `\Subset`
|
|
||||||
|$:$ `:` |$\eqqcolon$ `\eqqcolon` |$\lesssim$ `\lesssim`|$\subset$ `\subset` or `\sub`
|
|
||||||
|$\approx$ `\approx` |$\Eqqcolon$ `\Eqqcolon` |$\ll$ `\ll` |$\subseteq$ `\subseteq` or `\sube`
|
|
||||||
|$\approxeq$ `\approxeq`|$\eqsim$ `\eqsim` |$\lll$ `\lll` |$\subseteqq$ `\subseteqq`
|
|
||||||
|$\asymp$ `\asymp`|$\eqslantgtr$ `\eqslantgtr`|$\llless$ `\llless` |$\succ$ `\succ`
|
|
||||||
|$\backepsilon$ `\backepsilon`|$\eqslantless$ `\eqslantless` |$\lt$ `\lt` |$\succapprox$ `\succapprox`
|
|
||||||
|$\backsim$ `\backsim` |$\equiv$ `\equiv` |$\mid$ `\mid` |$\succcurlyeq$ `\succcurlyeq`
|
|
||||||
|$\backsimeq$ `\backsimeq` |$\fallingdotseq$ `\fallingdotseq`|$\models$ `\models` |$\succeq$ `\succeq`
|
|
||||||
|$\between$ `\between` |$\frown$ `\frown` |$\multimap$ `\multimap` |$\succsim$ `\succsim`
|
|
||||||
|$\bowtie$ `\bowtie` |$\ge$ `\ge` |$\owns$ `\owns`|$\Supset$ `\Supset`
|
|
||||||
|$\bumpeq$ `\bumpeq` |$\geq$ `\geq` |$\parallel$ `\parallel` |$\supset$ `\supset`
|
|
||||||
|$\Bumpeq$ `\Bumpeq` |$\geqq$ `\geqq`|$\perp$ `\perp`|$\supseteq$ `\supseteq` or `\supe`
|
|
||||||
|$\circeq$ `\circeq` |$\geqslant$ `\geqslant` |$\pitchfork$ `\pitchfork` |$\supseteqq$ `\supseteqq`
|
|
||||||
|$\colonapprox$ `\colonapprox`|$\gg$ `\gg` |$\prec$ `\prec`|$\thickapprox$ `\thickapprox`
|
|
||||||
|$\Colonapprox$ `\Colonapprox`|$\ggg$ `\ggg` |$\precapprox$ `\precapprox`|$\thicksim$ `\thicksim`
|
|
||||||
|$\coloneq$ `\coloneq` |$\gggtr$ `\gggtr` |$\preccurlyeq$ `\preccurlyeq` |$\trianglelefteq$ `\trianglelefteq`
|
|
||||||
|$\Coloneq$ `\Coloneq` |$\gt$ `\gt` |$\preceq$ `\preceq` |$\triangleq$ `\triangleq`
|
|
||||||
|$\coloneqq$ `\coloneqq`|$\gtrapprox$ `\gtrapprox` |$\precsim$ `\precsim`|$\trianglerighteq$ `\trianglerighteq`
|
|
||||||
|$\Coloneqq$ `\Coloneqq`|$\gtreqless$ `\gtreqless` |$\propto$ `\propto` |$\varpropto$ `\varpropto`
|
|
||||||
|$\colonsim$ `\colonsim`|$\gtreqqless$ `\gtreqqless`|$\risingdotseq$ `\risingdotseq` |$\vartriangle$ `\vartriangle`
|
|
||||||
|$\Colonsim$ `\Colonsim`|$\gtrless$ `\gtrless`|$\shortmid$ `\shortmid` |$\vartriangleleft$ `\vartriangleleft`
|
|
||||||
|$\cong$ `\cong` |$\gtrsim$ `\gtrsim` |$\shortparallel$ `\shortparallel`|$\vartriangleright$ `\vartriangleright`
|
|
||||||
|$\curlyeqprec$ `\curlyeqprec`|$\in$ `\in` or `\isin` |$\sim$ `\sim` |$\vcentcolon$ `\vcentcolon`
|
|
||||||
|$\curlyeqsucc$ `\curlyeqsucc`|$\Join$ `\Join`|$\simeq$ `\simeq` |$\vdash$ `\vdash`
|
|
||||||
|$\dashv$ `\dashv`|$\le$ `\le` |$\smallfrown$ `\smallfrown`|$\vDash$ `\vDash`
|
|
||||||
|$\dblcolon$ `\dblcolon`|$\leq$ `\leq` |$\smallsmile$ `\smallsmile`|$\Vdash$ `\Vdash`
|
|
||||||
|$\doteq$ `\doteq`|$\leqq$ `\leqq`|$\smile$ `\smile` |$\Vvdash$ `\Vvdash`
|
|
||||||
|$\Doteq$ `\Doteq`|$\leqslant$ `\leqslant` |$\sqsubset$ `\sqsubset` |
|
|
||||||
|$\doteqdot$ `\doteqdot`|$\lessapprox$ `\lessapprox`|$\sqsubseteq$ `\sqsubseteq`|
|
|
||||||
|
|
||||||
|
|
||||||
Direct Input: $= < > : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⟂ ⊨$ `≔ ≕ ⩴`
|
|
||||||
|
|
||||||
### Negated Relations
|
|
||||||
|
|
||||||
$\not =$ `\not =`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|--------------|-------------------|---------------------|------------------|
|
|
||||||
| $\gnapprox$ `\gnapprox` | $\ngeqslant$ `\ngeqslant`| $\nsubseteq$ `\nsubseteq` | $\precneqq$ `\precneqq`|
|
|
||||||
| $\gneq$ `\gneq`| $\ngtr$ `\ngtr` | $\nsubseteqq$ `\nsubseteqq` | $\precnsim$ `\precnsim`|
|
|
||||||
| $\gneqq$ `\gneqq` | $\nleq$ `\nleq` | $\nsucc$ `\nsucc`| $\subsetneq$ `\subsetneq` |
|
|
||||||
| $\gnsim$ `\gnsim` | $\nleqq$ `\nleqq` | $\nsucceq$ `\nsucceq` | $\subsetneqq$ `\subsetneqq` |
|
|
||||||
| $\gvertneqq$ `\gvertneqq` | $\nleqslant$ `\nleqslant`| $\nsupseteq$ `\nsupseteq` | $\succnapprox$ `\succnapprox`|
|
|
||||||
| $\lnapprox$ `\lnapprox` | $\nless$ `\nless` | $\nsupseteqq$ `\nsupseteqq` | $\succneqq$ `\succneqq`|
|
|
||||||
| $\lneq$ `\lneq`| $\nmid$ `\nmid` | $\ntriangleleft$ `\ntriangleleft` | $\succnsim$ `\succnsim`|
|
|
||||||
| $\lneqq$ `\lneqq` | $\notin$ `\notin` | $\ntrianglelefteq$ `\ntrianglelefteq` | $\supsetneq$ `\supsetneq` |
|
|
||||||
| $\lnsim$ `\lnsim` | $\notni$ `\notni` | $\ntriangleright$ `\ntriangleright`| $\supsetneqq$ `\supsetneqq` |
|
|
||||||
| $\lvertneqq$ `\lvertneqq` | $\nparallel$ `\nparallel`| $\ntrianglerighteq$ `\ntrianglerighteq` | $\varsubsetneq$ `\varsubsetneq` |
|
|
||||||
| $\ncong$ `\ncong` | $\nprec$ `\nprec` | $\nvdash$ `\nvdash` | $\varsubsetneqq$ `\varsubsetneqq` |
|
|
||||||
| $\ne$ `\ne` | $\npreceq$ `\npreceq` | $\nvDash$ `\nvDash` | $\varsupsetneq$ `\varsupsetneq` |
|
|
||||||
| $\neq$ `\neq` | $\nshortmid$ `\nshortmid`| $\nVDash$ `\nVDash` | $\varsupsetneqq$ `\varsupsetneqq` |
|
|
||||||
| $\ngeq$ `\ngeq`| $\nshortparallel$ `\nshortparallel` | $\nVdash$ `\nVdash` |
|
|
||||||
| $\ngeqq$ `\ngeqq` | $\nsim$ `\nsim` | $\precnapprox$ `\precnapprox`|
|
|
||||||
|
|
||||||
Direct Input: $∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌$
|
|
||||||
|
|
||||||
### Arrows
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|$\circlearrowleft$ `\circlearrowleft`|$\leftharpoonup$ `\leftharpoonup`|$\rArr$ `\rArr`
|
|
||||||
|$\circlearrowright$ `\circlearrowright`|$\leftleftarrows$ `\leftleftarrows`|$\rarr$ `\rarr`
|
|
||||||
|$\curvearrowleft$ `\curvearrowleft`|$\leftrightarrow$ `\leftrightarrow`|$\restriction$ `\restriction`
|
|
||||||
|$\curvearrowright$ `\curvearrowright`|$\Leftrightarrow$ `\Leftrightarrow`|$\rightarrow$ `\rightarrow`
|
|
||||||
|$\Darr$ `\Darr`|$\leftrightarrows$ `\leftrightarrows`|$\Rightarrow$ `\Rightarrow`
|
|
||||||
|$\dArr$ `\dArr`|$\leftrightharpoons$ `\leftrightharpoons`|$\rightarrowtail$ `\rightarrowtail`
|
|
||||||
|$\darr$ `\darr`|$\leftrightsquigarrow$ `\leftrightsquigarrow`|$\rightharpoondown$ `\rightharpoondown`
|
|
||||||
|$\dashleftarrow$ `\dashleftarrow`|$\Lleftarrow$ `\Lleftarrow`|$\rightharpoonup$ `\rightharpoonup`
|
|
||||||
|$\dashrightarrow$ `\dashrightarrow`|$\longleftarrow$ `\longleftarrow`|$\rightleftarrows$ `\rightleftarrows`
|
|
||||||
|$\downarrow$ `\downarrow`|$\Longleftarrow$ `\Longleftarrow`|$\rightleftharpoons$ `\rightleftharpoons`
|
|
||||||
|$\Downarrow$ `\Downarrow`|$\longleftrightarrow$ `\longleftrightarrow`|$\rightrightarrows$ `\rightrightarrows`
|
|
||||||
|$\downdownarrows$ `\downdownarrows`|$\Longleftrightarrow$ `\Longleftrightarrow`|$\rightsquigarrow$ `\rightsquigarrow`
|
|
||||||
|$\downharpoonleft$ `\downharpoonleft`|$\longmapsto$ `\longmapsto`|$\Rrightarrow$ `\Rrightarrow`
|
|
||||||
|$\downharpoonright$ `\downharpoonright`|$\longrightarrow$ `\longrightarrow`|$\Rsh$ `\Rsh`
|
|
||||||
|$\gets$ `\gets`|$\Longrightarrow$ `\Longrightarrow`|$\searrow$ `\searrow`
|
|
||||||
|$\Harr$ `\Harr`|$\looparrowleft$ `\looparrowleft`|$\swarrow$ `\swarrow`
|
|
||||||
|$\hArr$ `\hArr`|$\looparrowright$ `\looparrowright`|$\to$ `\to`
|
|
||||||
|$\harr$ `\harr`|$\Lrarr$ `\Lrarr`|$\twoheadleftarrow$ `\twoheadleftarrow`
|
|
||||||
|$\hookleftarrow$ `\hookleftarrow`|$\lrArr$ `\lrArr`|$\twoheadrightarrow$ `\twoheadrightarrow`
|
|
||||||
|$\hookrightarrow$ `\hookrightarrow`|$\lrarr$ `\lrarr`|$\Uarr$ `\Uarr`
|
|
||||||
|$\iff$ `\iff`|$\Lsh$ `\Lsh`|$\uArr$ `\uArr`
|
|
||||||
|$\impliedby$ `\impliedby`|$\mapsto$ `\mapsto`|$\uarr$ `\uarr`
|
|
||||||
|$\implies$ `\implies`|$\nearrow$ `\nearrow`|$\uparrow$ `\uparrow`
|
|
||||||
|$\Larr$ `\Larr`|$\nleftarrow$ `\nleftarrow`|$\Uparrow$ `\Uparrow`
|
|
||||||
|$\lArr$ `\lArr`|$\nLeftarrow$ `\nLeftarrow`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$\larr$ `\larr`|$\nleftrightarrow$ `\nleftrightarrow`|$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\leadsto$ `\leadsto`|$\nLeftrightarrow$ `\nLeftrightarrow`|$\upharpoonleft$ `\upharpoonleft`
|
|
||||||
|$\leftarrow$ `\leftarrow`|$\nrightarrow$ `\nrightarrow`|$\upharpoonright$ `\upharpoonright`
|
|
||||||
|$\Leftarrow$ `\Leftarrow`|$\nRightarrow$ `\nRightarrow`|$\upuparrows$ `\upuparrows`
|
|
||||||
|$\leftarrowtail$ `\leftarrowtail`|$\nwarrow$ `\nwarrow`
|
|
||||||
|$\leftharpoondown$ `\leftharpoondown`|$\Rarr$ `\Rarr`
|
|
||||||
|
|
||||||
Direct Input: $← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼$ ↽
|
|
||||||
|
|
||||||
**Extensible Arrows**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------------------------------------|:-----
|
|
||||||
|$\xleftarrow{abc}$ `\xleftarrow{abc}` |$\xrightarrow[under]{over}$ `\xrightarrow[under]{over}`
|
|
||||||
|$\xLeftarrow{abc}$ `\xLeftarrow{abc}` |$\xRightarrow{abc}$ `\xRightarrow{abc}`
|
|
||||||
|$\xleftrightarrow{abc}$ `\xleftrightarrow{abc}` |$\xLeftrightarrow{abc}$ `\xLeftrightarrow{abc}`
|
|
||||||
|$\xhookleftarrow{abc}$ `\xhookleftarrow{abc}` |$\xhookrightarrow{abc}$ `\xhookrightarrow{abc}`
|
|
||||||
|$\xtwoheadleftarrow{abc}$ `\xtwoheadleftarrow{abc}` |$\xtwoheadrightarrow{abc}$ `\xtwoheadrightarrow{abc}`
|
|
||||||
|$\xleftharpoonup{abc}$ `\xleftharpoonup{abc}` |$\xrightharpoonup{abc}$ `\xrightharpoonup{abc}`
|
|
||||||
|$\xleftharpoondown{abc}$ `\xleftharpoondown{abc}` |$\xrightharpoondown{abc}$ `\xrightharpoondown{abc}`
|
|
||||||
|$\xleftrightharpoons{abc}$ `\xleftrightharpoons{abc}`|$\xrightleftharpoons{abc}$ `\xrightleftharpoons{abc}`
|
|
||||||
|$\xtofrom{abc}$ `\xtofrom{abc}` |$\xmapsto{abc}$ `\xmapsto{abc}`
|
|
||||||
|$\xlongequal{abc}$ `\xlongequal{abc}`
|
|
||||||
|
|
||||||
Extensible arrows all can take an optional argument in the same manner<br>as `\xrightarrow[under]{over}`.
|
|
||||||
|
|
||||||
## Style, Color, Size, and Font
|
|
||||||
|
|
||||||
**Class Assignment**
|
|
||||||
|
|
||||||
`\mathbin` `\mathclose` `\mathinner` `\mathop`<br>
|
|
||||||
`\mathopen` `\mathord` `\mathpunct` `\mathrel`
|
|
||||||
|
|
||||||
**Color**
|
|
||||||
|
|
||||||
$\color{blue} F=ma$ `\color{blue} F=ma`
|
|
||||||
|
|
||||||
Note that KaTeX `\color` acts like a switch. This aligns with LaTeX and differs from MathJax.
|
|
||||||
Other KaTeX color functions expect the content to be a function argument:
|
|
||||||
|
|
||||||
$\textcolor{blue}{F=ma}$ `\textcolor{blue}{F=ma}`<br>
|
|
||||||
$\textcolor{#228B22}{F=ma}$ `\textcolor{#228B22}{F=ma}`<br>
|
|
||||||
$\colorbox{aqua}{A}$ `\colorbox{aqua}{A}`<br>
|
|
||||||
$\fcolorbox{red}{aqua}{A}$ `\fcolorbox{red}{aqua}{A}`
|
|
||||||
|
|
||||||
For color definition, KaTeX color functions will accept the standard HTML [predefined color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords). They will also accept an RGB argument in CSS hexadecimal style. The "#" is optional before a six-digit specification.
|
|
||||||
|
|
||||||
**Font**
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:-----
|
|
||||||
|$\mathrm{Ab0}$ `\mathrm{Ab0}` |$\mathbf{Ab0}$ `\mathbf{Ab0}` |$\mathit{Ab}$ `\mathit{Ab}`
|
|
||||||
|$\mathnormal{Ab0}$ `\mathnormal{Ab0}`|$\textbf{Ab0}$ `\textbf{Ab0}` |$\textit{Ab}$ `\textit{Ab}`
|
|
||||||
|$\textrm{Ab0}$ `\textrm{Ab0}` |$\bf Ab0$ `\bf Ab0` |$\it Ab$ `\it Ab`
|
|
||||||
|$\rm Ab0$ `\rm Ab0` |$\bold{Ab0}$ `\bold{Ab0}`|$\Bbb{AB}$ `\Bbb{AB}`
|
|
||||||
|$\textnormal{Ab0}$ `\textnormal{Ab0}`|$\boldsymbol{Ab}$ `\boldsymbol{Ab}`|$\mathbb{AB}$ `\mathbb{AB}`
|
|
||||||
|$\text{Ab0}$ `\text{Ab0}` |$\bm{Ab}$ `\bm{Ab}` |$\frak{Ab0}$ `\frak{Ab0}`
|
|
||||||
|$\mathsf{Ab0}$ `\mathsf{Ab0}` |$\mathtt{Ab0}$ `\mathtt{Ab0}` |$\mathfrak{Ab0}$ `\mathfrak{Ab0}`
|
|
||||||
|$\textsf{Ab0}$ `\textsf{Ab0}` |$\texttt{Ab0}$ `\texttt{Ab0}` |$\mathcal{AB0}$ `\mathcal{AB0}`
|
|
||||||
|$\sf Ab0$ `\sf Ab0` |$\tt Ab0$ `\tt Ab0` |$\mathscr{AB}$ `\mathscr{AB}`
|
|
||||||
|
|
||||||
One can stack font family, font weight, and font shape by using the `\textXX` versions of the font functions. So `\textsf{\textbf{H}}` will produce $\textsf{\textbf{H}}$. The other versions do not stack, e.g., `\mathsf{\mathbf{H}}` will produce $\mathsf{\mathbf{H}}$.
|
|
||||||
|
|
||||||
In cases where KaTeX fonts do not have a bold glyph, `\pmb` can simulate one. For example, `\pmb{\mu}` renders as : $\pmb{\mu}$
|
|
||||||
|
|
||||||
**Size**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------|:-----
|
|
||||||
|$\Huge AB$ `\Huge AB` |$\normalsize AB$ `\normalsize AB`
|
|
||||||
|$\huge AB$ `\huge AB` |$\small AB$ `\small AB`
|
|
||||||
|$\LARGE AB$ `\LARGE AB`|$\footnotesize AB$ `\footnotesize AB`
|
|
||||||
|$\Large AB$ `\Large AB`|$\scriptsize AB$ `\scriptsize AB`
|
|
||||||
|$\large AB$ `\large AB`|$\tiny AB$ `\tiny AB`
|
|
||||||
|
|
||||||
|
|
||||||
**Style**
|
|
||||||
|
|
||||||
||
|
|
||||||
|:-------------------------------------------------------|
|
|
||||||
|$\displaystyle\sum_{i=1}^n$ `\displaystyle\sum_{i=1}^n`
|
|
||||||
|$\textstyle\sum_{i=1}^n$ `\textstyle\sum_{i=1}^n`
|
|
||||||
|$\scriptstyle x$ `\scriptstyle x` (The size of a first sub/superscript)
|
|
||||||
|$\scriptscriptstyle x$ `\scriptscriptstyle x` (The size of subsequent sub/superscripts)
|
|
||||||
|$\lim\limits_x$ `\lim\limits_x`
|
|
||||||
|$\lim\nolimits_x$ `\lim\nolimits_x`
|
|
||||||
|$\verb!x^2!$ `\verb!x^2!`
|
|
||||||
|
|
||||||
`\text{…}` will accept nested `$…$` fragments and render them in math mode.
|
|
||||||
|
|
||||||
## Symbols and Punctuation
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|`% comment`|$\dots$ `\dots`|$\KaTeX$ `\KaTeX`
|
|
||||||
|$\%$ `\%`|$\cdots$ `\cdots`|$\LaTeX$ `\LaTeX`
|
|
||||||
|$\#$ `\#`|$\ddots$ `\ddots`|$\TeX$ `\TeX`
|
|
||||||
|$\&$ `\&`|$\ldots$ `\ldots`|$\nabla$ `\nabla`
|
|
||||||
|$\_$ `\_`|$\vdots$ `\vdots`|$\infty$ `\infty`
|
|
||||||
|$\text{\textunderscore}$ `\text{\textunderscore}`|$\dotsb$ `\dotsb`|$\infin$ `\infin`
|
|
||||||
|$\text{--}$ `\text{--}`|$\dotsc$ `\dotsc`|$\checkmark$ `\checkmark`
|
|
||||||
|$\text{\textendash}$ `\text{\textendash}`|$\dotsi$ `\dotsi`|$\dag$ `\dag`
|
|
||||||
|$\text{---}$ `\text{---}`|$\dotsm$ `\dotsm`|$\dagger$ `\dagger`
|
|
||||||
|$\text{\textemdash}$ `\text{\textemdash}`|$\dotso$ `\dotso`|$\text{\textdagger}$ `\text{\textdagger}`
|
|
||||||
|$\text{\textasciitilde}$ `\text{\textasciitilde}`|$\sdot$ `\sdot`|$\ddag$ `\ddag`
|
|
||||||
|$`$ <code>`</code>|$\mathellipsis$ `\mathellipsis`|$\ddagger$ `\ddagger`
|
|
||||||
|$\text{\textquoteleft}$ `text{\textquoteleft}`|$\text{\textellipsis}$ `\text{\textellipsis}`|$\text{\textdaggerdbl}$ `\text{\textdaggerdbl}`
|
|
||||||
|$\lq$ `\lq`|$\Box$ `\Box`|$\Dagger$ `\Dagger`
|
|
||||||
|$\text{\textquoteright}$ `\text{\textquoteright}`|$\square$ `\square`|$\angle$ `\angle`
|
|
||||||
|$\rq$ `\rq`|$\blacksquare$ `\blacksquare`|$\measuredangle$ `\measuredangle`
|
|
||||||
|$\text{\textquotedblleft}$ `\text{\textquotedblleft}`|$\triangle$ `\triangle`|$\sphericalangle$ `\sphericalangle`
|
|
||||||
|$"$ `"`|$\triangledown$ `\triangledown`|$\top$ `\top`
|
|
||||||
|$\text{\textquotedblright}$ `\text{\textquotedblright}`|$\triangleleft$ `\triangleleft`|$\bot$ `\bot`
|
|
||||||
|$\colon$ `\colon`|$\triangleright$ `\triangleright`|$\$$ `\$`
|
|
||||||
|$\backprime$ `\backprime`|$\bigtriangledown$ `\bigtriangledown`|$\text{\textdollar}$ `\text{\textdollar}`
|
|
||||||
|$\prime$ `\prime`|$\bigtriangleup$ `\bigtriangleup`|$\pounds$ `\pounds`
|
|
||||||
|$\text{\textless}$ `\text{\textless}`|$\blacktriangle$ `\blacktriangle`|$\mathsterling$ `\mathsterling`
|
|
||||||
|$\text{\textgreater}$ `\text{\textgreater}`|$\blacktriangledown$ `\blacktriangledown`|$\text{\textsterling}$ `\text{\textsterling}`
|
|
||||||
|$\text{\textbar}$ `\text{\textbar}`|$\blacktriangleleft$ `\blacktriangleleft`|$\yen$ `\yen`
|
|
||||||
|$\text{\textbardbl}$ `\text{\textbardbl}`|$\blacktriangleright$ `\blacktriangleright`|$\surd$ `\surd`
|
|
||||||
|$\text{\textbraceleft}$ `\text{\textbraceleft}`|$\diamond$ `\diamond`|$\degree$ `\degree`
|
|
||||||
|$\text{\textbraceright}$ `\text{\textbraceright}`|$\Diamond$ `\Diamond`|$\text{\textdegree}$ `\text{\textdegree}`
|
|
||||||
|$\text{\P}$ `\text{\P}`|$\lozenge$ `\lozenge`|$\mho$ `\mho`
|
|
||||||
|$\text{\S}$ `\text{\S}`|$\blacklozenge$ `\blacklozenge`|$\diagdown$ `\diagdown`
|
|
||||||
|$\text{\sect}$ `\text{\sect}`|$\star$ `\star`|$\diagup$ `\diagup`
|
|
||||||
|$\copyright$ `\copyright`|$\bigstar$ `\bigstar`|$\flat$ `\flat`
|
|
||||||
|$\circledR$ `\circledR`|$\clubsuit$ `\clubsuit`|$\natural$ `\natural`
|
|
||||||
|$\text{\textregistered}$ `\text{\textregistered}`|$\clubs$ `\clubs`|$\sharp$ `\sharp`
|
|
||||||
|$\circledS$ `\circledS`|$\diamondsuit$ `\diamondsuit`|$\heartsuit$ `\heartsuit`
|
|
||||||
|$\text{\textcircled a}$ `\text{\textcircled a}`|$\diamonds$ `\diamonds`|$\hearts$ `\hearts`
|
|
||||||
|$\maltese$ `\maltese`|$\spadesuit$ `\spadesuit`|$\spades$ `\spades`
|
|
||||||
|
|
||||||
Direct Input: $£ ¥ ∇ ∞ · ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ … ⋮ ⋯ ⋱ !$ ‼
|
|
||||||
|
|
||||||
## Units
|
|
||||||
|
|
||||||
In KaTeX, units are proportioned as they are in TeX.<br>
|
|
||||||
KaTeX units are different than CSS units.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="unit-tbl">
|
|
||||||
|
|
||||||
| KaTeX Unit | Value | KaTeX Unit | Value |
|
|
||||||
|:---|:---------------------|:---|:----------------|
|
|
||||||
| em | CSS em | bp | 1/72 inch × F × G|
|
|
||||||
| ex | CSS ex | pc | 12 KaTeX pt|
|
|
||||||
| mu | 1/18 CSS em | dd | 1238/1157 KaTeX pt |
|
|
||||||
| pt | 1/72.27 inch × F × G | cc | 14856/1157 KaTeX pt |
|
|
||||||
| mm | 1 mm × F × G | nd | 685/642 KaTeX pt |
|
|
||||||
| cm | 1 cm × F × G | nc | 1370/107 KaTeX pt|
|
|
||||||
| in | 1 inch × F × G | sp | 1/65536 KaTeX pt |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
where:
|
|
||||||
|
|
||||||
<div style="margin-left: 1.5em;">
|
|
||||||
|
|
||||||
F = (font size of surrounding HTML text)/(10 pt)
|
|
||||||
|
|
||||||
G = 1.21 by default, because KaTeX font-size is normally 1.21 × the surrounding font size. This value [can be overridden](font.md#font-size-and-lengths) by the CSS of an HTML page.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
The effect of style and size:
|
|
||||||
|
|
||||||
<div class="katex-cards" id="unit-blocks">
|
|
||||||
|
|
||||||
| Unit | textstyle | scriptscript | huge |
|
|
||||||
|:------:|:-----------------:|:------------:|:------:|
|
|
||||||
|em or ex|$\rule{1em}{1em}$ |$\scriptscriptstyle\rule{1em}{1em}$ |$\huge\rule{1em}{1em}$
|
|
||||||
| mu |$\rule{18mu}{18mu}$|$\scriptscriptstyle\rule{18mu}{18mu}$|$\huge\rule{18mu}{18mu}$
|
|
||||||
| others |$\rule{10pt}{10pt}$|$\scriptscriptstyle\rule{10pt}{10pt}$|$\huge\rule{10pt}{10pt}$
|
|
||||||
|
|
||||||
</div>
|
|
@@ -1,110 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.1-autorender
|
|
||||||
title: Auto-render Extension
|
|
||||||
original_id: autorender
|
|
||||||
---
|
|
||||||
This is an extension to automatically render all of the math inside of text. It
|
|
||||||
searches all of the text nodes within a given element for the given delimiters,
|
|
||||||
ignoring certain tags like `<pre>`, and renders the math in place.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
This extension isn't part of KaTeX proper, so the script needs to be included
|
|
||||||
(via a `<script>` tag) in the page along with KaTeX itself. For example,
|
|
||||||
using a CDN:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above, the [`defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
indicates that the script doesn't need to execute until the page has loaded,
|
|
||||||
speeding up page rendering; and the `onload` attribute calls
|
|
||||||
`renderMathInElement` once the auto-render script loads.
|
|
||||||
|
|
||||||
Alternatively, you can call the `renderMathInElement` when (or after) the
|
|
||||||
[`DOMContentLoaded` event](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded)
|
|
||||||
fires on the document or in another deferred script.
|
|
||||||
This approach is useful for specifying or computing options, or if you don't
|
|
||||||
want to use a `defer` or `onload` attribute.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
renderMathInElement(document.body, {
|
|
||||||
// ...options...
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
ECMAScript module is also available:
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous">
|
|
||||||
<script type="module">
|
|
||||||
import renderMathInElement from "https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.mjs";
|
|
||||||
renderMathInElement(document.body);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
> You can use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules. -->
|
|
||||||
|
|
||||||
## API
|
|
||||||
This extension exposes a single function, `window.renderMathInElement`, with
|
|
||||||
the following API:
|
|
||||||
|
|
||||||
```js
|
|
||||||
function renderMathInElement(elem, options)
|
|
||||||
```
|
|
||||||
|
|
||||||
`elem` is an HTML DOM element. The function will recursively search for text
|
|
||||||
nodes inside this element and render the math in them.
|
|
||||||
|
|
||||||
`options` is an optional object argument that can have the same keys as [the
|
|
||||||
object passed to `katex.render`](https://github.com/KaTeX/KaTeX/#rendering-options),
|
|
||||||
in addition to several auto-render-specific keys:
|
|
||||||
|
|
||||||
- `delimiters`: This is a list of delimiters to look for math. Each delimiter
|
|
||||||
has three properties:
|
|
||||||
|
|
||||||
- `left`: A string which starts the math expression (i.e. the left delimiter).
|
|
||||||
- `right`: A string which ends the math expression (i.e. the right delimiter).
|
|
||||||
- `display`: A boolean of whether the math in the expression should be
|
|
||||||
rendered in display mode or not.
|
|
||||||
|
|
||||||
The default value is:
|
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{left: "$$", right: "$$", display: true},
|
|
||||||
{left: "\\(", right: "\\)", display: false},
|
|
||||||
{left: "\\[", right: "\\]", display: true}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
- `ignoredTags`: This is a list of DOM node types to ignore when recursing
|
|
||||||
through. The default value is
|
|
||||||
`["script", "noscript", "style", "textarea", "pre", "code"]`.
|
|
||||||
|
|
||||||
- `ignoredClasses`: This is a list of DOM node class names to ignore when
|
|
||||||
recursing through. By default, this value is not set.
|
|
||||||
|
|
||||||
- `errorCallback`: A callback method returning a message and an error stack
|
|
||||||
in case of an critical error during rendering. The default uses `console.error`.
|
|
||||||
|
|
||||||
- `preProcess`: A callback function, `(math: string) => string`, used to process
|
|
||||||
math expressions before rendering.
|
|
||||||
|
|
||||||
The `displayMode` property of the options object is ignored, and is
|
|
||||||
instead taken from the `display` key of the corresponding entry in the
|
|
||||||
`delimiters` key.
|
|
||||||
|
|
||||||
The same `options.macros` object (which defaults to an empty object `{}`)
|
|
||||||
is passed into several calls to `katex.render`, so that consecutive equations
|
|
||||||
can build up shared macros by `\gdef`.
|
|
@@ -1,99 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.1-browser
|
|
||||||
title: Browser
|
|
||||||
original_id: browser
|
|
||||||
---
|
|
||||||
> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11.
|
|
||||||
|
|
||||||
## Global
|
|
||||||
If you include the `katex.js` directly, the `katex` object will be available as
|
|
||||||
a global variable.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.css" integrity="sha384-b/NoaeRXkMxyKcrDw2KtVtYKkVg3dA0rTRgLoV7W2df3MzeR1eHLTi+l4//4fMwk" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.js" integrity="sha384-ern5NCRqs6nJ/a4Ik0nB9hnKVH5HwV2XRUYdQl09OB/vvd1Lmmqbg1Mh+mYUclXx" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides minified versions:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
The loading of scripts are [deferred using `defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to speed up page rendering. The `katex` object will be available after
|
|
||||||
[`DOMContentLoaded` event is fired on the `document`](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded).
|
|
||||||
If you do not use `defer`, `katex` object will be available after corresponding
|
|
||||||
`script` tag.
|
|
||||||
|
|
||||||
If KaTeX is not used immediately or not critical, it is possible to load KaTeX
|
|
||||||
asynchronously. Add [`async` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to `script` and use [`rel="preload"` and `onload` attribute](https://github.com/filamentgroup/loadCSS)
|
|
||||||
on `link`.
|
|
||||||
|
|
||||||
You can prefetch KaTeX fonts to prevent FOUT or FOIT. Use [Font Loading API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API)
|
|
||||||
or [Web Font Loader](https://github.com/typekit/webfontloader):
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
window.WebFontConfig = {
|
|
||||||
custom: {
|
|
||||||
families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7',
|
|
||||||
'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script',
|
|
||||||
'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3',
|
|
||||||
'KaTeX_Size4', 'KaTeX_Typewriter'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use [`rel="preload"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content).
|
|
||||||
Add `<link rel="preload" href=(path to WOFF2 font) as="font" type="font/woff2" crossorigin="anonymous">`
|
|
||||||
to `head`. Note that [only few browsers support it](https://caniuse.com/#feat=link-rel-preload)
|
|
||||||
and they all support WOFF2 so preloading WOFF2 fonts is enough.
|
|
||||||
|
|
||||||
See [Google Web Fundamentals - Web Font Optimization](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/webfont-optimization)
|
|
||||||
for more detail.
|
|
||||||
|
|
||||||
## Module Loaders
|
|
||||||
### AMD
|
|
||||||
```html
|
|
||||||
<script type="text/javascript">
|
|
||||||
require([
|
|
||||||
"https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.js",
|
|
||||||
], katex => {
|
|
||||||
...
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.css" integrity="sha384-b/NoaeRXkMxyKcrDw2KtVtYKkVg3dA0rTRgLoV7W2df3MzeR1eHLTi+l4//4fMwk" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
### ECMAScript module
|
|
||||||
```html
|
|
||||||
<script type="module" type="text/javascript">
|
|
||||||
import katex from 'https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.mjs';
|
|
||||||
...
|
|
||||||
</script>
|
|
||||||
<script nomodule defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.js" integrity="sha384-ern5NCRqs6nJ/a4Ik0nB9hnKVH5HwV2XRUYdQl09OB/vvd1Lmmqbg1Mh+mYUclXx" crossorigin="anonymous"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.css" integrity="sha384-b/NoaeRXkMxyKcrDw2KtVtYKkVg3dA0rTRgLoV7W2df3MzeR1eHLTi+l4//4fMwk" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
> Use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules.
|
|
||||||
|
|
||||||
## Download & Host Things Yourself
|
|
||||||
Download a [KaTeX release](https://github.com/KaTeX/KaTeX/releases),
|
|
||||||
copy `katex.js`, `katex.css`
|
|
||||||
(or `katex.min.js` and `katex.min.css` to use minified versions),
|
|
||||||
and the `fonts` directory, and include or import it like above.
|
|
||||||
|
|
||||||
You can also build from source. See [Building from Source](node.md#building-from-source)
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
## Bundler
|
|
||||||
[Use Node.js package managers to install KaTeX and import it](node.md) in your
|
|
||||||
project. Then bundle using bundlers like [webpack](https://webpack.js.org/) or
|
|
||||||
[rollup.js](https://rollupjs.org/). Note that you have to bundle the stylesheet
|
|
||||||
(`katex.css`) or include it manually.
|
|
@@ -1,67 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.1-cli
|
|
||||||
title: CLI
|
|
||||||
original_id: cli
|
|
||||||
---
|
|
||||||
|
|
||||||
KaTeX installed [using Node.js package managers](node.md) comes with a
|
|
||||||
built-in command-line interface (CLI) which can be used to render TeX to HTML.
|
|
||||||
By default, CLI will take the input from standard input.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npx katex
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above uses the `npx` command to run the locally installed executable
|
|
||||||
after `npm install katex`. You can also execute with the relative path:
|
|
||||||
`./node_modules/.bin/katex`
|
|
||||||
|
|
||||||
> To use the CLI from local Git clone, you need to build the project first.
|
|
||||||
See [Building from Source](node.md#building-from-source) for more details.
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### `-V, --version`
|
|
||||||
output the version number
|
|
||||||
|
|
||||||
### `-d, --display-mode`
|
|
||||||
Render math in display mode, which puts the math in display style (so \int and \sum are large, for example), and centers the math on the page on its own line.
|
|
||||||
|
|
||||||
### `--leqno`
|
|
||||||
Render display math in leqno style (left-justified tags).
|
|
||||||
|
|
||||||
### `--fleqn`
|
|
||||||
Render display math flush left.
|
|
||||||
|
|
||||||
### `-t, --no-throw-on-error`
|
|
||||||
Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.
|
|
||||||
|
|
||||||
### `-c, --error-color <color>`
|
|
||||||
A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option. (default: #cc0000)
|
|
||||||
|
|
||||||
### `-b, --color-is-text-color`
|
|
||||||
Makes \color behave like LaTeX's 2-argument \textcolor, instead of LaTeX's one-argument \color mode change.
|
|
||||||
|
|
||||||
### `-S, --strict`
|
|
||||||
Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX
|
|
||||||
|
|
||||||
### `-s, --max-size <n>`
|
|
||||||
If non-zero, all user-specified sizes, e.g. in \rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large (default: Infinity)
|
|
||||||
|
|
||||||
### `-e, --max-expand <n>`
|
|
||||||
Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.
|
|
||||||
|
|
||||||
### `-m, --macro <def>`
|
|
||||||
Define custom macro of the form '\foo:expansion' (use multiple -m arguments for multiple macros). (default: )
|
|
||||||
|
|
||||||
### `-f, --macro-file <path>`
|
|
||||||
Read macro definitions, one per line, from the given file.
|
|
||||||
|
|
||||||
### `-i, --input <path>`
|
|
||||||
Read LaTeX input from the given file.
|
|
||||||
|
|
||||||
### `-o, --output <path>`
|
|
||||||
Write html output to the given file.
|
|
||||||
|
|
||||||
### `-h, --help`
|
|
||||||
Output usage information
|
|
@@ -1,47 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.1-font
|
|
||||||
title: Font
|
|
||||||
original_id: font
|
|
||||||
---
|
|
||||||
By changing the variables in the `fonts.less` file at the [katex-fonts submodule](https://github.com/KaTeX/katex-fonts/),
|
|
||||||
several properties of the way fonts are used can be changed.
|
|
||||||
|
|
||||||
## Font size and lengths
|
|
||||||
By default, KaTeX math is rendered in a 1.21× larger font than the surrounding
|
|
||||||
context, which makes super- and subscripts easier to read. You can control
|
|
||||||
this using CSS, for example, to set to 1.1×:
|
|
||||||
|
|
||||||
```css
|
|
||||||
.katex { font-size: 1.1em; }
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX supports all TeX units, including absolute units like `cm` and `in`.
|
|
||||||
Absolute units are currently scaled relative to the default TeX font size of
|
|
||||||
10pt, so that `\kern1cm` produces the same results as `\kern2.845275em`.
|
|
||||||
As a result, relative and absolute units are both uniformly scaled relative
|
|
||||||
to LaTeX with a 10pt font; for example, the rectangle `\rule{1cm}{1em}` has
|
|
||||||
the same aspect ratio in KaTeX as in LaTeX. However, because most browsers
|
|
||||||
default to a larger font size, this typically means that a 1cm kern in KaTeX
|
|
||||||
will appear larger than 1cm in browser units.
|
|
||||||
|
|
||||||
## Kinds of fonts used
|
|
||||||
|
|
||||||
KaTeX provides fonts in three different formats: `ttf`, `woff`, and `woff2`.
|
|
||||||
|
|
||||||
- `ttf`s are included to support very old browsers and local installation. [Browser support](https://caniuse.com/#feat=ttf)
|
|
||||||
- `woff` is the format that is most widely supported (all modern browsers support it), so it probably provides the most benefit to being included. [Browser support](https://caniuse.com/#feat=woff)
|
|
||||||
- `woff2`s are included for modern browsers, because they are much smaller and faster to load. [Browser support](https://caniuse.com/#feat=woff2)
|
|
||||||
|
|
||||||
KaTeX will automatically include only necessary fonts for target environments
|
|
||||||
specified by [Browserslist config](https://github.com/browserslist/browserslist#queries).
|
|
||||||
|
|
||||||
To force a font type to be included or excluded, set `USE_(FONT NAME)` environment
|
|
||||||
variable to `"true"` or `"false"`, respectively.`
|
|
||||||
|
|
||||||
## Location of font files
|
|
||||||
|
|
||||||
The default build of KaTeX expects the KaTeX fonts to be located in a directory called `fonts` which is a sibling of the `katex.min.css` stylesheet. This can be changed as follows:
|
|
||||||
|
|
||||||
1. At the top of the [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less) file, set `@font-folder` to the location of your fonts. You can use relative or absolute paths, so setting it to `"/fonts"` would cause it to search for the fonts in a root `fonts` folder, while `"../fonts"` would search in a `fonts` directory one level above the `katex.min.css` file.
|
|
||||||
2. Rebuild KaTeX by running `yarn build` from the top-level directory.
|
|
||||||
3. Use the newly generated `build/katex.min.css` file, and place the fonts where you indicated.
|
|
@@ -1,45 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.1-libs
|
|
||||||
title: Extensions & Libraries
|
|
||||||
original_id: libs
|
|
||||||
---
|
|
||||||
## Extensions
|
|
||||||
|
|
||||||
These extensions are provided by KaTeX.
|
|
||||||
|
|
||||||
- [Auto-render](autorender.md): Automatically renders all of the math inside text
|
|
||||||
- [Copy-tex](https://github.com/Khan/KaTeX/tree/master/contrib/copy-tex): When selecting and copying KaTeX-rendered elements, copies their LaTeX source to the clipboard
|
|
||||||
- [`math/tex` Custom Script Type](https://github.com/Khan/KaTeX/tree/master/contrib/mathtex-script-type): Automatically displays LaTeX math inside `script` tags with `type=math/tex`
|
|
||||||
- [mhchem](https://github.com/Khan/KaTeX/tree/master/contrib/mhchem): Write beautiful chemical equations easily
|
|
||||||
|
|
||||||
## Libraries
|
|
||||||
|
|
||||||
These libraries are maintained by third-parties.
|
|
||||||
|
|
||||||
### Angular2+
|
|
||||||
- [ng-katex](https://github.com/garciparedes/ng-katex): Angular module to write beautiful math expressions with TeX syntax boosted by KaTeX library
|
|
||||||
|
|
||||||
### iOS
|
|
||||||
- [KaTeX-iOS](https://github.com/ianarawjo/KaTeX-iOS): iOS UIView that renders TeX expressions with KaTeX
|
|
||||||
|
|
||||||
### React
|
|
||||||
- [react-latex](https://github.com/zzish/react-latex): React component to render latex strings, based on KaTeX
|
|
||||||
- [react-katex](https://github.com/talyssonoc/react-katex): React components that use KaTeX to typeset math expressions
|
|
||||||
|
|
||||||
### Ruby
|
|
||||||
|
|
||||||
- [katex-ruby](https://github.com/glebm/katex-ruby): Provides server-side rendering and integration with popular Ruby web frameworks (Rails, Hanami, and anything that uses Sprockets).
|
|
||||||
|
|
||||||
### Vue
|
|
||||||
- [vue-katex](https://github.com/lucpotage/vue-katex): Vue plugin to render TeX expressions using KaTeX.
|
|
||||||
|
|
||||||
### AsciiMath
|
|
||||||
|
|
||||||
If you want to render math written in [AsciiMath](http://asciimath.org/),
|
|
||||||
you'll need to first convert AsciiMath into LaTeX input, then call KaTeX.
|
|
||||||
|
|
||||||
- [asciimath2tex](https://github.com/christianp/asciimath2tex): Converts AsciiMath to TeX, with KaTeX in mind
|
|
||||||
|
|
||||||
### Canvas LaTeX
|
|
||||||
|
|
||||||
- [canvas-latex](https://github.com/CurriculumAssociates/canvas-latex): Renders mathematical expressions on HTML5's canvas element. Supports popular libraries like: CreateJS, and PIXI.
|
|
@@ -1,79 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.1-node
|
|
||||||
title: Node.js
|
|
||||||
original_id: node
|
|
||||||
---
|
|
||||||
## Installation
|
|
||||||
### npm
|
|
||||||
Install with `npm`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install katex
|
|
||||||
# or globally
|
|
||||||
npm install -g katex
|
|
||||||
```
|
|
||||||
|
|
||||||
### Yarn
|
|
||||||
Install with `Yarn`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn add katex
|
|
||||||
# or globally
|
|
||||||
yarn global add katex
|
|
||||||
```
|
|
||||||
|
|
||||||
### Building from Source
|
|
||||||
To build you will need Git, Node.js 6.9 or later, and Yarn.
|
|
||||||
|
|
||||||
Clone a copy of the GitHub source repository:
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/KaTeX/KaTeX.git
|
|
||||||
cd KaTeX
|
|
||||||
```
|
|
||||||
|
|
||||||
Then install dependencies and run `build` script:
|
|
||||||
```bash
|
|
||||||
yarn
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
It will automatically transpile code and include only necessary fonts for
|
|
||||||
target environments specified by [Browserslist config](https://github.com/browserslist/browserslist#environment-variables).
|
|
||||||
For example, if you are making a web app for a kiosk with Chrome 68, run
|
|
||||||
`BROWSERSLIST="Chrome 68" yarn build` and it will produce build with no
|
|
||||||
transpilation, as it fully supports ES6, and only include WOFF2 fonts.
|
|
||||||
|
|
||||||
You can override included fonts using environment variables. Set `USE_(FONT NAME)`
|
|
||||||
environment variable to `"true"` or `"false"`, to force a font type to be included
|
|
||||||
or excluded, respectively.`
|
|
||||||
|
|
||||||
If you'd like to use the built KaTeX in other projects, install the package by
|
|
||||||
specifying the path:
|
|
||||||
```bash
|
|
||||||
yarn add /path/to/KaTeX
|
|
||||||
# or using npm
|
|
||||||
npm install /path/to/KaTeX
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can manually download the package and source code from
|
|
||||||
[GitHub releases](https://github.com/KaTeX/KaTeX/releases).
|
|
||||||
|
|
||||||
## Importing
|
|
||||||
KaTeX is exported as a CommonJS module, which can be imported using `require`:
|
|
||||||
```js
|
|
||||||
const katex = require('katex');
|
|
||||||
```
|
|
||||||
|
|
||||||
If you're using a module loader, transpiler, or bundler that supports interoperability
|
|
||||||
between ECMAScript module and CommonJS module, you can use `import`:
|
|
||||||
```js
|
|
||||||
import katex from 'katex';
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides an ECMAScript module:
|
|
||||||
```js
|
|
||||||
import katex from 'katex/dist/katex.mjs'
|
|
||||||
```
|
|
||||||
|
|
||||||
> The ES module contains ES6 syntaxes and features, and may need transpiling to
|
|
||||||
use in old environments:
|
|
@@ -1,43 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.1-options
|
|
||||||
title: Options
|
|
||||||
original_id: options
|
|
||||||
---
|
|
||||||
You can provide an object of options as the last argument to [`katex.render` and `katex.renderToString`](api.md). Available options are:
|
|
||||||
|
|
||||||
- `displayMode`: `boolean`. If `true` the math will be rendered in display mode, which will put the math in display style (so `\int` and `\sum` are large, for example), and will center the math on the page on its own line. If `false` the math will be rendered in inline mode. (default: `false`)
|
|
||||||
- `leqno`: `boolean`. If `true`, display math has `\tag`s rendered on the left instead of the right, like `\usepackage[leqno]{amsmath}` in LaTeX.
|
|
||||||
- `fleqn`: `boolean`. If `true`, display math renders flush left, like `\documentclass[fleqn]` in LaTeX.
|
|
||||||
- `throwOnError`: `boolean`. If `true` (the default), KaTeX will throw a `ParseError` when it encounters an unsupported command or invalid LaTeX. If `false`, KaTeX will render unsupported commands as text, and render invalid LaTeX as its source code with hover text giving the error, in the color given by `errorColor`.
|
|
||||||
- `errorColor`: `string`. A color string given in the format `"#XXX"` or `"#XXXXXX"`. This option determines the color that unsupported commands and invalid LaTeX are rendered in when `throwOnError` is set to `false`. (default: `#cc0000`)
|
|
||||||
- `macros`: `object`. A collection of custom macros. Each macro is a property with a name like `\name` (written `"\\name"` in JavaScript) which maps to a string that describes the expansion of the macro, or a function that accepts an instance of `MacroExpander` as first argument and returns the expansion as a string. `MacroExpander` is an internal API and subject to non-backwards compatible changes. See [`src/macros.js`](https://github.com/KaTeX/KaTeX/blob/master/src/macros.js) for its usage. Single-character keys can also be included in which case the character will be redefined as the given macro (similar to TeX active characters). *This object will be modified* if the LaTeX code defines its own macros via `\gdef`, which enables consecutive calls to KaTeX to share state.
|
|
||||||
- `colorIsTextColor`: `boolean`. If `true`, `\color` will work like LaTeX's `\textcolor`, and take two arguments (e.g., `\color{blue}{hello}`), which restores the old behavior of KaTeX (pre-0.8.0). If `false` (the default), `\color` will work like LaTeX's `\color`, and take one argument (e.g., `\color{blue}hello`). In both cases, `\textcolor` works as in LaTeX (e.g., `\textcolor{blue}{hello}`).
|
|
||||||
- `maxSize`: `number`. All user-specified sizes, e.g. in `\rule{500em}{500em}`, will be capped to `maxSize` ems. If set to `Infinity` (the default), users can make elements and spaces arbitrarily large.
|
|
||||||
- `maxExpand`: `number`. Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to `Infinity`, the macro expander will try to fully expand as in LaTeX. (default: 1000)
|
|
||||||
- `allowedProtocols`: `string[]`. Allowed protocols in `\href`. Use `_relative` to allow relative urls, and `*` to allow all protocols. (default: `["http", "https", "mailto", "_relative"]`)
|
|
||||||
- `strict`: `boolean` or `string` or `function` (default: `"warn"`). If `false` or `"ignore`", allow features that make writing LaTeX convenient but are not actually supported by (Xe)LaTeX (similar to MathJax). If `true` or `"error"` (LaTeX faithfulness mode), throw an error for any such transgressions. If `"warn"` (the default), warn about such behavior via `console.warn`. Provide a custom function `handler(errorCode, errorMsg, token)` to customize behavior depending on the type of transgression (summarized by the string code `errorCode` and detailed in `errorMsg`); this function can also return `"ignore"`, `"error"`, or `"warn"` to use a built-in behavior. A list of such features and their `errorCode`s:
|
|
||||||
- `"unknownSymbol"`: Use of unknown Unicode symbol, which will likely also
|
|
||||||
lead to warnings about missing character metrics, and layouts may be
|
|
||||||
incorrect (especially in terms of vertical heights).
|
|
||||||
- `"unicodeTextInMathMode"`: Use of Unicode text characters in math mode.
|
|
||||||
- `"mathVsTextUnits"`: Mismatch of math vs. text commands and units/mode.
|
|
||||||
- `"commentAtEnd"`: Use of `%` comment without a terminating newline.
|
|
||||||
LaTeX would thereby comment out the end of math mode (e.g. `$`),
|
|
||||||
causing an error.
|
|
||||||
|
|
||||||
A second category of `errorCode`s never throw errors, but their strictness
|
|
||||||
affects the behavior of KaTeX:
|
|
||||||
- `"newLineInDisplayMode"`: Use of `\\` or `\newline` in display mode
|
|
||||||
(outside an array/tabular environment). In strict mode, no line break
|
|
||||||
results, as in LaTeX.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
katex.render("c = \\pm\\sqrt{a^2 + b^2}\\in\\RR", element, {
|
|
||||||
displayMode: true,
|
|
||||||
macros: {
|
|
||||||
"\\RR": "\\mathbb{R}"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,640 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.1-supported
|
|
||||||
title: Supported Functions
|
|
||||||
original_id: supported
|
|
||||||
---
|
|
||||||
This is a list of TeX functions supported by KaTeX. It is sorted into logical groups.
|
|
||||||
|
|
||||||
There is a similar [Support Table](support_table.md), sorted alphabetically, that lists both supported and un-supported functions.
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous"/>
|
|
||||||
<style>
|
|
||||||
p {overflow-wrap: break-word;}
|
|
||||||
table tr,
|
|
||||||
table td {
|
|
||||||
vertical-align: middle;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Accents
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------------------------|:----------------------------------------------------|:-----
|
|
||||||
|$a'$ `a'` |$\tilde{a}$ `\tilde{a}`|$\mathring{g}$ `\mathring{g}`
|
|
||||||
|$a''$ `a''`|$\widetilde{ac}$ `\widetilde{ac}` |$\overgroup{AB}$ `\overgroup{AB}`
|
|
||||||
|$a^{\prime}$ `a^{\prime}` |$\utilde{AB}$ `\utilde{AB}` |$\undergroup{AB}$ `\undergroup{AB}`
|
|
||||||
|$\acute{a}$ `\acute{a}`|$\vec{F}$ `\vec{F}` |$\Overrightarrow{AB}$ `\Overrightarrow{AB}`
|
|
||||||
|$\bar{y}$ `\bar{y}` |$\overleftarrow{AB}$ `\overleftarrow{AB}`|$\overrightarrow{AB}$ `\overrightarrow{AB}`
|
|
||||||
|$\breve{a}$ `\breve{a}`|$\underleftarrow{AB}$ `\underleftarrow{AB}` |$\underrightarrow{AB}$ `\underrightarrow{AB}`
|
|
||||||
|$\check{a}$ `\check{a}`|$\overleftharpoon{ac}$ `\overleftharpoon{ac}` |$\overrightharpoon{ac}$ `\overrightharpoon{ac}`
|
|
||||||
|$\dot{a}$ `\dot{a}` |$\overleftrightarrow{AB}$ `\overleftrightarrow{AB}` |$\overbrace{AB}$ `\overbrace{AB}`
|
|
||||||
|$\ddot{a}$ `\ddot{a}` |$\underleftrightarrow{AB}$ `\underleftrightarrow{AB}`|$\underbrace{AB}$ `\underbrace{AB}`
|
|
||||||
|$\grave{a}$ `\grave{a}`|$\overline{AB}$ `\overline{AB}` |$\overlinesegment{AB}$ `\overlinesegment{AB}`
|
|
||||||
|$\hat{\theta}$ `\hat{\theta}`|$\underline{AB}$ `\underline{AB}` |$\underlinesegment{AB}$ `\underlinesegment{AB}`
|
|
||||||
|$\widehat{ac}$ `\widehat{ac}`|$\widecheck{ac}$ `\widecheck{ac}` |
|
|
||||||
|
|
||||||
***Accent functions inside \\text{…}***
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:-----
|
|
||||||
|$\text{\'{a}}$ `\'{a}`|$\text{\~{a}}$ `\~{a}`|$\text{\.{a}}$ `\.{a}`|$\text{\H{a}}$ `\H{a}`
|
|
||||||
|$\text{\`{a}}$ <code>\\`{a}</code>|$\text{\={a}}$ `\={a}`|$\text{\"{a}}$ `\"{a}`|$\text{\v{a}}$ `\v{a}`
|
|
||||||
|$\text{\^{a}}$ `\^{a}`|$\text{\u{a}}$ `\u{a}`|$\text{\r{a}}$ `\r{a}`|
|
|
||||||
|
|
||||||
See also [letters](#letters)
|
|
||||||
|
|
||||||
## Delimiters
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:-----------------------------------|:---------------------------------------|:----------|:-------------------------------------------------------|:-----
|
|
||||||
|$(~)$ `( )` |$\lparen~\rparen$ `\lparen`<br>$~~~~$`\rparen`|$⌈~⌉$ `⌈ ⌉`|$\lceil~\rceil$ `\lceil`<br>$~~~~~$`\rceil` |$\uparrow$ `\uparrow`
|
|
||||||
|$[~]$ `[ ]` |$\lbrack~\rbrack$ `\lbrack`<br>$~~~~$`\rbrack`|$⌊~⌋$ `⌊ ⌋`|$\lfloor~\rfloor$ `\lfloor`<br>$~~~~~$`\rfloor` |$\downarrow$ `\downarrow`
|
|
||||||
|$\{ \}$ `\{ \}`|$\lbrace \rbrace$ `\lbrace`<br>$~~~~$`\rbrace`|$⎰⎱$ `⎰⎱` |$\lmoustache \rmoustache$ `\lmoustache`<br>$~~~~$`\rmoustache`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$⟨~⟩$ `⟨ ⟩` |$\langle~\rangle$ `\langle`<br>$~~~~$`\rangle`|$⟮~⟯$ `⟮ ⟯`|$\lgroup~\rgroup$ `\lgroup`<br>$~~~~~$`\rgroup` |$\Uparrow$ `\Uparrow`
|
|
||||||
|$\vert$ <code>|</code> |$\vert$ `\vert` |$┌ ┐$ `┌ ┐`|$\ulcorner \urcorner$ `\ulcorner`<br>$~~~~$`\urcorner` |$\Downarrow$ `\Downarrow`
|
|
||||||
|$\Vert$ <code>\|</code> |$\Vert$ `\Vert` |$└ ┘$ `└ ┘`|$\llcorner \lrcorner$ `\llcorner`<br>$~~~~$`\lrcorner` |$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\lvert~\rvert$ `\lvert`<br>$~~~~$`\rvert`|$\lVert~\rVert$ `\lVert`<br>$~~~~~$`\rVert` |`\left.`| `\right.` |$\backslash$ `\backslash`
|
|
||||||
|$\lang~\rang$ `\lang`<br>$~~~~$`\rang`|$\lt~\gt$ `\lt \gt`|$⟦~⟧$ `⟦ ⟧`|
|
|
||||||
|
|
||||||
**Delimiter Sizing**
|
|
||||||
|
|
||||||
$\left(\LARGE{AB}\right)$ `\left(\LARGE{AB}\right)`
|
|
||||||
|
|
||||||
$( \big( \Big( \bigg( \Bigg($ `( \big( \Big( \bigg( \Bigg(`
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:--------|:------|:--------|:-------|:------|
|
|
||||||
|`\left` |`\big` |`\bigl` |`\bigm` |`\bigr`
|
|
||||||
|`\middle`|`\Big` |`\Bigl` |`\Bigm` | `\Bigr`
|
|
||||||
|`\right` |`\bigg`|`\biggl` |`\biggm`|`\biggr`
|
|
||||||
| |`\Bigg`|`\Biggl` |`\Biggm`|`\Biggr`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Environments
|
|
||||||
|
|
||||||
<div class="katex-cards" id="environments">
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:--------
|
|
||||||
|$\begin{matrix} a & b \\ c & d \end{matrix}$ | `\begin{matrix}`<br> `a & b \\`<br> `c & d`<br>`\end{matrix}` |$\begin{array}{cc}a & b\\c & d\end{array}$ | `\begin{array}{cc}`<br> `a & b \\`<br> `c & d`<br>`\end{array}`
|
|
||||||
|$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$ |`\begin{pmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{pmatrix}` |$\begin{bmatrix} a & b \\ c & d \end{bmatrix}$ | `\begin{bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{bmatrix}`
|
|
||||||
|$\begin{vmatrix} a & b \\ c & d \end{vmatrix}$ |`\begin{vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{vmatrix}` |$\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}$ |`\begin{Vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Vmatrix}`
|
|
||||||
|$\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}$ |`\begin{Bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Bmatrix}`|$\def\arraystretch{1.5}\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}$|`\def\arraystretch{1.5}`<br> `\begin{array}{c:c:c}`<br> `a & b & c \\ \hline`<br> `d & e & f \\`<br> `\hdashline`<br> `g & h & i`<br>`\end{array}`
|
|
||||||
|$\begin{aligned} a&=b+c \\ d+e&=f \end{aligned}$ |`\begin{aligned}`<br> `a&=b+c \\`<br> `d+e&=f`<br>`\end{aligned}`|$\begin{alignedat}{2}10&x+&3&y=2\\3&x+&13&y=4\end{alignedat}$ |`\begin{alignedat}{2}`<br> `10&x+ &3&y = 2 \\`<br> ` 3&x+&13&y = 4`<br>`\end{alignedat}`
|
|
||||||
|$\begin{gathered} a=b \\ e=b+c \end{gathered}$ |`\begin{gathered}`<br> `a=b \\ `<br> `e=b+c`<br>`\end{gathered}`|$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$ |`x = \begin{cases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{cases}`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
KaTeX also supports `darray` and `dcases`.
|
|
||||||
|
|
||||||
Acceptable line separators include: `\\`, `\cr`, `\\[distance]`, and `\cr[distance]`. *Distance* can be written with any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
The `{array}` environment supports `|` and `:` vertical separators.
|
|
||||||
|
|
||||||
The `{array}` environment does not yet support `\cline` or `\multicolumn`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## HTML
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------|:-------------------|
|
|
||||||
| $\href{https://katex.org/}{\KaTeX}$ | `\href{https://katex.org/}{\KaTeX}` |
|
|
||||||
| $\url{https://katex.org/}$ | `\url{https://katex.org/}` |
|
|
||||||
|
|
||||||
## Letters and Unicode
|
|
||||||
|
|
||||||
**Greek Letters**
|
|
||||||
|
|
||||||
Direct Input: $Α Β Γ Δ Ε Ζ Η Θ Ι \allowbreak Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω$
|
|
||||||
$\allowbreak α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π \allowbreak ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ$
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|---------------|-------------|-------------|---------------|
|
|
||||||
| $\Alpha$ `\Alpha` | $\Beta$ `\Beta` | $\Gamma$ `\Gamma`| $\Delta$ `\Delta`
|
|
||||||
| $\Epsilon$ `\Epsilon` | $\Zeta$ `\Zeta` | $\Eta$ `\Eta` | $\Theta$ `\Theta`
|
|
||||||
| $\Iota$ `\Iota` | $\Kappa$ `\Kappa` | $\Lambda$ `\Lambda` | $\Mu$ `\Mu`
|
|
||||||
| $\Nu$ `\Nu` | $\Xi$ `\Xi` | $\Omicron$ `\Omicron` | $\Pi$ `\Pi`
|
|
||||||
| $\Sigma$ `\Sigma` | $\Tau$ `\Tau` | $\Upsilon$ `\Upsilon` | $\Phi$ `\Phi`
|
|
||||||
| $\Chi$ `\Chi` | $\Psi$ `\Psi`| $\Omega$ `\Omega`
|
|
||||||
| $\varGamma$ `\varGamma`| $\varDelta$ `\varDelta` | $\varTheta$ `\varTheta` | $\varLambda$ `\varLambda` |
|
|
||||||
| $\varXi$ `\varXi`| $\varPi$ `\varPi` | $\varSigma$ `\varSigma` | $\varUpsilon$ `\varUpsilon` |
|
|
||||||
| $\varPhi$ `\varPhi` | $\varPsi$ `\varPsi`| $\varOmega$ `\varOmega` ||
|
|
||||||
| $\alpha$ `\alpha`| $\beta$ `\beta` | $\gamma$ `\gamma` | $\delta$ `\delta`|
|
|
||||||
| $\epsilon$ `\epsilon` | $\zeta$ `\zeta` | $\eta$ `\eta`| $\theta$ `\theta`|
|
|
||||||
| $\iota$ `\iota` | $\kappa$ `\kappa` | $\lambda$ `\lambda`| $\mu$ `\mu`|
|
|
||||||
| $\nu$ `\nu`| $\xi$ `\xi` | $\omicron$ `\omicron` | $\pi$ `\pi`|
|
|
||||||
| $\rho$ `\rho` | $\sigma$ `\sigma` | $\tau$ `\tau`| $\upsilon$ `\upsilon` |
|
|
||||||
| $\phi$ `\phi` | $\chi$ `\chi`| $\psi$ `\psi`| $\omega$ `\omega`|
|
|
||||||
| $\varepsilon$ `\varepsilon` | $\varkappa$ `\varkappa` | $\vartheta$ `\vartheta` | $\thetasym$ `\thetasym`
|
|
||||||
| $\varpi$ `\varpi`| $\varrho$ `\varrho` | $\varsigma$ `\varsigma` | $\varphi$ `\varphi`
|
|
||||||
| $\digamma $ `\digamma`
|
|
||||||
|
|
||||||
**Other Letters**
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:----------|:----------|:----------|:----------|:----------|
|
|
||||||
|$\imath$ `\imath`|$\nabla$ `\nabla`|$\Im$ `\Im`|$\Reals$ `\Reals`|$\text{\OE}$ `\text{\OE}`
|
|
||||||
|$\jmath$ `\jmath`|$\partial$ `\partial`|$\image$ `\image`|$\wp$ `\wp`|$\text{\o}$ `\text{\o}`
|
|
||||||
|$\aleph$ `\aleph`|$\Game$ `\Game`|$\Bbbk$ `\Bbbk`|$\weierp$ `\weierp`|$\text{\O}$ `\text{\O}`
|
|
||||||
|$\alef$ `\alef`|$\Finv$ `\Finv`|$\N$ `\N`|$\Z$ `\Z`|$\text{\ss}$ `\text{\ss}`
|
|
||||||
|$\alefsym$ `\alefsym`|$\cnums$ `\cnums`|$\natnums$ `\natnums`|$\text{\aa}$ `\text{\aa}`|$\text{\i}$ `\text{\i}`
|
|
||||||
|$\beth$ `\beth`|$\Complex$ `\Complex`|$\R$ `\R`|$\text{\AA}$ `\text{\AA}`|$\text{\j}$ `\text{\j}`
|
|
||||||
|$\gimel$ `\gimel`|$\ell$ `\ell`|$\Re$ `\Re`|$\text{\ae}$ `\text{\ae}`
|
|
||||||
|$\daleth$ `\daleth`|$\hbar$ `\hbar`|$\real$ `\real`|$\text{\AE}$ `\text{\AE}`
|
|
||||||
|$\eth$ `\eth`|$\hslash$ `\hslash`|$\reals$ `\reals`|$\text{\oe}$ `\text{\oe}`
|
|
||||||
|
|
||||||
Direct Input: $∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð$
|
|
||||||
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåçèéêëìíîïðñòóôöùúûüýþÿ
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="math-alpha">
|
|
||||||
|
|
||||||
**Unicode Mathematical Alphanumeric Symbols**
|
|
||||||
|
|
||||||
| Item | Range | Item | Range |
|
|
||||||
|-------------|---------------------|-------------------|---------------|
|
|
||||||
| Bold | $\text{𝐀-𝐙 𝐚-𝐳 𝟎-𝟗}$ | Double-struck | $\text{𝔸-}ℤ\ 𝕜$
|
|
||||||
| Italic | $\text{𝐴-𝑍 𝑎-𝑧}$ | Sans serif | $\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}$
|
|
||||||
| Bold Italic | $\text{𝑨-𝒁 𝒂-𝒛}$ | Sans serif bold | $\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}$
|
|
||||||
| Script | $\text{𝒜-𝒵}$ | Sans serif italic | $\text{𝘈-𝘡 𝘢-𝘻}$
|
|
||||||
| Fractur | $\text{𝔄-}ℨ\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
**Unicode**
|
|
||||||
|
|
||||||
The letters listed above will render in any KaTeX rendering mode.
|
|
||||||
|
|
||||||
If the KaTeX rendering mode is set to `strict: false` or `strict:"warn"` (default), then KaTeX will accept all Unicode letters. The letters not listed above will be rendered from system fonts, not KaTeX-supplied fonts, so their typography may clash. They may also cause small vertical alignment issues. KaTeX has detailed metrics for glyphs in Latin, Greek, and Cyrillic, but other glyphs are treated as if they are each as tall as the letter M.
|
|
||||||
|
|
||||||
For Persian composite characters, a user-supplied [plug-in](https://github.com/HosseinAgha/persian-katex-plugin) is under development.
|
|
||||||
|
|
||||||
## Layout
|
|
||||||
|
|
||||||
### Annotation
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:------------------------------|:-----
|
|
||||||
|$\cancel{5}$ `\cancel{5}`|$\overbrace{a+b+c}^{\text{note}}$ `\overbrace{a+b+c}^{\text{note}}`
|
|
||||||
|$\bcancel{5}$ `\bcancel{5}` |$\underbrace{a+b+c}_{\text{note}}$ `\underbrace{a+b+c}_{\text{note}}`
|
|
||||||
|$\xcancel{ABC}$ `\xcancel{ABC}`|$\not =$ `\not =`
|
|
||||||
|$\sout{abc}$ `\sout{abc}`|$\boxed{\pi=\frac c d}$ `\boxed{\pi=\frac c d}`
|
|
||||||
|
|
||||||
`\tag{hi} x+y^{2x}`
|
|
||||||
$$\tag{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
`\tag*{hi} x+y^{2x}`
|
|
||||||
$$\tag*{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
### Line Breaks
|
|
||||||
|
|
||||||
KaTeX 0.10.0+ will insert automatic line breaks in inline math after relations or binary operators such as “=” or “+”. These can be suppressed by `\nobreak` or by placing math inside a pair of braces, as in `{F=ma}`. `\allowbreak` will allow automatic line breaks at locations other than relations or operators.
|
|
||||||
|
|
||||||
Hard line breaks are `\\` and `\newline`.
|
|
||||||
|
|
||||||
In display math, KaTeX does not insert automatic line breaks. It ignores display math hard line breaks when rendering option `strict: true`.
|
|
||||||
|
|
||||||
### Vertical Layout
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------|:----------------------------------------|:-----
|
|
||||||
|$x_n$ `x_n` |$\stackrel{!}{=}$ `\stackrel{!}{=}` |$a \atop b$ `a \atop b`
|
|
||||||
|$e^x$ `e^x` |$\overset{!}{=}$ `\overset{!}{=}` |$a\raisebox{0.25em}{b}c$ `a\raisebox{0.25em}{b}c`
|
|
||||||
|$_u^o $ `_u^o `|$\underset{!}{=}$ `\underset{!}{=}`
|
|
||||||
|
|
||||||
The second argument of `\raisebox` can contain math if it is nested within `$…$` delimiters, as in `\raisebox{0.25em}{$\frac a b$}`
|
|
||||||
|
|
||||||
### Overlap and Spacing
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------|:-------|
|
|
||||||
|${=}\mathllap{/\,}$ `{=}\mathllap{/\,}` | $\left(x^{\smash{2}}\right)$ `\left(x^{\smash{2}}\right)`
|
|
||||||
|$\mathrlap{\,/}{=}$ `\mathrlap{\,/}{=}` | $\sqrt{\smash[b]{y}}$ `\sqrt{\smash[b]{y}} `
|
|
||||||
|
|
||||||
$\displaystyle\sum_{\mathclap{1\le i\le j\le n}} x_{ij}$ `\sum_{\mathclap{1\le i\le j\le n}} x_{ij}`
|
|
||||||
|
|
||||||
KaTeX also supports `\llap`, `\rlap`, and `\clap`, but they will take only text, not math, as arguments.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="spacing-tbl">
|
|
||||||
|
|
||||||
**Spacing**
|
|
||||||
|
|
||||||
| Function | Produces | Function | Produces|
|
|
||||||
|:----------------|:-------------------|:---------------------|:--------------------------------------|
|
|
||||||
| `\,` | ³∕₁₈ em space | `\kern{distance}` | space, width = *distance*
|
|
||||||
| `\thinspace` | ³∕₁₈ em space | `\mkern{distance}` | space, width = *distance*
|
|
||||||
| `\>` | ⁴∕₁₈ em space | `\mskip{distance}` | space, width = *distance*
|
|
||||||
| `\:` | ⁴∕₁₈ em space | `\hskip{distance}` | space, width = *distance*
|
|
||||||
| `\medspace` | ⁴∕₁₈ em space | `\hspace{distance}` | space, width = *distance*
|
|
||||||
| `\;` | ⁵∕₁₈ em space | `\hspace*{distance}` | space, width = *distance*
|
|
||||||
| `\thickspace` | ⁵∕₁₈ em space | `\phantom{content}` | space the width and height of content
|
|
||||||
| `\enspace` | ½ em space | `\hphantom{content}` | space the width of content
|
|
||||||
| `\quad` | 1 em space | `\vphantom{content}` | a strut the height of content
|
|
||||||
| `\qquad` | 2 em space | `\!` | – ³∕₁₈ em space
|
|
||||||
| `~` | non-breaking space | `\negthinspace` | – ³∕₁₈ em space
|
|
||||||
| `\<space>` | space | `\negmedspace` | – ⁴∕₁₈ em space
|
|
||||||
| `\nobreakspace` | non-breaking space | `\negthickspace` | – ⁵∕₁₈ em space
|
|
||||||
| `\space` | space |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
**Notes:**
|
|
||||||
|
|
||||||
`distance` will accept any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
`\kern`, `\mkern`, `\mskip`, and `\hspace` accept unbraced distances, as in: `\kern1em`.
|
|
||||||
|
|
||||||
`\mkern` and `\mskip` will not work in text mode and both will write a console warning for any unit except `mu`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Logic and Set Theory
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:--------------------|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\forall$ `\forall` |$\complement$ `\complement`|$\therefore$ `\therefore` |$\emptyset$ `\emptyset`
|
|
||||||
|$\exists$ `\exists` |$\subset$ `\subset` |$\because$ `\because` |$\empty$ `\empty`
|
|
||||||
|$\exist$ `\exist` |$\supset$ `\supset` |$\mapsto$ `\mapsto` |$\varnothing$ `\varnothing`
|
|
||||||
|$\nexists$ `\nexists`|$\mid$ `\mid` |$\to$ `\to` |$\implies$ `\implies`
|
|
||||||
|$\in$ `\in` |$\land$ `\land` |$\gets$ `\gets` |$\impliedby$ `\impliedby`
|
|
||||||
|$\isin$ `\isin` |$\lor$ `\lor` |$\leftrightarrow$ `\leftrightarrow`|$\iff$ `\iff`
|
|
||||||
|$\notin$ `\notin` |$\ni$ `\ni` |$\notni$ `\notni` |$\neg$ `\neg` or `\lnot`
|
|
||||||
|
|
||||||
Direct Input: $∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬$ ℂ ℍ ℕ ℙ ℚ ℝ
|
|
||||||
|
|
||||||
## Macros
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------------------------------------|:------
|
|
||||||
|$\def\foo{x^2} \foo + \foo$ | `\def\foo{x^2} \foo + \foo`
|
|
||||||
|$\gdef\bar#1{#1^2} \bar{y} + \bar{y}$ | `\gdef\bar#1{#1^2} \bar{y} + \bar{y}`
|
|
||||||
| | `\global\def\macroname#1#2…{definition}`
|
|
||||||
| | `\newcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\renewcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\providecommand\macroname[numargs]{definition}`
|
|
||||||
|
|
||||||
Macros can also be defined in the KaTeX [rendering options](options.md).
|
|
||||||
|
|
||||||
Macros accept up to nine arguments: #1, #2, etc.
|
|
||||||
|
|
||||||
`\gdef` and `\global\def` macros will persist between math expressions.
|
|
||||||
|
|
||||||
Available functions include:
|
|
||||||
|
|
||||||
`\char` `\mathchoice` `\TextOrMath` `\@ifstar` `\@ifnextchar` `\@firstoftwo` `\@secondoftwo` `\relax`
|
|
||||||
|
|
||||||
@ is a valid character for commands, as if `\makeatletter` were in effect.
|
|
||||||
|
|
||||||
## Operators
|
|
||||||
|
|
||||||
### Big Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|------------------|-------------------------|--------------------------|--------------|
|
|
||||||
| $\sum$ `\sum` | $\prod$ `\prod` | $\bigotimes$ `\bigotimes`| $\bigvee$ `\bigvee`
|
|
||||||
| $\int$ `\int` | $\coprod$ `\coprod` | $\bigoplus$ `\bigoplus` | $\bigwedge$ `\bigwedge`
|
|
||||||
| $\iint$ `\iint` | $\intop$ `\intop` | $\bigodot$ `\bigodot` | $\bigcap$ `\bigcap`
|
|
||||||
| $\iiint$ `\iiint`| $\smallint$ `\smallint` | $\biguplus$ `\biguplus` | $\bigcup$ `\bigcup`
|
|
||||||
| $\oint$ `\oint` | $\oiint$ `\oiint` | $\oiiint$ `\oiiint` | $\bigsqcup$ `\bigsqcup`
|
|
||||||
|
|
||||||
Direct Input: $∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆$
|
|
||||||
|
|
||||||
### Binary Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-------------|-------------------|-------------------|--------------------|
|
|
||||||
| $+$ `+`| $\cdot$ `\cdot` | $\gtrdot$ `\gtrdot`| $x \pmod a$ `x \pmod a`|
|
|
||||||
| $-$ `-`| $\cdotp$ `\cdotp` | $\intercal$ `\intercal` | $x \pod a$ `x \pod a` |
|
|
||||||
| $/$ `/`| $\centerdot$ `\centerdot`| $\land$ `\land` | $\rhd$ `\rhd` |
|
|
||||||
| $*$ `*`| $\circ$ `\circ` | $\leftthreetimes$ `\leftthreetimes` | $\rightthreetimes$ `\rightthreetimes` |
|
|
||||||
| $\amalg$ `\amalg` | $\circledast$ `\circledast` | $\ldotp$ `\ldotp` | $\rtimes$ `\rtimes` |
|
|
||||||
| $\And$ `\And`| $\circledcirc$ `\circledcirc` | $\lor$ `\lor`| $\setminus$ `\setminus` |
|
|
||||||
| $\ast$ `\ast`| $\circleddash$ `\circleddash` | $\lessdot$ `\lessdot` | $\smallsetminus$ `\smallsetminus`|
|
|
||||||
| $\barwedge$ `\barwedge` | $\Cup$ `\Cup`| $\lhd$ `\lhd`| $\sqcap$ `\sqcap` |
|
|
||||||
| $\bigcirc$ `\bigcirc` | $\cup$ `\cup`| $\ltimes$ `\ltimes`| $\sqcup$ `\sqcup` |
|
|
||||||
| $\bmod$ `\bmod` | $\curlyvee$ `\curlyvee` | $x \mod a$ `x\mod a`| $\times$ `\times` |
|
|
||||||
| $\boxdot$ `\boxdot`| $\curlywedge$ `\curlywedge` | $\mp$ `\mp` | $\unlhd$ `\unlhd` |
|
|
||||||
| $\boxminus$ `\boxminus` | $\div$ `\div`| $\odot$ `\odot` | $\unrhd$ `\unrhd` |
|
|
||||||
| $\boxplus$ `\boxplus` | $\divideontimes$ `\divideontimes` | $\ominus$ `\ominus`| $\uplus$ `\uplus` |
|
|
||||||
| $\boxtimes$ `\boxtimes` | $\dotplus$ `\dotplus` | $\oplus$ `\oplus` | $\vee$ `\vee` |
|
|
||||||
| $\bullet$ `\bullet`| $\doublebarwedge$ `\doublebarwedge` | $\otimes$ `\otimes`| $\veebar$ `\veebar` |
|
|
||||||
| $\Cap$ `\Cap`| $\doublecap$ `\doublecap`| $\oslash$ `\oslash`| $\wedge$ `\wedge` |
|
|
||||||
| $\cap$ `\cap`| $\doublecup$ `\doublecup`| $\pm$ `\pm` or `\plusmn` | $\wr$ `\wr` |
|
|
||||||
|
|
||||||
Direct Input: $+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝$
|
|
||||||
|
|
||||||
### Fractions and Binomials
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\frac{a}{b}$ `\frac{a}{b}`|$\tfrac{a}{b}$ `\tfrac{a}{b}`|$\genfrac ( ] {2pt}{1}a{a+1}$ `\genfrac ( ] {2pt}{1}a{a+1}`
|
|
||||||
|${a \over b}$ `{a \over b}`|$\dfrac{a}{b}$ `\dfrac{a}{b}`|${a \above{2pt} b+1}$ `{a \above{2pt} b+1}`
|
|
||||||
|$a/b$ `a/b` | |$\cfrac{a}{1 + \cfrac{1}{b}}$ `\cfrac{a}{1 + \cfrac{1}{b}}`
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:--------
|
|
||||||
|$\binom{n}{k}$ `\binom{n}{k}` |$\dbinom{n}{k}$ `\dbinom{n}{k}`|${n\brace k}$ `{n\brace k}`
|
|
||||||
|${n \choose k}$ `{n \choose k}`|$\tbinom{n}{k}$ `\tbinom{n}{k}`|${n\brack k}$ `{n\brack k}`
|
|
||||||
|
|
||||||
### Math Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-----------|---------|-----------------|-----------|
|
|
||||||
| $\arcsin$ `\arcsin` | $\cotg$ `\cotg` | $\ln$ `\ln` | $\det$ `\det` |
|
|
||||||
| $\arccos$ `\arccos` | $\coth$ `\coth` | $\log$ `\log` | $\gcd$ `\gcd` |
|
|
||||||
| $\arctan$ `\arctan` | $\csc$ `\csc` | $\sec$ `\sec` | $\inf$ `\inf` |
|
|
||||||
| $\arctg$ `\arctg` | $\ctg$ `\ctg` | $\sin$ `\sin` | $\lim$ `\lim` |
|
|
||||||
| $\arcctg$ `\arcctg` | $\cth$ `\cth` | $\sinh$ `\sinh`| $\liminf$ `\liminf` |
|
|
||||||
| $\arg$ `\arg` | $\deg$ `\deg` | $\sh$ `\sh` | $\limsup$ `\limsup` |
|
|
||||||
| $\ch$ `\ch` | $\dim$ `\dim` | $\tan$ `\tan` | $\max$ `\max` |
|
|
||||||
| $\cos$ `\cos` | $\exp$ `\exp` | $\tanh$ `\tanh`| $\min$ `\min` |
|
|
||||||
| $\cosec$ `\cosec` | $\hom$ `\hom` | $\tg$ `\tg` | $\Pr$ `\Pr` |
|
|
||||||
| $\cosh$ `\cosh`| $\ker$ `\ker` | $\th$ `\th` | $\sup$ `\sup` |
|
|
||||||
| $\cot$ `\cot` | $\lg$ `\lg`| $\operatorname{f}$ `\operatorname{f}` | $\argmax$ `\argmax` |
|
|
||||||
|$\argmin$ `\argmin`|
|
|
||||||
|
|
||||||
Functions on the right column of this table can take `\limits`.
|
|
||||||
|
|
||||||
### \sqrt
|
|
||||||
|
|
||||||
$\sqrt{x}$ `\sqrt{x}`
|
|
||||||
|
|
||||||
$\sqrt[3]{x}$ `\sqrt[3]{x}`
|
|
||||||
|
|
||||||
## Relations
|
|
||||||
|
|
||||||
$\stackrel{!}{=}$ `\stackrel{!}{=}`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:----------------------------|:--------------------------------|:--------------------------------|:-----
|
|
||||||
|$=$ `=` |$\eqcirc$ `\eqcirc` |$\lesseqgtr$ `\lesseqgtr` |$\sqsupset$ `\sqsupset`
|
|
||||||
|$<$ `<` |$\eqcolon$ `\eqcolon`|$\lesseqqgtr$ `\lesseqqgtr`|$\sqsupseteq$ `\sqsupseteq`
|
|
||||||
|$>$ `>` |$\Eqcolon$ `\Eqcolon`|$\lessgtr$ `\lessgtr`|$\Subset$ `\Subset`
|
|
||||||
|$:$ `:` |$\eqqcolon$ `\eqqcolon` |$\lesssim$ `\lesssim`|$\subset$ `\subset` or `\sub`
|
|
||||||
|$\approx$ `\approx` |$\Eqqcolon$ `\Eqqcolon` |$\ll$ `\ll` |$\subseteq$ `\subseteq` or `\sube`
|
|
||||||
|$\approxeq$ `\approxeq`|$\eqsim$ `\eqsim` |$\lll$ `\lll` |$\subseteqq$ `\subseteqq`
|
|
||||||
|$\asymp$ `\asymp`|$\eqslantgtr$ `\eqslantgtr`|$\llless$ `\llless` |$\succ$ `\succ`
|
|
||||||
|$\backepsilon$ `\backepsilon`|$\eqslantless$ `\eqslantless` |$\lt$ `\lt` |$\succapprox$ `\succapprox`
|
|
||||||
|$\backsim$ `\backsim` |$\equiv$ `\equiv` |$\mid$ `\mid` |$\succcurlyeq$ `\succcurlyeq`
|
|
||||||
|$\backsimeq$ `\backsimeq` |$\fallingdotseq$ `\fallingdotseq`|$\models$ `\models` |$\succeq$ `\succeq`
|
|
||||||
|$\between$ `\between` |$\frown$ `\frown` |$\multimap$ `\multimap` |$\succsim$ `\succsim`
|
|
||||||
|$\bowtie$ `\bowtie` |$\ge$ `\ge` |$\owns$ `\owns`|$\Supset$ `\Supset`
|
|
||||||
|$\bumpeq$ `\bumpeq` |$\geq$ `\geq` |$\parallel$ `\parallel` |$\supset$ `\supset`
|
|
||||||
|$\Bumpeq$ `\Bumpeq` |$\geqq$ `\geqq`|$\perp$ `\perp`|$\supseteq$ `\supseteq` or `\supe`
|
|
||||||
|$\circeq$ `\circeq` |$\geqslant$ `\geqslant` |$\pitchfork$ `\pitchfork` |$\supseteqq$ `\supseteqq`
|
|
||||||
|$\colonapprox$ `\colonapprox`|$\gg$ `\gg` |$\prec$ `\prec`|$\thickapprox$ `\thickapprox`
|
|
||||||
|$\Colonapprox$ `\Colonapprox`|$\ggg$ `\ggg` |$\precapprox$ `\precapprox`|$\thicksim$ `\thicksim`
|
|
||||||
|$\coloneq$ `\coloneq` |$\gggtr$ `\gggtr` |$\preccurlyeq$ `\preccurlyeq` |$\trianglelefteq$ `\trianglelefteq`
|
|
||||||
|$\Coloneq$ `\Coloneq` |$\gt$ `\gt` |$\preceq$ `\preceq` |$\triangleq$ `\triangleq`
|
|
||||||
|$\coloneqq$ `\coloneqq`|$\gtrapprox$ `\gtrapprox` |$\precsim$ `\precsim`|$\trianglerighteq$ `\trianglerighteq`
|
|
||||||
|$\Coloneqq$ `\Coloneqq`|$\gtreqless$ `\gtreqless` |$\propto$ `\propto` |$\varpropto$ `\varpropto`
|
|
||||||
|$\colonsim$ `\colonsim`|$\gtreqqless$ `\gtreqqless`|$\risingdotseq$ `\risingdotseq` |$\vartriangle$ `\vartriangle`
|
|
||||||
|$\Colonsim$ `\Colonsim`|$\gtrless$ `\gtrless`|$\shortmid$ `\shortmid` |$\vartriangleleft$ `\vartriangleleft`
|
|
||||||
|$\cong$ `\cong` |$\gtrsim$ `\gtrsim` |$\shortparallel$ `\shortparallel`|$\vartriangleright$ `\vartriangleright`
|
|
||||||
|$\curlyeqprec$ `\curlyeqprec`|$\in$ `\in` or `\isin` |$\sim$ `\sim` |$\vcentcolon$ `\vcentcolon`
|
|
||||||
|$\curlyeqsucc$ `\curlyeqsucc`|$\Join$ `\Join`|$\simeq$ `\simeq` |$\vdash$ `\vdash`
|
|
||||||
|$\dashv$ `\dashv`|$\le$ `\le` |$\smallfrown$ `\smallfrown`|$\vDash$ `\vDash`
|
|
||||||
|$\dblcolon$ `\dblcolon`|$\leq$ `\leq` |$\smallsmile$ `\smallsmile`|$\Vdash$ `\Vdash`
|
|
||||||
|$\doteq$ `\doteq`|$\leqq$ `\leqq`|$\smile$ `\smile` |$\Vvdash$ `\Vvdash`
|
|
||||||
|$\Doteq$ `\Doteq`|$\leqslant$ `\leqslant` |$\sqsubset$ `\sqsubset` |
|
|
||||||
|$\doteqdot$ `\doteqdot`|$\lessapprox$ `\lessapprox`|$\sqsubseteq$ `\sqsubseteq`|
|
|
||||||
|
|
||||||
|
|
||||||
Direct Input: $= < > : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⟂ ⊨$ `≔ ≕ ⩴`
|
|
||||||
|
|
||||||
### Negated Relations
|
|
||||||
|
|
||||||
$\not =$ `\not =`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|--------------|-------------------|---------------------|------------------|
|
|
||||||
| $\gnapprox$ `\gnapprox` | $\ngeqslant$ `\ngeqslant`| $\nsubseteq$ `\nsubseteq` | $\precneqq$ `\precneqq`|
|
|
||||||
| $\gneq$ `\gneq`| $\ngtr$ `\ngtr` | $\nsubseteqq$ `\nsubseteqq` | $\precnsim$ `\precnsim`|
|
|
||||||
| $\gneqq$ `\gneqq` | $\nleq$ `\nleq` | $\nsucc$ `\nsucc`| $\subsetneq$ `\subsetneq` |
|
|
||||||
| $\gnsim$ `\gnsim` | $\nleqq$ `\nleqq` | $\nsucceq$ `\nsucceq` | $\subsetneqq$ `\subsetneqq` |
|
|
||||||
| $\gvertneqq$ `\gvertneqq` | $\nleqslant$ `\nleqslant`| $\nsupseteq$ `\nsupseteq` | $\succnapprox$ `\succnapprox`|
|
|
||||||
| $\lnapprox$ `\lnapprox` | $\nless$ `\nless` | $\nsupseteqq$ `\nsupseteqq` | $\succneqq$ `\succneqq`|
|
|
||||||
| $\lneq$ `\lneq`| $\nmid$ `\nmid` | $\ntriangleleft$ `\ntriangleleft` | $\succnsim$ `\succnsim`|
|
|
||||||
| $\lneqq$ `\lneqq` | $\notin$ `\notin` | $\ntrianglelefteq$ `\ntrianglelefteq` | $\supsetneq$ `\supsetneq` |
|
|
||||||
| $\lnsim$ `\lnsim` | $\notni$ `\notni` | $\ntriangleright$ `\ntriangleright`| $\supsetneqq$ `\supsetneqq` |
|
|
||||||
| $\lvertneqq$ `\lvertneqq` | $\nparallel$ `\nparallel`| $\ntrianglerighteq$ `\ntrianglerighteq` | $\varsubsetneq$ `\varsubsetneq` |
|
|
||||||
| $\ncong$ `\ncong` | $\nprec$ `\nprec` | $\nvdash$ `\nvdash` | $\varsubsetneqq$ `\varsubsetneqq` |
|
|
||||||
| $\ne$ `\ne` | $\npreceq$ `\npreceq` | $\nvDash$ `\nvDash` | $\varsupsetneq$ `\varsupsetneq` |
|
|
||||||
| $\neq$ `\neq` | $\nshortmid$ `\nshortmid`| $\nVDash$ `\nVDash` | $\varsupsetneqq$ `\varsupsetneqq` |
|
|
||||||
| $\ngeq$ `\ngeq`| $\nshortparallel$ `\nshortparallel` | $\nVdash$ `\nVdash` |
|
|
||||||
| $\ngeqq$ `\ngeqq` | $\nsim$ `\nsim` | $\precnapprox$ `\precnapprox`|
|
|
||||||
|
|
||||||
Direct Input: $∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌$
|
|
||||||
|
|
||||||
### Arrows
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|$\circlearrowleft$ `\circlearrowleft`|$\leftharpoonup$ `\leftharpoonup`|$\rArr$ `\rArr`
|
|
||||||
|$\circlearrowright$ `\circlearrowright`|$\leftleftarrows$ `\leftleftarrows`|$\rarr$ `\rarr`
|
|
||||||
|$\curvearrowleft$ `\curvearrowleft`|$\leftrightarrow$ `\leftrightarrow`|$\restriction$ `\restriction`
|
|
||||||
|$\curvearrowright$ `\curvearrowright`|$\Leftrightarrow$ `\Leftrightarrow`|$\rightarrow$ `\rightarrow`
|
|
||||||
|$\Darr$ `\Darr`|$\leftrightarrows$ `\leftrightarrows`|$\Rightarrow$ `\Rightarrow`
|
|
||||||
|$\dArr$ `\dArr`|$\leftrightharpoons$ `\leftrightharpoons`|$\rightarrowtail$ `\rightarrowtail`
|
|
||||||
|$\darr$ `\darr`|$\leftrightsquigarrow$ `\leftrightsquigarrow`|$\rightharpoondown$ `\rightharpoondown`
|
|
||||||
|$\dashleftarrow$ `\dashleftarrow`|$\Lleftarrow$ `\Lleftarrow`|$\rightharpoonup$ `\rightharpoonup`
|
|
||||||
|$\dashrightarrow$ `\dashrightarrow`|$\longleftarrow$ `\longleftarrow`|$\rightleftarrows$ `\rightleftarrows`
|
|
||||||
|$\downarrow$ `\downarrow`|$\Longleftarrow$ `\Longleftarrow`|$\rightleftharpoons$ `\rightleftharpoons`
|
|
||||||
|$\Downarrow$ `\Downarrow`|$\longleftrightarrow$ `\longleftrightarrow`|$\rightrightarrows$ `\rightrightarrows`
|
|
||||||
|$\downdownarrows$ `\downdownarrows`|$\Longleftrightarrow$ `\Longleftrightarrow`|$\rightsquigarrow$ `\rightsquigarrow`
|
|
||||||
|$\downharpoonleft$ `\downharpoonleft`|$\longmapsto$ `\longmapsto`|$\Rrightarrow$ `\Rrightarrow`
|
|
||||||
|$\downharpoonright$ `\downharpoonright`|$\longrightarrow$ `\longrightarrow`|$\Rsh$ `\Rsh`
|
|
||||||
|$\gets$ `\gets`|$\Longrightarrow$ `\Longrightarrow`|$\searrow$ `\searrow`
|
|
||||||
|$\Harr$ `\Harr`|$\looparrowleft$ `\looparrowleft`|$\swarrow$ `\swarrow`
|
|
||||||
|$\hArr$ `\hArr`|$\looparrowright$ `\looparrowright`|$\to$ `\to`
|
|
||||||
|$\harr$ `\harr`|$\Lrarr$ `\Lrarr`|$\twoheadleftarrow$ `\twoheadleftarrow`
|
|
||||||
|$\hookleftarrow$ `\hookleftarrow`|$\lrArr$ `\lrArr`|$\twoheadrightarrow$ `\twoheadrightarrow`
|
|
||||||
|$\hookrightarrow$ `\hookrightarrow`|$\lrarr$ `\lrarr`|$\Uarr$ `\Uarr`
|
|
||||||
|$\iff$ `\iff`|$\Lsh$ `\Lsh`|$\uArr$ `\uArr`
|
|
||||||
|$\impliedby$ `\impliedby`|$\mapsto$ `\mapsto`|$\uarr$ `\uarr`
|
|
||||||
|$\implies$ `\implies`|$\nearrow$ `\nearrow`|$\uparrow$ `\uparrow`
|
|
||||||
|$\Larr$ `\Larr`|$\nleftarrow$ `\nleftarrow`|$\Uparrow$ `\Uparrow`
|
|
||||||
|$\lArr$ `\lArr`|$\nLeftarrow$ `\nLeftarrow`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$\larr$ `\larr`|$\nleftrightarrow$ `\nleftrightarrow`|$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\leadsto$ `\leadsto`|$\nLeftrightarrow$ `\nLeftrightarrow`|$\upharpoonleft$ `\upharpoonleft`
|
|
||||||
|$\leftarrow$ `\leftarrow`|$\nrightarrow$ `\nrightarrow`|$\upharpoonright$ `\upharpoonright`
|
|
||||||
|$\Leftarrow$ `\Leftarrow`|$\nRightarrow$ `\nRightarrow`|$\upuparrows$ `\upuparrows`
|
|
||||||
|$\leftarrowtail$ `\leftarrowtail`|$\nwarrow$ `\nwarrow`
|
|
||||||
|$\leftharpoondown$ `\leftharpoondown`|$\Rarr$ `\Rarr`
|
|
||||||
|
|
||||||
Direct Input: $← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼$ ↽
|
|
||||||
|
|
||||||
**Extensible Arrows**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------------------------------------|:-----
|
|
||||||
|$\xleftarrow{abc}$ `\xleftarrow{abc}` |$\xrightarrow[under]{over}$ `\xrightarrow[under]{over}`
|
|
||||||
|$\xLeftarrow{abc}$ `\xLeftarrow{abc}` |$\xRightarrow{abc}$ `\xRightarrow{abc}`
|
|
||||||
|$\xleftrightarrow{abc}$ `\xleftrightarrow{abc}` |$\xLeftrightarrow{abc}$ `\xLeftrightarrow{abc}`
|
|
||||||
|$\xhookleftarrow{abc}$ `\xhookleftarrow{abc}` |$\xhookrightarrow{abc}$ `\xhookrightarrow{abc}`
|
|
||||||
|$\xtwoheadleftarrow{abc}$ `\xtwoheadleftarrow{abc}` |$\xtwoheadrightarrow{abc}$ `\xtwoheadrightarrow{abc}`
|
|
||||||
|$\xleftharpoonup{abc}$ `\xleftharpoonup{abc}` |$\xrightharpoonup{abc}$ `\xrightharpoonup{abc}`
|
|
||||||
|$\xleftharpoondown{abc}$ `\xleftharpoondown{abc}` |$\xrightharpoondown{abc}$ `\xrightharpoondown{abc}`
|
|
||||||
|$\xleftrightharpoons{abc}$ `\xleftrightharpoons{abc}`|$\xrightleftharpoons{abc}$ `\xrightleftharpoons{abc}`
|
|
||||||
|$\xtofrom{abc}$ `\xtofrom{abc}` |$\xmapsto{abc}$ `\xmapsto{abc}`
|
|
||||||
|$\xlongequal{abc}$ `\xlongequal{abc}`
|
|
||||||
|
|
||||||
Extensible arrows all can take an optional argument in the same manner<br>as `\xrightarrow[under]{over}`.
|
|
||||||
|
|
||||||
## Style, Color, Size, and Font
|
|
||||||
|
|
||||||
**Class Assignment**
|
|
||||||
|
|
||||||
`\mathbin` `\mathclose` `\mathinner` `\mathop`<br>
|
|
||||||
`\mathopen` `\mathord` `\mathpunct` `\mathrel`
|
|
||||||
|
|
||||||
**Color**
|
|
||||||
|
|
||||||
$\color{blue} F=ma$ `\color{blue} F=ma`
|
|
||||||
|
|
||||||
Note that KaTeX `\color` acts like a switch. This aligns with LaTeX and differs from MathJax.
|
|
||||||
Other KaTeX color functions expect the content to be a function argument:
|
|
||||||
|
|
||||||
$\textcolor{blue}{F=ma}$ `\textcolor{blue}{F=ma}`<br>
|
|
||||||
$\textcolor{#228B22}{F=ma}$ `\textcolor{#228B22}{F=ma}`<br>
|
|
||||||
$\colorbox{aqua}{A}$ `\colorbox{aqua}{A}`<br>
|
|
||||||
$\fcolorbox{red}{aqua}{A}$ `\fcolorbox{red}{aqua}{A}`
|
|
||||||
|
|
||||||
For color definition, KaTeX color functions will accept the standard HTML [predefined color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords). They will also accept an RGB argument in CSS hexadecimal style. The "#" is optional before a six-digit specification.
|
|
||||||
|
|
||||||
**Font**
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:-----
|
|
||||||
|$\mathrm{Ab0}$ `\mathrm{Ab0}` |$\mathbf{Ab0}$ `\mathbf{Ab0}` |$\mathit{Ab}$ `\mathit{Ab}`
|
|
||||||
|$\mathnormal{Ab0}$ `\mathnormal{Ab0}`|$\textbf{Ab0}$ `\textbf{Ab0}` |$\textit{Ab}$ `\textit{Ab}`
|
|
||||||
|$\textrm{Ab0}$ `\textrm{Ab0}` |$\bf Ab0$ `\bf Ab0` |$\it Ab$ `\it Ab`
|
|
||||||
|$\rm Ab0$ `\rm Ab0` |$\bold{Ab0}$ `\bold{Ab0}`|$\Bbb{AB}$ `\Bbb{AB}`
|
|
||||||
|$\textnormal{Ab0}$ `\textnormal{Ab0}`|$\boldsymbol{Ab}$ `\boldsymbol{Ab}`|$\mathbb{AB}$ `\mathbb{AB}`
|
|
||||||
|$\text{Ab0}$ `\text{Ab0}` |$\bm{Ab}$ `\bm{Ab}` |$\frak{Ab0}$ `\frak{Ab0}`
|
|
||||||
|$\mathsf{Ab0}$ `\mathsf{Ab0}` |$\mathtt{Ab0}$ `\mathtt{Ab0}` |$\mathfrak{Ab0}$ `\mathfrak{Ab0}`
|
|
||||||
|$\textsf{Ab0}$ `\textsf{Ab0}` |$\texttt{Ab0}$ `\texttt{Ab0}` |$\mathcal{AB0}$ `\mathcal{AB0}`
|
|
||||||
|$\sf Ab0$ `\sf Ab0` |$\tt Ab0$ `\tt Ab0` |$\mathscr{AB}$ `\mathscr{AB}`
|
|
||||||
|
|
||||||
One can stack font family, font weight, and font shape by using the `\textXX` versions of the font functions. So `\textsf{\textbf{H}}` will produce $\textsf{\textbf{H}}$. The other versions do not stack, e.g., `\mathsf{\mathbf{H}}` will produce $\mathsf{\mathbf{H}}$.
|
|
||||||
|
|
||||||
In cases where KaTeX fonts do not have a bold glyph, `\pmb` can simulate one. For example, `\pmb{\mu}` renders as : $\pmb{\mu}$
|
|
||||||
|
|
||||||
**Size**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------|:-----
|
|
||||||
|$\Huge AB$ `\Huge AB` |$\normalsize AB$ `\normalsize AB`
|
|
||||||
|$\huge AB$ `\huge AB` |$\small AB$ `\small AB`
|
|
||||||
|$\LARGE AB$ `\LARGE AB`|$\footnotesize AB$ `\footnotesize AB`
|
|
||||||
|$\Large AB$ `\Large AB`|$\scriptsize AB$ `\scriptsize AB`
|
|
||||||
|$\large AB$ `\large AB`|$\tiny AB$ `\tiny AB`
|
|
||||||
|
|
||||||
|
|
||||||
**Style**
|
|
||||||
|
|
||||||
||
|
|
||||||
|:-------------------------------------------------------|
|
|
||||||
|$\displaystyle\sum_{i=1}^n$ `\displaystyle\sum_{i=1}^n`
|
|
||||||
|$\textstyle\sum_{i=1}^n$ `\textstyle\sum_{i=1}^n`
|
|
||||||
|$\scriptstyle x$ `\scriptstyle x` (The size of a first sub/superscript)
|
|
||||||
|$\scriptscriptstyle x$ `\scriptscriptstyle x` (The size of subsequent sub/superscripts)
|
|
||||||
|$\lim\limits_x$ `\lim\limits_x`
|
|
||||||
|$\lim\nolimits_x$ `\lim\nolimits_x`
|
|
||||||
|$\verb!x^2!$ `\verb!x^2!`
|
|
||||||
|
|
||||||
`\text{…}` will accept nested `$…$` fragments and render them in math mode.
|
|
||||||
|
|
||||||
## Symbols and Punctuation
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|`% comment`|$\dots$ `\dots`|$\KaTeX$ `\KaTeX`
|
|
||||||
|$\%$ `\%`|$\cdots$ `\cdots`|$\LaTeX$ `\LaTeX`
|
|
||||||
|$\#$ `\#`|$\ddots$ `\ddots`|$\TeX$ `\TeX`
|
|
||||||
|$\&$ `\&`|$\ldots$ `\ldots`|$\nabla$ `\nabla`
|
|
||||||
|$\_$ `\_`|$\vdots$ `\vdots`|$\infty$ `\infty`
|
|
||||||
|$\text{\textunderscore}$ `\text{\textunderscore}`|$\dotsb$ `\dotsb`|$\infin$ `\infin`
|
|
||||||
|$\text{--}$ `\text{--}`|$\dotsc$ `\dotsc`|$\checkmark$ `\checkmark`
|
|
||||||
|$\text{\textendash}$ `\text{\textendash}`|$\dotsi$ `\dotsi`|$\dag$ `\dag`
|
|
||||||
|$\text{---}$ `\text{---}`|$\dotsm$ `\dotsm`|$\dagger$ `\dagger`
|
|
||||||
|$\text{\textemdash}$ `\text{\textemdash}`|$\dotso$ `\dotso`|$\text{\textdagger}$ `\text{\textdagger}`
|
|
||||||
|$\text{\textasciitilde}$ `\text{\textasciitilde}`|$\sdot$ `\sdot`|$\ddag$ `\ddag`
|
|
||||||
|$\text{\textasciicircum}$ `\text{\textasciicircum}`|$\mathellipsis$ `\mathellipsis`|$\ddagger$ `\ddagger`
|
|
||||||
|$`$ <code>`</code>|$\text{\textellipsis}$ `\text{\textellipsis}`|$\text{\textdaggerdbl}$ `\text{\textdaggerdbl}`
|
|
||||||
|$\text{\textquoteleft}$ `text{\textquoteleft}`|$\Box$ `\Box`|$\Dagger$ `\Dagger`
|
|
||||||
|$\lq$ `\lq`|$\square$ `\square`|$\angle$ `\angle`
|
|
||||||
|$\text{\textquoteright}$ `\text{\textquoteright}`|$\blacksquare$ `\blacksquare`|$\measuredangle$ `\measuredangle`
|
|
||||||
|$\rq$ `\rq`|$\triangle$ `\triangle`|$\sphericalangle$ `\sphericalangle`
|
|
||||||
|$\text{\textquotedblleft}$ `\text{\textquotedblleft}`|$\triangledown$ `\triangledown`|$\top$ `\top`
|
|
||||||
|$"$ `"`|$\triangleleft$ `\triangleleft`|$\bot$ `\bot`
|
|
||||||
|$\text{\textquotedblright}$ `\text{\textquotedblright}`|$\triangleright$ `\triangleright`|$\$$ `\$`
|
|
||||||
|$\colon$ `\colon`|$\bigtriangledown$ `\bigtriangledown`|$\text{\textdollar}$ `\text{\textdollar}`
|
|
||||||
|$\backprime$ `\backprime`|$\bigtriangleup$ `\bigtriangleup`|$\pounds$ `\pounds`
|
|
||||||
|$\prime$ `\prime`|$\blacktriangle$ `\blacktriangle`|$\mathsterling$ `\mathsterling`
|
|
||||||
|$\text{\textless}$ `\text{\textless}`|$\blacktriangledown$ `\blacktriangledown`|$\text{\textsterling}$ `\text{\textsterling}`
|
|
||||||
|$\text{\textgreater}$ `\text{\textgreater}`|$\blacktriangleleft$ `\blacktriangleleft`|$\yen$ `\yen`
|
|
||||||
|$\text{\textbar}$ `\text{\textbar}`|$\blacktriangleright$ `\blacktriangleright`|$\surd$ `\surd`
|
|
||||||
|$\text{\textbardbl}$ `\text{\textbardbl}`|$\diamond$ `\diamond`|$\degree$ `\degree`
|
|
||||||
|$\text{\textbraceleft}$ `\text{\textbraceleft}`|$\Diamond$ `\Diamond`|$\text{\textdegree}$ `\text{\textdegree}`
|
|
||||||
|$\text{\textbraceright}$ `\text{\textbraceright}`|$\lozenge$ `\lozenge`|$\mho$ `\mho`
|
|
||||||
|$\text{\textbackslash}$ `\text{\textbackslash}`|$\blacklozenge$ `\blacklozenge`|$\diagdown$ `\diagdown`
|
|
||||||
|$\text{\P}$ `\text{\P}`|$\star$ `\star`|$\diagup$ `\diagup`
|
|
||||||
|$\text{\S}$ `\text{\S}`|$\bigstar$ `\bigstar`|$\flat$ `\flat`
|
|
||||||
|$\text{\sect}$ `\text{\sect}`|$\clubsuit$ `\clubsuit`|$\natural$ `\natural`
|
|
||||||
|$\copyright$ `\copyright`|$\clubs$ `\clubs`|$\sharp$ `\sharp`
|
|
||||||
|$\circledR$ `\circledR`|$\diamondsuit$ `\diamondsuit`|$\heartsuit$ `\heartsuit`
|
|
||||||
|$\text{\textregistered}$ `\text{\textregistered}`|$\diamonds$ `\diamonds`|$\hearts$ `\hearts`
|
|
||||||
|$\circledS$ `\circledS`|$\spadesuit$ `\spadesuit`|$\spades$ `\spades`
|
|
||||||
|$\text{\textcircled a}$ `\text{\textcircled a}`|$\maltese$ `\maltese`||
|
|
||||||
|
|
||||||
Direct Input: $£ ¥ ∇ ∞ · ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ … ⋮ ⋯ ⋱ !$ ‼
|
|
||||||
|
|
||||||
## Units
|
|
||||||
|
|
||||||
In KaTeX, units are proportioned as they are in TeX.<br>
|
|
||||||
KaTeX units are different than CSS units.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="unit-tbl">
|
|
||||||
|
|
||||||
| KaTeX Unit | Value | KaTeX Unit | Value |
|
|
||||||
|:---|:---------------------|:---|:----------------|
|
|
||||||
| em | CSS em | bp | 1/72 inch × F × G|
|
|
||||||
| ex | CSS ex | pc | 12 KaTeX pt|
|
|
||||||
| mu | 1/18 CSS em | dd | 1238/1157 KaTeX pt |
|
|
||||||
| pt | 1/72.27 inch × F × G | cc | 14856/1157 KaTeX pt |
|
|
||||||
| mm | 1 mm × F × G | nd | 685/642 KaTeX pt |
|
|
||||||
| cm | 1 cm × F × G | nc | 1370/107 KaTeX pt|
|
|
||||||
| in | 1 inch × F × G | sp | 1/65536 KaTeX pt |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
where:
|
|
||||||
|
|
||||||
<div style="margin-left: 1.5em;">
|
|
||||||
|
|
||||||
F = (font size of surrounding HTML text)/(10 pt)
|
|
||||||
|
|
||||||
G = 1.21 by default, because KaTeX font-size is normally 1.21 × the surrounding font size. This value [can be overridden](font.md#font-size-and-lengths) by the CSS of an HTML page.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
The effect of style and size:
|
|
||||||
|
|
||||||
<div class="katex-cards" id="unit-blocks">
|
|
||||||
|
|
||||||
| Unit | textstyle | scriptscript | huge |
|
|
||||||
|:------:|:-----------------:|:------------:|:------:|
|
|
||||||
|em or ex|$\rule{1em}{1em}$ |$\scriptscriptstyle\rule{1em}{1em}$ |$\huge\rule{1em}{1em}$
|
|
||||||
| mu |$\rule{18mu}{18mu}$|$\scriptscriptstyle\rule{18mu}{18mu}$|$\huge\rule{18mu}{18mu}$
|
|
||||||
| others |$\rule{10pt}{10pt}$|$\scriptscriptstyle\rule{10pt}{10pt}$|$\huge\rule{10pt}{10pt}$
|
|
||||||
|
|
||||||
</div>
|
|
@@ -1,110 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.2-autorender
|
|
||||||
title: Auto-render Extension
|
|
||||||
original_id: autorender
|
|
||||||
---
|
|
||||||
This is an extension to automatically render all of the math inside of text. It
|
|
||||||
searches all of the text nodes within a given element for the given delimiters,
|
|
||||||
ignoring certain tags like `<pre>`, and renders the math in place.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
This extension isn't part of KaTeX proper, so the script needs to be included
|
|
||||||
(via a `<script>` tag) in the page along with KaTeX itself. For example,
|
|
||||||
using a CDN:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above, the [`defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
indicates that the script doesn't need to execute until the page has loaded,
|
|
||||||
speeding up page rendering; and the `onload` attribute calls
|
|
||||||
`renderMathInElement` once the auto-render script loads.
|
|
||||||
|
|
||||||
Alternatively, you can call the `renderMathInElement` when (or after) the
|
|
||||||
[`DOMContentLoaded` event](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded)
|
|
||||||
fires on the document or in another deferred script.
|
|
||||||
This approach is useful for specifying or computing options, or if you don't
|
|
||||||
want to use a `defer` or `onload` attribute.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
renderMathInElement(document.body, {
|
|
||||||
// ...options...
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
ECMAScript module is also available:
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
|
|
||||||
<script type="module">
|
|
||||||
import renderMathInElement from "https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/auto-render.mjs";
|
|
||||||
renderMathInElement(document.body);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
> You can use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules. -->
|
|
||||||
|
|
||||||
## API
|
|
||||||
This extension exposes a single function, `window.renderMathInElement`, with
|
|
||||||
the following API:
|
|
||||||
|
|
||||||
```js
|
|
||||||
function renderMathInElement(elem, options)
|
|
||||||
```
|
|
||||||
|
|
||||||
`elem` is an HTML DOM element. The function will recursively search for text
|
|
||||||
nodes inside this element and render the math in them.
|
|
||||||
|
|
||||||
`options` is an optional object argument that can have the same keys as [the
|
|
||||||
object passed to `katex.render`](https://github.com/KaTeX/KaTeX/#rendering-options),
|
|
||||||
in addition to several auto-render-specific keys:
|
|
||||||
|
|
||||||
- `delimiters`: This is a list of delimiters to look for math. Each delimiter
|
|
||||||
has three properties:
|
|
||||||
|
|
||||||
- `left`: A string which starts the math expression (i.e. the left delimiter).
|
|
||||||
- `right`: A string which ends the math expression (i.e. the right delimiter).
|
|
||||||
- `display`: A boolean of whether the math in the expression should be
|
|
||||||
rendered in display mode or not.
|
|
||||||
|
|
||||||
The default value is:
|
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{left: "$$", right: "$$", display: true},
|
|
||||||
{left: "\\(", right: "\\)", display: false},
|
|
||||||
{left: "\\[", right: "\\]", display: true}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
- `ignoredTags`: This is a list of DOM node types to ignore when recursing
|
|
||||||
through. The default value is
|
|
||||||
`["script", "noscript", "style", "textarea", "pre", "code"]`.
|
|
||||||
|
|
||||||
- `ignoredClasses`: This is a list of DOM node class names to ignore when
|
|
||||||
recursing through. By default, this value is not set.
|
|
||||||
|
|
||||||
- `errorCallback`: A callback method returning a message and an error stack
|
|
||||||
in case of an critical error during rendering. The default uses `console.error`.
|
|
||||||
|
|
||||||
- `preProcess`: A callback function, `(math: string) => string`, used to process
|
|
||||||
math expressions before rendering.
|
|
||||||
|
|
||||||
The `displayMode` property of the options object is ignored, and is
|
|
||||||
instead taken from the `display` key of the corresponding entry in the
|
|
||||||
`delimiters` key.
|
|
||||||
|
|
||||||
The same `options.macros` object (which defaults to an empty object `{}`)
|
|
||||||
is passed into several calls to `katex.render`, so that consecutive equations
|
|
||||||
can build up shared macros by `\gdef`.
|
|
@@ -1,99 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.2-browser
|
|
||||||
title: Browser
|
|
||||||
original_id: browser
|
|
||||||
---
|
|
||||||
> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11.
|
|
||||||
|
|
||||||
## Global
|
|
||||||
If you include the `katex.js` directly, the `katex` object will be available as
|
|
||||||
a global variable.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.css" integrity="sha384-+MsSfd29vjUzcyqYURxcmpWGtqoSHBy+QdEJNLEslXQftxojQv0k6BGDqUNp9GtA" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.js" integrity="sha384-5zUJgoXUAOXAoLeyJm2Ja3vbN3VCnoc2w0rG7dyC2jjGwD8PINuWoDHJ3gNdkOxj" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides minified versions:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
The loading of scripts are [deferred using `defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to speed up page rendering. The `katex` object will be available after
|
|
||||||
[`DOMContentLoaded` event is fired on the `document`](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded).
|
|
||||||
If you do not use `defer`, `katex` object will be available after corresponding
|
|
||||||
`script` tag.
|
|
||||||
|
|
||||||
If KaTeX is not used immediately or not critical, it is possible to load KaTeX
|
|
||||||
asynchronously. Add [`async` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to `script` and use [`rel="preload"` and `onload` attribute](https://github.com/filamentgroup/loadCSS)
|
|
||||||
on `link`.
|
|
||||||
|
|
||||||
You can prefetch KaTeX fonts to prevent FOUT or FOIT. Use [Font Loading API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API)
|
|
||||||
or [Web Font Loader](https://github.com/typekit/webfontloader):
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
window.WebFontConfig = {
|
|
||||||
custom: {
|
|
||||||
families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7',
|
|
||||||
'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script',
|
|
||||||
'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3',
|
|
||||||
'KaTeX_Size4', 'KaTeX_Typewriter'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use [`rel="preload"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content).
|
|
||||||
Add `<link rel="preload" href=(path to WOFF2 font) as="font" type="font/woff2" crossorigin="anonymous">`
|
|
||||||
to `head`. Note that [only few browsers support it](https://caniuse.com/#feat=link-rel-preload)
|
|
||||||
and they all support WOFF2 so preloading WOFF2 fonts is enough.
|
|
||||||
|
|
||||||
See [Google Web Fundamentals - Web Font Optimization](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/webfont-optimization)
|
|
||||||
for more detail.
|
|
||||||
|
|
||||||
## Module Loaders
|
|
||||||
### AMD
|
|
||||||
```html
|
|
||||||
<script type="text/javascript">
|
|
||||||
require([
|
|
||||||
"https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.js",
|
|
||||||
], katex => {
|
|
||||||
...
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.css" integrity="sha384-+MsSfd29vjUzcyqYURxcmpWGtqoSHBy+QdEJNLEslXQftxojQv0k6BGDqUNp9GtA" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
### ECMAScript module
|
|
||||||
```html
|
|
||||||
<script type="module" type="text/javascript">
|
|
||||||
import katex from 'https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.mjs';
|
|
||||||
...
|
|
||||||
</script>
|
|
||||||
<script nomodule defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.js" integrity="sha384-5zUJgoXUAOXAoLeyJm2Ja3vbN3VCnoc2w0rG7dyC2jjGwD8PINuWoDHJ3gNdkOxj" crossorigin="anonymous"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.css" integrity="sha384-+MsSfd29vjUzcyqYURxcmpWGtqoSHBy+QdEJNLEslXQftxojQv0k6BGDqUNp9GtA" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
> Use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules.
|
|
||||||
|
|
||||||
## Download & Host Things Yourself
|
|
||||||
Download a [KaTeX release](https://github.com/KaTeX/KaTeX/releases),
|
|
||||||
copy `katex.js`, `katex.css`
|
|
||||||
(or `katex.min.js` and `katex.min.css` to use minified versions),
|
|
||||||
and the `fonts` directory, and include or import it like above.
|
|
||||||
|
|
||||||
You can also build from source. See [Building from Source](node.md#building-from-source)
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
## Bundler
|
|
||||||
[Use Node.js package managers to install KaTeX and import it](node.md) in your
|
|
||||||
project. Then bundle using bundlers like [webpack](https://webpack.js.org/) or
|
|
||||||
[rollup.js](https://rollupjs.org/). Note that you have to bundle the stylesheet
|
|
||||||
(`katex.css`) or include it manually.
|
|
@@ -1,51 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.2-libs
|
|
||||||
title: Extensions & Libraries
|
|
||||||
original_id: libs
|
|
||||||
---
|
|
||||||
## Extensions
|
|
||||||
|
|
||||||
These extensions are provided by KaTeX.
|
|
||||||
|
|
||||||
- [Auto-render](autorender.md): Automatically renders all of the math inside text
|
|
||||||
- [Copy-tex](https://github.com/Khan/KaTeX/tree/master/contrib/copy-tex): When selecting and copying KaTeX-rendered elements, copies their LaTeX source to the clipboard
|
|
||||||
- [`math/tex` Custom Script Type](https://github.com/Khan/KaTeX/tree/master/contrib/mathtex-script-type): Automatically displays LaTeX math inside `script` tags with `type=math/tex`
|
|
||||||
- [mhchem](https://github.com/Khan/KaTeX/tree/master/contrib/mhchem): Write beautiful chemical equations easily
|
|
||||||
|
|
||||||
## Libraries
|
|
||||||
|
|
||||||
These libraries are maintained by third-parties.
|
|
||||||
|
|
||||||
### Angular2+
|
|
||||||
- [ng-katex](https://github.com/garciparedes/ng-katex): Angular module to write beautiful math expressions with TeX syntax boosted by KaTeX library
|
|
||||||
|
|
||||||
### iOS
|
|
||||||
- [KaTeX-iOS](https://github.com/ianarawjo/KaTeX-iOS): iOS UIView that renders TeX expressions with KaTeX
|
|
||||||
|
|
||||||
### Android
|
|
||||||
- [KaTeXView](https://github.com/judemanutd/KaTeXView): An android library that uses Khan Academy KaTeX for TeX math rendering.
|
|
||||||
|
|
||||||
### React
|
|
||||||
- [react-latex](https://github.com/zzish/react-latex): React component to render latex strings, based on KaTeX
|
|
||||||
- [react-katex](https://github.com/talyssonoc/react-katex): React components that use KaTeX to typeset math expressions
|
|
||||||
|
|
||||||
### Ruby
|
|
||||||
|
|
||||||
- [katex-ruby](https://github.com/glebm/katex-ruby): Provides server-side rendering and integration with popular Ruby web frameworks (Rails, Hanami, and anything that uses Sprockets).
|
|
||||||
|
|
||||||
### Vue
|
|
||||||
- [vue-katex](https://github.com/lucpotage/vue-katex): Vue plugin to render TeX expressions using KaTeX.
|
|
||||||
|
|
||||||
### AsciiMath
|
|
||||||
|
|
||||||
If you want to render math written in [AsciiMath](http://asciimath.org/),
|
|
||||||
you'll need to first convert AsciiMath into LaTeX input, then call KaTeX.
|
|
||||||
|
|
||||||
- [asciimath2tex](https://github.com/christianp/asciimath2tex): Converts AsciiMath to TeX, with KaTeX in mind
|
|
||||||
|
|
||||||
### Canvas LaTeX
|
|
||||||
|
|
||||||
- [canvas-latex](https://github.com/CurriculumAssociates/canvas-latex): Renders mathematical expressions on HTML5's canvas element. Supports popular libraries like: CreateJS, and PIXI.
|
|
||||||
|
|
||||||
### Web-Components
|
|
||||||
- [katex-element](https://github.com/georges-gomes/katex-element): KaTeX wrapped in a custom element. Simply use `<katex-element>` in HTML - framework independent.
|
|
@@ -1,79 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.2-node
|
|
||||||
title: Node.js
|
|
||||||
original_id: node
|
|
||||||
---
|
|
||||||
## Installation
|
|
||||||
### npm
|
|
||||||
Install with `npm`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install katex
|
|
||||||
# or globally
|
|
||||||
npm install -g katex
|
|
||||||
```
|
|
||||||
|
|
||||||
### Yarn
|
|
||||||
Install with `Yarn`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn add katex
|
|
||||||
# or globally
|
|
||||||
yarn global add katex
|
|
||||||
```
|
|
||||||
|
|
||||||
### Building from Source
|
|
||||||
To build you will need Git, Node.js 8 or later, and Yarn.
|
|
||||||
|
|
||||||
Clone a copy of the GitHub source repository:
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/KaTeX/KaTeX.git
|
|
||||||
cd KaTeX
|
|
||||||
```
|
|
||||||
|
|
||||||
Then install dependencies and run `build` script:
|
|
||||||
```bash
|
|
||||||
yarn
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
It will automatically transpile code and include only necessary fonts for
|
|
||||||
target environments specified by [Browserslist config](https://github.com/browserslist/browserslist#environment-variables).
|
|
||||||
For example, if you are making a web app for a kiosk with Chrome 68, run
|
|
||||||
`BROWSERSLIST="Chrome 68" yarn build` and it will produce build with no
|
|
||||||
transpilation, as it fully supports ES6, and only include WOFF2 fonts.
|
|
||||||
|
|
||||||
You can override included fonts using environment variables. Set `USE_(FONT NAME)`
|
|
||||||
environment variable to `"true"` or `"false"`, to force a font type to be included
|
|
||||||
or excluded, respectively.`
|
|
||||||
|
|
||||||
If you'd like to use the built KaTeX in other projects, install the package by
|
|
||||||
specifying the path:
|
|
||||||
```bash
|
|
||||||
yarn add /path/to/KaTeX
|
|
||||||
# or using npm
|
|
||||||
npm install /path/to/KaTeX
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can manually download the package and source code from
|
|
||||||
[GitHub releases](https://github.com/KaTeX/KaTeX/releases).
|
|
||||||
|
|
||||||
## Importing
|
|
||||||
KaTeX is exported as a CommonJS module, which can be imported using `require`:
|
|
||||||
```js
|
|
||||||
const katex = require('katex');
|
|
||||||
```
|
|
||||||
|
|
||||||
If you're using a module loader, transpiler, or bundler that supports interoperability
|
|
||||||
between ECMAScript module and CommonJS module, you can use `import`:
|
|
||||||
```js
|
|
||||||
import katex from 'katex';
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides an ECMAScript module:
|
|
||||||
```js
|
|
||||||
import katex from 'katex/dist/katex.mjs'
|
|
||||||
```
|
|
||||||
|
|
||||||
> The ES module contains ES6 syntaxes and features, and may need transpiling to
|
|
||||||
use in old environments:
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,641 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.10.2-supported
|
|
||||||
title: Supported Functions
|
|
||||||
original_id: supported
|
|
||||||
---
|
|
||||||
This is a list of TeX functions supported by KaTeX. It is sorted into logical groups.
|
|
||||||
|
|
||||||
There is a similar [Support Table](support_table.md), sorted alphabetically, that lists both supported and un-supported functions.
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/static/katex.min.css"/>
|
|
||||||
<style>
|
|
||||||
p {overflow-wrap: break-word;}
|
|
||||||
table tr,
|
|
||||||
table td {
|
|
||||||
vertical-align: middle;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Accents
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------------------------|:----------------------------------------------------|:-----
|
|
||||||
|$a'$ `a'` |$\tilde{a}$ `\tilde{a}`|$\mathring{g}$ `\mathring{g}`
|
|
||||||
|$a''$ `a''`|$\widetilde{ac}$ `\widetilde{ac}` |$\overgroup{AB}$ `\overgroup{AB}`
|
|
||||||
|$a^{\prime}$ `a^{\prime}` |$\utilde{AB}$ `\utilde{AB}` |$\undergroup{AB}$ `\undergroup{AB}`
|
|
||||||
|$\acute{a}$ `\acute{a}`|$\vec{F}$ `\vec{F}` |$\Overrightarrow{AB}$ `\Overrightarrow{AB}`
|
|
||||||
|$\bar{y}$ `\bar{y}` |$\overleftarrow{AB}$ `\overleftarrow{AB}`|$\overrightarrow{AB}$ `\overrightarrow{AB}`
|
|
||||||
|$\breve{a}$ `\breve{a}`|$\underleftarrow{AB}$ `\underleftarrow{AB}` |$\underrightarrow{AB}$ `\underrightarrow{AB}`
|
|
||||||
|$\check{a}$ `\check{a}`|$\overleftharpoon{ac}$ `\overleftharpoon{ac}` |$\overrightharpoon{ac}$ `\overrightharpoon{ac}`
|
|
||||||
|$\dot{a}$ `\dot{a}` |$\overleftrightarrow{AB}$ `\overleftrightarrow{AB}` |$\overbrace{AB}$ `\overbrace{AB}`
|
|
||||||
|$\ddot{a}$ `\ddot{a}` |$\underleftrightarrow{AB}$ `\underleftrightarrow{AB}`|$\underbrace{AB}$ `\underbrace{AB}`
|
|
||||||
|$\grave{a}$ `\grave{a}`|$\overline{AB}$ `\overline{AB}` |$\overlinesegment{AB}$ `\overlinesegment{AB}`
|
|
||||||
|$\hat{\theta}$ `\hat{\theta}`|$\underline{AB}$ `\underline{AB}` |$\underlinesegment{AB}$ `\underlinesegment{AB}`
|
|
||||||
|$\widehat{ac}$ `\widehat{ac}`|$\widecheck{ac}$ `\widecheck{ac}` |
|
|
||||||
|
|
||||||
***Accent functions inside \\text{…}***
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:-----
|
|
||||||
|$\text{\'{a}}$ `\'{a}`|$\text{\~{a}}$ `\~{a}`|$\text{\.{a}}$ `\.{a}`|$\text{\H{a}}$ `\H{a}`
|
|
||||||
|$\text{\`{a}}$ <code>\\`{a}</code>|$\text{\={a}}$ `\={a}`|$\text{\"{a}}$ `\"{a}`|$\text{\v{a}}$ `\v{a}`
|
|
||||||
|$\text{\^{a}}$ `\^{a}`|$\text{\u{a}}$ `\u{a}`|$\text{\r{a}}$ `\r{a}`|
|
|
||||||
|
|
||||||
See also [letters](#letters)
|
|
||||||
|
|
||||||
## Delimiters
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:-----------------------------------|:---------------------------------------|:----------|:-------------------------------------------------------|:-----
|
|
||||||
|$(~)$ `( )` |$\lparen~\rparen$ `\lparen`<br>$~~~~$`\rparen`|$⌈~⌉$ `⌈ ⌉`|$\lceil~\rceil$ `\lceil`<br>$~~~~~$`\rceil` |$\uparrow$ `\uparrow`
|
|
||||||
|$[~]$ `[ ]` |$\lbrack~\rbrack$ `\lbrack`<br>$~~~~$`\rbrack`|$⌊~⌋$ `⌊ ⌋`|$\lfloor~\rfloor$ `\lfloor`<br>$~~~~~$`\rfloor` |$\downarrow$ `\downarrow`
|
|
||||||
|$\{ \}$ `\{ \}`|$\lbrace \rbrace$ `\lbrace`<br>$~~~~$`\rbrace`|$⎰⎱$ `⎰⎱` |$\lmoustache \rmoustache$ `\lmoustache`<br>$~~~~$`\rmoustache`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$⟨~⟩$ `⟨ ⟩` |$\langle~\rangle$ `\langle`<br>$~~~~$`\rangle`|$⟮~⟯$ `⟮ ⟯`|$\lgroup~\rgroup$ `\lgroup`<br>$~~~~~$`\rgroup` |$\Uparrow$ `\Uparrow`
|
|
||||||
|$\vert$ <code>|</code> |$\vert$ `\vert` |$┌ ┐$ `┌ ┐`|$\ulcorner \urcorner$ `\ulcorner`<br>$~~~~$`\urcorner` |$\Downarrow$ `\Downarrow`
|
|
||||||
|$\Vert$ <code>\|</code> |$\Vert$ `\Vert` |$└ ┘$ `└ ┘`|$\llcorner \lrcorner$ `\llcorner`<br>$~~~~$`\lrcorner` |$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\lvert~\rvert$ `\lvert`<br>$~~~~$`\rvert`|$\lVert~\rVert$ `\lVert`<br>$~~~~~$`\rVert` |`\left.`| `\right.` |$\backslash$ `\backslash`
|
|
||||||
|$\lang~\rang$ `\lang`<br>$~~~~$`\rang`|$\lt~\gt$ `\lt \gt`|$⟦~⟧$ `⟦ ⟧`|$\llbracket~\rrbracket$ `\llbracket`<br>$~~~~$`\rrbracket`|$\lBrace~\rBrace$ `\lBrace \rBrace`
|
|
||||||
|
|
||||||
**Delimiter Sizing**
|
|
||||||
|
|
||||||
$\left(\LARGE{AB}\right)$ `\left(\LARGE{AB}\right)`
|
|
||||||
|
|
||||||
$( \big( \Big( \bigg( \Bigg($ `( \big( \Big( \bigg( \Bigg(`
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:--------|:------|:--------|:-------|:------|
|
|
||||||
|`\left` |`\big` |`\bigl` |`\bigm` |`\bigr`
|
|
||||||
|`\middle`|`\Big` |`\Bigl` |`\Bigm` | `\Bigr`
|
|
||||||
|`\right` |`\bigg`|`\biggl` |`\biggm`|`\biggr`
|
|
||||||
| |`\Bigg`|`\Biggl` |`\Biggm`|`\Biggr`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Environments
|
|
||||||
|
|
||||||
<div class="katex-cards" id="environments">
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:--------
|
|
||||||
|$\begin{matrix} a & b \\ c & d \end{matrix}$ | `\begin{matrix}`<br> `a & b \\`<br> `c & d`<br>`\end{matrix}` |$\begin{array}{cc}a & b\\c & d\end{array}$ | `\begin{array}{cc}`<br> `a & b \\`<br> `c & d`<br>`\end{array}`
|
|
||||||
|$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$ |`\begin{pmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{pmatrix}` |$\begin{bmatrix} a & b \\ c & d \end{bmatrix}$ | `\begin{bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{bmatrix}`
|
|
||||||
|$\begin{vmatrix} a & b \\ c & d \end{vmatrix}$ |`\begin{vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{vmatrix}` |$\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}$ |`\begin{Vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Vmatrix}`
|
|
||||||
|$\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}$ |`\begin{Bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Bmatrix}`|$\def\arraystretch{1.5}\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}$|`\def\arraystretch{1.5}`<br> `\begin{array}{c:c:c}`<br> `a & b & c \\ \hline`<br> `d & e & f \\`<br> `\hdashline`<br> `g & h & i`<br>`\end{array}`
|
|
||||||
|$\begin{aligned} a&=b+c \\ d+e&=f \end{aligned}$ |`\begin{aligned}`<br> `a&=b+c \\`<br> `d+e&=f`<br>`\end{aligned}`|$\begin{alignedat}{2}10&x+&3&y=2\\3&x+&13&y=4\end{alignedat}$ |`\begin{alignedat}{2}`<br> `10&x+ &3&y = 2 \\`<br> ` 3&x+&13&y = 4`<br>`\end{alignedat}`
|
|
||||||
|$\begin{gathered} a=b \\ e=b+c \end{gathered}$ |`\begin{gathered}`<br> `a=b \\ `<br> `e=b+c`<br>`\end{gathered}`|$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$ |`x = \begin{cases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{cases}`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
KaTeX also supports `darray` and `dcases`.
|
|
||||||
|
|
||||||
Acceptable line separators include: `\\`, `\cr`, `\\[distance]`, and `\cr[distance]`. *Distance* can be written with any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
The `{array}` environment supports `|` and `:` vertical separators.
|
|
||||||
|
|
||||||
The `{array}` environment does not yet support `\cline` or `\multicolumn`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## HTML
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------|:-------------------|
|
|
||||||
| $\href{https://katex.org/}{\KaTeX}$ | `\href{https://katex.org/}{\KaTeX}` |
|
|
||||||
| $\url{https://katex.org/}$ | `\url{https://katex.org/}` |
|
|
||||||
|
|
||||||
## Letters and Unicode
|
|
||||||
|
|
||||||
**Greek Letters**
|
|
||||||
|
|
||||||
Direct Input: $Α Β Γ Δ Ε Ζ Η Θ Ι \allowbreak Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω$
|
|
||||||
$\allowbreak α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π \allowbreak ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ$
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|---------------|-------------|-------------|---------------|
|
|
||||||
| $\Alpha$ `\Alpha` | $\Beta$ `\Beta` | $\Gamma$ `\Gamma`| $\Delta$ `\Delta`
|
|
||||||
| $\Epsilon$ `\Epsilon` | $\Zeta$ `\Zeta` | $\Eta$ `\Eta` | $\Theta$ `\Theta`
|
|
||||||
| $\Iota$ `\Iota` | $\Kappa$ `\Kappa` | $\Lambda$ `\Lambda` | $\Mu$ `\Mu`
|
|
||||||
| $\Nu$ `\Nu` | $\Xi$ `\Xi` | $\Omicron$ `\Omicron` | $\Pi$ `\Pi`
|
|
||||||
| $\Rho$ `\Rho` | $\Sigma$ `\Sigma` | $\Tau$ `\Tau` | $\Upsilon$ `\Upsilon`
|
|
||||||
| $\Phi$ `\Phi` | $\Chi$ `\Chi` | $\Psi$ `\Psi` | $\Omega$ `\Omega`
|
|
||||||
| $\varGamma$ `\varGamma`| $\varDelta$ `\varDelta` | $\varTheta$ `\varTheta` | $\varLambda$ `\varLambda` |
|
|
||||||
| $\varXi$ `\varXi`| $\varPi$ `\varPi` | $\varSigma$ `\varSigma` | $\varUpsilon$ `\varUpsilon` |
|
|
||||||
| $\varPhi$ `\varPhi` | $\varPsi$ `\varPsi`| $\varOmega$ `\varOmega` ||
|
|
||||||
| $\alpha$ `\alpha`| $\beta$ `\beta` | $\gamma$ `\gamma` | $\delta$ `\delta`|
|
|
||||||
| $\epsilon$ `\epsilon` | $\zeta$ `\zeta` | $\eta$ `\eta`| $\theta$ `\theta`|
|
|
||||||
| $\iota$ `\iota` | $\kappa$ `\kappa` | $\lambda$ `\lambda`| $\mu$ `\mu`|
|
|
||||||
| $\nu$ `\nu`| $\xi$ `\xi` | $\omicron$ `\omicron` | $\pi$ `\pi`|
|
|
||||||
| $\rho$ `\rho` | $\sigma$ `\sigma` | $\tau$ `\tau`| $\upsilon$ `\upsilon` |
|
|
||||||
| $\phi$ `\phi` | $\chi$ `\chi`| $\psi$ `\psi`| $\omega$ `\omega`|
|
|
||||||
| $\varepsilon$ `\varepsilon` | $\varkappa$ `\varkappa` | $\vartheta$ `\vartheta` | $\thetasym$ `\thetasym`
|
|
||||||
| $\varpi$ `\varpi`| $\varrho$ `\varrho` | $\varsigma$ `\varsigma` | $\varphi$ `\varphi`
|
|
||||||
| $\digamma $ `\digamma`
|
|
||||||
|
|
||||||
**Other Letters**
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:----------|:----------|:----------|:----------|:----------|
|
|
||||||
|$\imath$ `\imath`|$\nabla$ `\nabla`|$\Im$ `\Im`|$\Reals$ `\Reals`|$\text{\OE}$ `\text{\OE}`
|
|
||||||
|$\jmath$ `\jmath`|$\partial$ `\partial`|$\image$ `\image`|$\wp$ `\wp`|$\text{\o}$ `\text{\o}`
|
|
||||||
|$\aleph$ `\aleph`|$\Game$ `\Game`|$\Bbbk$ `\Bbbk`|$\weierp$ `\weierp`|$\text{\O}$ `\text{\O}`
|
|
||||||
|$\alef$ `\alef`|$\Finv$ `\Finv`|$\N$ `\N`|$\Z$ `\Z`|$\text{\ss}$ `\text{\ss}`
|
|
||||||
|$\alefsym$ `\alefsym`|$\cnums$ `\cnums`|$\natnums$ `\natnums`|$\text{\aa}$ `\text{\aa}`|$\text{\i}$ `\text{\i}`
|
|
||||||
|$\beth$ `\beth`|$\Complex$ `\Complex`|$\R$ `\R`|$\text{\AA}$ `\text{\AA}`|$\text{\j}$ `\text{\j}`
|
|
||||||
|$\gimel$ `\gimel`|$\ell$ `\ell`|$\Re$ `\Re`|$\text{\ae}$ `\text{\ae}`
|
|
||||||
|$\daleth$ `\daleth`|$\hbar$ `\hbar`|$\real$ `\real`|$\text{\AE}$ `\text{\AE}`
|
|
||||||
|$\eth$ `\eth`|$\hslash$ `\hslash`|$\reals$ `\reals`|$\text{\oe}$ `\text{\oe}`
|
|
||||||
|
|
||||||
Direct Input: $∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð$
|
|
||||||
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåçèéêëìíîïðñòóôöùúûüýþÿ
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="math-alpha">
|
|
||||||
|
|
||||||
**Unicode Mathematical Alphanumeric Symbols**
|
|
||||||
|
|
||||||
| Item | Range | Item | Range |
|
|
||||||
|-------------|---------------------|-------------------|---------------|
|
|
||||||
| Bold | $\text{𝐀-𝐙 𝐚-𝐳 𝟎-𝟗}$ | Double-struck | $\text{𝔸-}ℤ\ 𝕜$
|
|
||||||
| Italic | $\text{𝐴-𝑍 𝑎-𝑧}$ | Sans serif | $\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}$
|
|
||||||
| Bold Italic | $\text{𝑨-𝒁 𝒂-𝒛}$ | Sans serif bold | $\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}$
|
|
||||||
| Script | $\text{𝒜-𝒵}$ | Sans serif italic | $\text{𝘈-𝘡 𝘢-𝘻}$
|
|
||||||
| Fractur | $\text{𝔄-}ℨ\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
**Unicode**
|
|
||||||
|
|
||||||
The letters listed above will render in any KaTeX rendering mode.
|
|
||||||
|
|
||||||
If the KaTeX rendering mode is set to `strict: false` or `strict:"warn"` (default), then KaTeX will accept all Unicode letters. The letters not listed above will be rendered from system fonts, not KaTeX-supplied fonts, so their typography may clash. They may also cause small vertical alignment issues. KaTeX has detailed metrics for glyphs in Latin, Greek, and Cyrillic, but other glyphs are treated as if they are each as tall as the letter M.
|
|
||||||
|
|
||||||
For Persian composite characters, a user-supplied [plug-in](https://github.com/HosseinAgha/persian-katex-plugin) is under development.
|
|
||||||
|
|
||||||
## Layout
|
|
||||||
|
|
||||||
### Annotation
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:------------------------------|:-----
|
|
||||||
|$\cancel{5}$ `\cancel{5}`|$\overbrace{a+b+c}^{\text{note}}$ `\overbrace{a+b+c}^{\text{note}}`
|
|
||||||
|$\bcancel{5}$ `\bcancel{5}` |$\underbrace{a+b+c}_{\text{note}}$ `\underbrace{a+b+c}_{\text{note}}`
|
|
||||||
|$\xcancel{ABC}$ `\xcancel{ABC}`|$\not =$ `\not =`
|
|
||||||
|$\sout{abc}$ `\sout{abc}`|$\boxed{\pi=\frac c d}$ `\boxed{\pi=\frac c d}`
|
|
||||||
|
|
||||||
`\tag{hi} x+y^{2x}`
|
|
||||||
$$\tag{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
`\tag*{hi} x+y^{2x}`
|
|
||||||
$$\tag*{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
### Line Breaks
|
|
||||||
|
|
||||||
KaTeX 0.10.0+ will insert automatic line breaks in inline math after relations or binary operators such as “=” or “+”. These can be suppressed by `\nobreak` or by placing math inside a pair of braces, as in `{F=ma}`. `\allowbreak` will allow automatic line breaks at locations other than relations or operators.
|
|
||||||
|
|
||||||
Hard line breaks are `\\` and `\newline`.
|
|
||||||
|
|
||||||
In display math, KaTeX does not insert automatic line breaks. It ignores display math hard line breaks when rendering option `strict: true`.
|
|
||||||
|
|
||||||
### Vertical Layout
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------|:----------------------------------------|:-----
|
|
||||||
|$x_n$ `x_n` |$\stackrel{!}{=}$ `\stackrel{!}{=}` |$a \atop b$ `a \atop b`
|
|
||||||
|$e^x$ `e^x` |$\overset{!}{=}$ `\overset{!}{=}` |$a\raisebox{0.25em}{b}c$ `a\raisebox{0.25em}{b}c`
|
|
||||||
|$_u^o $ `_u^o `|$\underset{!}{=}$ `\underset{!}{=}`
|
|
||||||
|
|
||||||
The second argument of `\raisebox` can contain math if it is nested within `$…$` delimiters, as in `\raisebox{0.25em}{$\frac a b$}`
|
|
||||||
|
|
||||||
### Overlap and Spacing
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------|:-------|
|
|
||||||
|${=}\mathllap{/\,}$ `{=}\mathllap{/\,}` | $\left(x^{\smash{2}}\right)$ `\left(x^{\smash{2}}\right)`
|
|
||||||
|$\mathrlap{\,/}{=}$ `\mathrlap{\,/}{=}` | $\sqrt{\smash[b]{y}}$ `\sqrt{\smash[b]{y}} `
|
|
||||||
|
|
||||||
$\displaystyle\sum_{\mathclap{1\le i\le j\le n}} x_{ij}$ `\sum_{\mathclap{1\le i\le j\le n}} x_{ij}`
|
|
||||||
|
|
||||||
KaTeX also supports `\llap`, `\rlap`, and `\clap`, but they will take only text, not math, as arguments.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="spacing-tbl">
|
|
||||||
|
|
||||||
**Spacing**
|
|
||||||
|
|
||||||
| Function | Produces | Function | Produces|
|
|
||||||
|:----------------|:-------------------|:---------------------|:--------------------------------------|
|
|
||||||
| `\,` | ³∕₁₈ em space | `\kern{distance}` | space, width = *distance*
|
|
||||||
| `\thinspace` | ³∕₁₈ em space | `\mkern{distance}` | space, width = *distance*
|
|
||||||
| `\>` | ⁴∕₁₈ em space | `\mskip{distance}` | space, width = *distance*
|
|
||||||
| `\:` | ⁴∕₁₈ em space | `\hskip{distance}` | space, width = *distance*
|
|
||||||
| `\medspace` | ⁴∕₁₈ em space | `\hspace{distance}` | space, width = *distance*
|
|
||||||
| `\;` | ⁵∕₁₈ em space | `\hspace*{distance}` | space, width = *distance*
|
|
||||||
| `\thickspace` | ⁵∕₁₈ em space | `\phantom{content}` | space the width and height of content
|
|
||||||
| `\enspace` | ½ em space | `\hphantom{content}` | space the width of content
|
|
||||||
| `\quad` | 1 em space | `\vphantom{content}` | a strut the height of content
|
|
||||||
| `\qquad` | 2 em space | `\!` | – ³∕₁₈ em space
|
|
||||||
| `~` | non-breaking space | `\negthinspace` | – ³∕₁₈ em space
|
|
||||||
| `\<space>` | space | `\negmedspace` | – ⁴∕₁₈ em space
|
|
||||||
| `\nobreakspace` | non-breaking space | `\negthickspace` | – ⁵∕₁₈ em space
|
|
||||||
| `\space` | space |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
**Notes:**
|
|
||||||
|
|
||||||
`distance` will accept any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
`\kern`, `\mkern`, `\mskip`, and `\hspace` accept unbraced distances, as in: `\kern1em`.
|
|
||||||
|
|
||||||
`\mkern` and `\mskip` will not work in text mode and both will write a console warning for any unit except `mu`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Logic and Set Theory
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:--------------------|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\forall$ `\forall` |$\complement$ `\complement`|$\therefore$ `\therefore` |$\emptyset$ `\emptyset`
|
|
||||||
|$\exists$ `\exists` |$\subset$ `\subset` |$\because$ `\because` |$\empty$ `\empty`
|
|
||||||
|$\exist$ `\exist` |$\supset$ `\supset` |$\mapsto$ `\mapsto` |$\varnothing$ `\varnothing`
|
|
||||||
|$\nexists$ `\nexists`|$\mid$ `\mid` |$\to$ `\to` |$\implies$ `\implies`
|
|
||||||
|$\in$ `\in` |$\land$ `\land` |$\gets$ `\gets` |$\impliedby$ `\impliedby`
|
|
||||||
|$\isin$ `\isin` |$\lor$ `\lor` |$\leftrightarrow$ `\leftrightarrow`|$\iff$ `\iff`
|
|
||||||
|$\notin$ `\notin` |$\ni$ `\ni` |$\notni$ `\notni` |$\neg$ `\neg` or `\lnot`
|
|
||||||
|
|
||||||
Direct Input: $∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬$ ℂ ℍ ℕ ℙ ℚ ℝ
|
|
||||||
|
|
||||||
## Macros
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------------------------------------|:------
|
|
||||||
|$\def\foo{x^2} \foo + \foo$ | `\def\foo{x^2} \foo + \foo`
|
|
||||||
|$\gdef\bar#1{#1^2} \bar{y} + \bar{y}$ | `\gdef\bar#1{#1^2} \bar{y} + \bar{y}`
|
|
||||||
| | `\global\def\macroname#1#2…{definition}`
|
|
||||||
| | `\newcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\renewcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\providecommand\macroname[numargs]{definition}`
|
|
||||||
|
|
||||||
Macros can also be defined in the KaTeX [rendering options](options.md).
|
|
||||||
|
|
||||||
Macros accept up to nine arguments: #1, #2, etc.
|
|
||||||
|
|
||||||
`\gdef` and `\global\def` macros will persist between math expressions.
|
|
||||||
|
|
||||||
Available functions include:
|
|
||||||
|
|
||||||
`\char` `\mathchoice` `\TextOrMath` `\@ifstar` `\@ifnextchar` `\@firstoftwo` `\@secondoftwo` `\relax`
|
|
||||||
|
|
||||||
@ is a valid character for commands, as if `\makeatletter` were in effect.
|
|
||||||
|
|
||||||
## Operators
|
|
||||||
|
|
||||||
### Big Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|------------------|-------------------------|--------------------------|--------------|
|
|
||||||
| $\sum$ `\sum` | $\prod$ `\prod` | $\bigotimes$ `\bigotimes`| $\bigvee$ `\bigvee`
|
|
||||||
| $\int$ `\int` | $\coprod$ `\coprod` | $\bigoplus$ `\bigoplus` | $\bigwedge$ `\bigwedge`
|
|
||||||
| $\iint$ `\iint` | $\intop$ `\intop` | $\bigodot$ `\bigodot` | $\bigcap$ `\bigcap`
|
|
||||||
| $\iiint$ `\iiint`| $\smallint$ `\smallint` | $\biguplus$ `\biguplus` | $\bigcup$ `\bigcup`
|
|
||||||
| $\oint$ `\oint` | $\oiint$ `\oiint` | $\oiiint$ `\oiiint` | $\bigsqcup$ `\bigsqcup`
|
|
||||||
|
|
||||||
Direct Input: $∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆$
|
|
||||||
|
|
||||||
### Binary Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-------------|-------------------|-------------------|--------------------|
|
|
||||||
| $+$ `+`| $\cdot$ `\cdot` | $\gtrdot$ `\gtrdot`| $x \pmod a$ `x \pmod a`|
|
|
||||||
| $-$ `-`| $\cdotp$ `\cdotp` | $\intercal$ `\intercal` | $x \pod a$ `x \pod a` |
|
|
||||||
| $/$ `/`| $\centerdot$ `\centerdot`| $\land$ `\land` | $\rhd$ `\rhd` |
|
|
||||||
| $*$ `*`| $\circ$ `\circ` | $\leftthreetimes$ `\leftthreetimes` | $\rightthreetimes$ `\rightthreetimes` |
|
|
||||||
| $\amalg$ `\amalg` | $\circledast$ `\circledast` | $\ldotp$ `\ldotp` | $\rtimes$ `\rtimes` |
|
|
||||||
| $\And$ `\And`| $\circledcirc$ `\circledcirc` | $\lor$ `\lor`| $\setminus$ `\setminus` |
|
|
||||||
| $\ast$ `\ast`| $\circleddash$ `\circleddash` | $\lessdot$ `\lessdot` | $\smallsetminus$ `\smallsetminus`|
|
|
||||||
| $\barwedge$ `\barwedge` | $\Cup$ `\Cup`| $\lhd$ `\lhd`| $\sqcap$ `\sqcap` |
|
|
||||||
| $\bigcirc$ `\bigcirc` | $\cup$ `\cup`| $\ltimes$ `\ltimes`| $\sqcup$ `\sqcup` |
|
|
||||||
| $\bmod$ `\bmod` | $\curlyvee$ `\curlyvee` | $x \mod a$ `x\mod a`| $\times$ `\times` |
|
|
||||||
| $\boxdot$ `\boxdot`| $\curlywedge$ `\curlywedge` | $\mp$ `\mp` | $\unlhd$ `\unlhd` |
|
|
||||||
| $\boxminus$ `\boxminus` | $\div$ `\div`| $\odot$ `\odot` | $\unrhd$ `\unrhd` |
|
|
||||||
| $\boxplus$ `\boxplus` | $\divideontimes$ `\divideontimes` | $\ominus$ `\ominus`| $\uplus$ `\uplus` |
|
|
||||||
| $\boxtimes$ `\boxtimes` | $\dotplus$ `\dotplus` | $\oplus$ `\oplus` | $\vee$ `\vee` |
|
|
||||||
| $\bullet$ `\bullet`| $\doublebarwedge$ `\doublebarwedge` | $\otimes$ `\otimes`| $\veebar$ `\veebar` |
|
|
||||||
| $\Cap$ `\Cap`| $\doublecap$ `\doublecap`| $\oslash$ `\oslash`| $\wedge$ `\wedge` |
|
|
||||||
| $\cap$ `\cap`| $\doublecup$ `\doublecup`| $\pm$ `\pm` or `\plusmn` | $\wr$ `\wr` |
|
|
||||||
|
|
||||||
Direct Input: $+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝$
|
|
||||||
|
|
||||||
### Fractions and Binomials
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\frac{a}{b}$ `\frac{a}{b}`|$\tfrac{a}{b}$ `\tfrac{a}{b}`|$\genfrac ( ] {2pt}{1}a{a+1}$ `\genfrac ( ] {2pt}{1}a{a+1}`
|
|
||||||
|${a \over b}$ `{a \over b}`|$\dfrac{a}{b}$ `\dfrac{a}{b}`|${a \above{2pt} b+1}$ `{a \above{2pt} b+1}`
|
|
||||||
|$a/b$ `a/b` | |$\cfrac{a}{1 + \cfrac{1}{b}}$ `\cfrac{a}{1 + \cfrac{1}{b}}`
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:--------
|
|
||||||
|$\binom{n}{k}$ `\binom{n}{k}` |$\dbinom{n}{k}$ `\dbinom{n}{k}`|${n\brace k}$ `{n\brace k}`
|
|
||||||
|${n \choose k}$ `{n \choose k}`|$\tbinom{n}{k}$ `\tbinom{n}{k}`|${n\brack k}$ `{n\brack k}`
|
|
||||||
|
|
||||||
### Math Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-----------|---------|-----------------|-----------|
|
|
||||||
| $\arcsin$ `\arcsin` | $\cotg$ `\cotg` | $\ln$ `\ln` | $\det$ `\det` |
|
|
||||||
| $\arccos$ `\arccos` | $\coth$ `\coth` | $\log$ `\log` | $\gcd$ `\gcd` |
|
|
||||||
| $\arctan$ `\arctan` | $\csc$ `\csc` | $\sec$ `\sec` | $\inf$ `\inf` |
|
|
||||||
| $\arctg$ `\arctg` | $\ctg$ `\ctg` | $\sin$ `\sin` | $\lim$ `\lim` |
|
|
||||||
| $\arcctg$ `\arcctg` | $\cth$ `\cth` | $\sinh$ `\sinh`| $\liminf$ `\liminf` |
|
|
||||||
| $\arg$ `\arg` | $\deg$ `\deg` | $\sh$ `\sh` | $\limsup$ `\limsup` |
|
|
||||||
| $\ch$ `\ch` | $\dim$ `\dim` | $\tan$ `\tan` | $\max$ `\max` |
|
|
||||||
| $\cos$ `\cos` | $\exp$ `\exp` | $\tanh$ `\tanh`| $\min$ `\min` |
|
|
||||||
| $\cosec$ `\cosec` | $\hom$ `\hom` | $\tg$ `\tg` | $\Pr$ `\Pr` |
|
|
||||||
| $\cosh$ `\cosh`| $\ker$ `\ker` | $\th$ `\th` | $\sup$ `\sup` |
|
|
||||||
| $\cot$ `\cot` | $\lg$ `\lg`| $\operatorname{f}$ `\operatorname{f}` | $\argmax$ `\argmax` |
|
|
||||||
|$\argmin$ `\argmin`|
|
|
||||||
|
|
||||||
Functions on the right column of this table can take `\limits`.
|
|
||||||
|
|
||||||
### \sqrt
|
|
||||||
|
|
||||||
$\sqrt{x}$ `\sqrt{x}`
|
|
||||||
|
|
||||||
$\sqrt[3]{x}$ `\sqrt[3]{x}`
|
|
||||||
|
|
||||||
## Relations
|
|
||||||
|
|
||||||
$\stackrel{!}{=}$ `\stackrel{!}{=}`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:----------------------------|:--------------------------------|:--------------------------------|:-----
|
|
||||||
|$=$ `=` |$\eqcirc$ `\eqcirc` |$\lesseqgtr$ `\lesseqgtr` |$\sqsupset$ `\sqsupset`
|
|
||||||
|$<$ `<` |$\eqcolon$ `\eqcolon`|$\lesseqqgtr$ `\lesseqqgtr`|$\sqsupseteq$ `\sqsupseteq`
|
|
||||||
|$>$ `>` |$\Eqcolon$ `\Eqcolon`|$\lessgtr$ `\lessgtr`|$\Subset$ `\Subset`
|
|
||||||
|$:$ `:` |$\eqqcolon$ `\eqqcolon` |$\lesssim$ `\lesssim`|$\subset$ `\subset` or `\sub`
|
|
||||||
|$\approx$ `\approx` |$\Eqqcolon$ `\Eqqcolon` |$\ll$ `\ll` |$\subseteq$ `\subseteq` or `\sube`
|
|
||||||
|$\approxeq$ `\approxeq`|$\eqsim$ `\eqsim` |$\lll$ `\lll` |$\subseteqq$ `\subseteqq`
|
|
||||||
|$\asymp$ `\asymp`|$\eqslantgtr$ `\eqslantgtr`|$\llless$ `\llless` |$\succ$ `\succ`
|
|
||||||
|$\backepsilon$ `\backepsilon`|$\eqslantless$ `\eqslantless` |$\lt$ `\lt` |$\succapprox$ `\succapprox`
|
|
||||||
|$\backsim$ `\backsim` |$\equiv$ `\equiv` |$\mid$ `\mid` |$\succcurlyeq$ `\succcurlyeq`
|
|
||||||
|$\backsimeq$ `\backsimeq` |$\fallingdotseq$ `\fallingdotseq`|$\models$ `\models` |$\succeq$ `\succeq`
|
|
||||||
|$\between$ `\between` |$\frown$ `\frown` |$\multimap$ `\multimap` |$\succsim$ `\succsim`
|
|
||||||
|$\bowtie$ `\bowtie` |$\ge$ `\ge` |$\owns$ `\owns`|$\Supset$ `\Supset`
|
|
||||||
|$\bumpeq$ `\bumpeq` |$\geq$ `\geq` |$\parallel$ `\parallel` |$\supset$ `\supset`
|
|
||||||
|$\Bumpeq$ `\Bumpeq` |$\geqq$ `\geqq`|$\perp$ `\perp`|$\supseteq$ `\supseteq` or `\supe`
|
|
||||||
|$\circeq$ `\circeq` |$\geqslant$ `\geqslant` |$\pitchfork$ `\pitchfork` |$\supseteqq$ `\supseteqq`
|
|
||||||
|$\colonapprox$ `\colonapprox`|$\gg$ `\gg` |$\prec$ `\prec`|$\thickapprox$ `\thickapprox`
|
|
||||||
|$\Colonapprox$ `\Colonapprox`|$\ggg$ `\ggg` |$\precapprox$ `\precapprox`|$\thicksim$ `\thicksim`
|
|
||||||
|$\coloneq$ `\coloneq` |$\gggtr$ `\gggtr` |$\preccurlyeq$ `\preccurlyeq` |$\trianglelefteq$ `\trianglelefteq`
|
|
||||||
|$\Coloneq$ `\Coloneq` |$\gt$ `\gt` |$\preceq$ `\preceq` |$\triangleq$ `\triangleq`
|
|
||||||
|$\coloneqq$ `\coloneqq`|$\gtrapprox$ `\gtrapprox` |$\precsim$ `\precsim`|$\trianglerighteq$ `\trianglerighteq`
|
|
||||||
|$\Coloneqq$ `\Coloneqq`|$\gtreqless$ `\gtreqless` |$\propto$ `\propto` |$\varpropto$ `\varpropto`
|
|
||||||
|$\colonsim$ `\colonsim`|$\gtreqqless$ `\gtreqqless`|$\risingdotseq$ `\risingdotseq` |$\vartriangle$ `\vartriangle`
|
|
||||||
|$\Colonsim$ `\Colonsim`|$\gtrless$ `\gtrless`|$\shortmid$ `\shortmid` |$\vartriangleleft$ `\vartriangleleft`
|
|
||||||
|$\cong$ `\cong` |$\gtrsim$ `\gtrsim` |$\shortparallel$ `\shortparallel`|$\vartriangleright$ `\vartriangleright`
|
|
||||||
|$\curlyeqprec$ `\curlyeqprec`|$\in$ `\in` or `\isin` |$\sim$ `\sim` |$\vcentcolon$ `\vcentcolon`
|
|
||||||
|$\curlyeqsucc$ `\curlyeqsucc`|$\Join$ `\Join`|$\simeq$ `\simeq` |$\vdash$ `\vdash`
|
|
||||||
|$\dashv$ `\dashv`|$\le$ `\le` |$\smallfrown$ `\smallfrown`|$\vDash$ `\vDash`
|
|
||||||
|$\dblcolon$ `\dblcolon`|$\leq$ `\leq` |$\smallsmile$ `\smallsmile`|$\Vdash$ `\Vdash`
|
|
||||||
|$\doteq$ `\doteq`|$\leqq$ `\leqq`|$\smile$ `\smile` |$\Vvdash$ `\Vvdash`
|
|
||||||
|$\Doteq$ `\Doteq`|$\leqslant$ `\leqslant` |$\sqsubset$ `\sqsubset` |
|
|
||||||
|$\doteqdot$ `\doteqdot`|$\lessapprox$ `\lessapprox`|$\sqsubseteq$ `\sqsubseteq`|
|
|
||||||
|
|
||||||
|
|
||||||
Direct Input: $= < > : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⟂ ⊨$ `≔ ≕ ⩴`
|
|
||||||
|
|
||||||
### Negated Relations
|
|
||||||
|
|
||||||
$\not =$ `\not =`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|--------------|-------------------|---------------------|------------------|
|
|
||||||
| $\gnapprox$ `\gnapprox` | $\ngeqslant$ `\ngeqslant`| $\nsubseteq$ `\nsubseteq` | $\precneqq$ `\precneqq`|
|
|
||||||
| $\gneq$ `\gneq`| $\ngtr$ `\ngtr` | $\nsubseteqq$ `\nsubseteqq` | $\precnsim$ `\precnsim`|
|
|
||||||
| $\gneqq$ `\gneqq` | $\nleq$ `\nleq` | $\nsucc$ `\nsucc`| $\subsetneq$ `\subsetneq` |
|
|
||||||
| $\gnsim$ `\gnsim` | $\nleqq$ `\nleqq` | $\nsucceq$ `\nsucceq` | $\subsetneqq$ `\subsetneqq` |
|
|
||||||
| $\gvertneqq$ `\gvertneqq` | $\nleqslant$ `\nleqslant`| $\nsupseteq$ `\nsupseteq` | $\succnapprox$ `\succnapprox`|
|
|
||||||
| $\lnapprox$ `\lnapprox` | $\nless$ `\nless` | $\nsupseteqq$ `\nsupseteqq` | $\succneqq$ `\succneqq`|
|
|
||||||
| $\lneq$ `\lneq`| $\nmid$ `\nmid` | $\ntriangleleft$ `\ntriangleleft` | $\succnsim$ `\succnsim`|
|
|
||||||
| $\lneqq$ `\lneqq` | $\notin$ `\notin` | $\ntrianglelefteq$ `\ntrianglelefteq` | $\supsetneq$ `\supsetneq` |
|
|
||||||
| $\lnsim$ `\lnsim` | $\notni$ `\notni` | $\ntriangleright$ `\ntriangleright`| $\supsetneqq$ `\supsetneqq` |
|
|
||||||
| $\lvertneqq$ `\lvertneqq` | $\nparallel$ `\nparallel`| $\ntrianglerighteq$ `\ntrianglerighteq` | $\varsubsetneq$ `\varsubsetneq` |
|
|
||||||
| $\ncong$ `\ncong` | $\nprec$ `\nprec` | $\nvdash$ `\nvdash` | $\varsubsetneqq$ `\varsubsetneqq` |
|
|
||||||
| $\ne$ `\ne` | $\npreceq$ `\npreceq` | $\nvDash$ `\nvDash` | $\varsupsetneq$ `\varsupsetneq` |
|
|
||||||
| $\neq$ `\neq` | $\nshortmid$ `\nshortmid`| $\nVDash$ `\nVDash` | $\varsupsetneqq$ `\varsupsetneqq` |
|
|
||||||
| $\ngeq$ `\ngeq`| $\nshortparallel$ `\nshortparallel` | $\nVdash$ `\nVdash` |
|
|
||||||
| $\ngeqq$ `\ngeqq` | $\nsim$ `\nsim` | $\precnapprox$ `\precnapprox`|
|
|
||||||
|
|
||||||
Direct Input: $∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌$
|
|
||||||
|
|
||||||
### Arrows
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|$\circlearrowleft$ `\circlearrowleft`|$\leftharpoonup$ `\leftharpoonup`|$\rArr$ `\rArr`
|
|
||||||
|$\circlearrowright$ `\circlearrowright`|$\leftleftarrows$ `\leftleftarrows`|$\rarr$ `\rarr`
|
|
||||||
|$\curvearrowleft$ `\curvearrowleft`|$\leftrightarrow$ `\leftrightarrow`|$\restriction$ `\restriction`
|
|
||||||
|$\curvearrowright$ `\curvearrowright`|$\Leftrightarrow$ `\Leftrightarrow`|$\rightarrow$ `\rightarrow`
|
|
||||||
|$\Darr$ `\Darr`|$\leftrightarrows$ `\leftrightarrows`|$\Rightarrow$ `\Rightarrow`
|
|
||||||
|$\dArr$ `\dArr`|$\leftrightharpoons$ `\leftrightharpoons`|$\rightarrowtail$ `\rightarrowtail`
|
|
||||||
|$\darr$ `\darr`|$\leftrightsquigarrow$ `\leftrightsquigarrow`|$\rightharpoondown$ `\rightharpoondown`
|
|
||||||
|$\dashleftarrow$ `\dashleftarrow`|$\Lleftarrow$ `\Lleftarrow`|$\rightharpoonup$ `\rightharpoonup`
|
|
||||||
|$\dashrightarrow$ `\dashrightarrow`|$\longleftarrow$ `\longleftarrow`|$\rightleftarrows$ `\rightleftarrows`
|
|
||||||
|$\downarrow$ `\downarrow`|$\Longleftarrow$ `\Longleftarrow`|$\rightleftharpoons$ `\rightleftharpoons`
|
|
||||||
|$\Downarrow$ `\Downarrow`|$\longleftrightarrow$ `\longleftrightarrow`|$\rightrightarrows$ `\rightrightarrows`
|
|
||||||
|$\downdownarrows$ `\downdownarrows`|$\Longleftrightarrow$ `\Longleftrightarrow`|$\rightsquigarrow$ `\rightsquigarrow`
|
|
||||||
|$\downharpoonleft$ `\downharpoonleft`|$\longmapsto$ `\longmapsto`|$\Rrightarrow$ `\Rrightarrow`
|
|
||||||
|$\downharpoonright$ `\downharpoonright`|$\longrightarrow$ `\longrightarrow`|$\Rsh$ `\Rsh`
|
|
||||||
|$\gets$ `\gets`|$\Longrightarrow$ `\Longrightarrow`|$\searrow$ `\searrow`
|
|
||||||
|$\Harr$ `\Harr`|$\looparrowleft$ `\looparrowleft`|$\swarrow$ `\swarrow`
|
|
||||||
|$\hArr$ `\hArr`|$\looparrowright$ `\looparrowright`|$\to$ `\to`
|
|
||||||
|$\harr$ `\harr`|$\Lrarr$ `\Lrarr`|$\twoheadleftarrow$ `\twoheadleftarrow`
|
|
||||||
|$\hookleftarrow$ `\hookleftarrow`|$\lrArr$ `\lrArr`|$\twoheadrightarrow$ `\twoheadrightarrow`
|
|
||||||
|$\hookrightarrow$ `\hookrightarrow`|$\lrarr$ `\lrarr`|$\Uarr$ `\Uarr`
|
|
||||||
|$\iff$ `\iff`|$\Lsh$ `\Lsh`|$\uArr$ `\uArr`
|
|
||||||
|$\impliedby$ `\impliedby`|$\mapsto$ `\mapsto`|$\uarr$ `\uarr`
|
|
||||||
|$\implies$ `\implies`|$\nearrow$ `\nearrow`|$\uparrow$ `\uparrow`
|
|
||||||
|$\Larr$ `\Larr`|$\nleftarrow$ `\nleftarrow`|$\Uparrow$ `\Uparrow`
|
|
||||||
|$\lArr$ `\lArr`|$\nLeftarrow$ `\nLeftarrow`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$\larr$ `\larr`|$\nleftrightarrow$ `\nleftrightarrow`|$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\leadsto$ `\leadsto`|$\nLeftrightarrow$ `\nLeftrightarrow`|$\upharpoonleft$ `\upharpoonleft`
|
|
||||||
|$\leftarrow$ `\leftarrow`|$\nrightarrow$ `\nrightarrow`|$\upharpoonright$ `\upharpoonright`
|
|
||||||
|$\Leftarrow$ `\Leftarrow`|$\nRightarrow$ `\nRightarrow`|$\upuparrows$ `\upuparrows`
|
|
||||||
|$\leftarrowtail$ `\leftarrowtail`|$\nwarrow$ `\nwarrow`
|
|
||||||
|$\leftharpoondown$ `\leftharpoondown`|$\Rarr$ `\Rarr`
|
|
||||||
|
|
||||||
Direct Input: $← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼$ ↽
|
|
||||||
|
|
||||||
**Extensible Arrows**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------------------------------------|:-----
|
|
||||||
|$\xleftarrow{abc}$ `\xleftarrow{abc}` |$\xrightarrow[under]{over}$ `\xrightarrow[under]{over}`
|
|
||||||
|$\xLeftarrow{abc}$ `\xLeftarrow{abc}` |$\xRightarrow{abc}$ `\xRightarrow{abc}`
|
|
||||||
|$\xleftrightarrow{abc}$ `\xleftrightarrow{abc}` |$\xLeftrightarrow{abc}$ `\xLeftrightarrow{abc}`
|
|
||||||
|$\xhookleftarrow{abc}$ `\xhookleftarrow{abc}` |$\xhookrightarrow{abc}$ `\xhookrightarrow{abc}`
|
|
||||||
|$\xtwoheadleftarrow{abc}$ `\xtwoheadleftarrow{abc}` |$\xtwoheadrightarrow{abc}$ `\xtwoheadrightarrow{abc}`
|
|
||||||
|$\xleftharpoonup{abc}$ `\xleftharpoonup{abc}` |$\xrightharpoonup{abc}$ `\xrightharpoonup{abc}`
|
|
||||||
|$\xleftharpoondown{abc}$ `\xleftharpoondown{abc}` |$\xrightharpoondown{abc}$ `\xrightharpoondown{abc}`
|
|
||||||
|$\xleftrightharpoons{abc}$ `\xleftrightharpoons{abc}`|$\xrightleftharpoons{abc}$ `\xrightleftharpoons{abc}`
|
|
||||||
|$\xtofrom{abc}$ `\xtofrom{abc}` |$\xmapsto{abc}$ `\xmapsto{abc}`
|
|
||||||
|$\xlongequal{abc}$ `\xlongequal{abc}`
|
|
||||||
|
|
||||||
Extensible arrows all can take an optional argument in the same manner<br>as `\xrightarrow[under]{over}`.
|
|
||||||
|
|
||||||
## Style, Color, Size, and Font
|
|
||||||
|
|
||||||
**Class Assignment**
|
|
||||||
|
|
||||||
`\mathbin` `\mathclose` `\mathinner` `\mathop`<br>
|
|
||||||
`\mathopen` `\mathord` `\mathpunct` `\mathrel`
|
|
||||||
|
|
||||||
**Color**
|
|
||||||
|
|
||||||
$\color{blue} F=ma$ `\color{blue} F=ma`
|
|
||||||
|
|
||||||
Note that KaTeX `\color` acts like a switch. This aligns with LaTeX and differs from MathJax.
|
|
||||||
Other KaTeX color functions expect the content to be a function argument:
|
|
||||||
|
|
||||||
$\textcolor{blue}{F=ma}$ `\textcolor{blue}{F=ma}`<br>
|
|
||||||
$\textcolor{#228B22}{F=ma}$ `\textcolor{#228B22}{F=ma}`<br>
|
|
||||||
$\colorbox{aqua}{A}$ `\colorbox{aqua}{A}`<br>
|
|
||||||
$\fcolorbox{red}{aqua}{A}$ `\fcolorbox{red}{aqua}{A}`
|
|
||||||
|
|
||||||
For color definition, KaTeX color functions will accept the standard HTML [predefined color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords). They will also accept an RGB argument in CSS hexadecimal style. The "#" is optional before a six-digit specification.
|
|
||||||
|
|
||||||
**Font**
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:-----
|
|
||||||
|$\mathrm{Ab0}$ `\mathrm{Ab0}` |$\mathbf{Ab0}$ `\mathbf{Ab0}` |$\mathit{Ab0}$ `\mathit{Ab0}`
|
|
||||||
|$\mathnormal{Ab0}$ `\mathnormal{Ab0}`|$\textbf{Ab0}$ `\textbf{Ab0}` |$\textit{Ab0}$ `\textit{Ab0}`
|
|
||||||
|$\textrm{Ab0}$ `\textrm{Ab0}` |$\bf Ab0$ `\bf Ab0` |$\it Ab0$ `\it Ab0`
|
|
||||||
|$\rm Ab0$ `\rm Ab0` |$\bold{Ab0}$ `\bold{Ab0}` |$\textup{Ab0}$ `\textup{Ab0}`
|
|
||||||
|$\textnormal{Ab0}$ `\textnormal{Ab0}`|$\boldsymbol{Ab0}$ `\boldsymbol{Ab}`|$\Bbb{AB}$ `\Bbb{AB}`
|
|
||||||
|$\text{Ab0}$ `\text{Ab0}` |$\bm{Ab0}$ `\bm{Ab0}` |$\mathbb{AB}$ `\mathbb{AB}`
|
|
||||||
|$\mathsf{Ab0}$ `\mathsf{Ab0}` |$\textmd{Ab0}$ `\textmd{Ab0}` |$\frak{Ab0}$ `\frak{Ab0}`
|
|
||||||
|$\textsf{Ab0}$ `\textsf{Ab0}` |$\mathtt{Ab0}$ `\mathtt{Ab0}` |$\mathfrak{Ab0}$ `\mathfrak{Ab0}`
|
|
||||||
|$\sf Ab0$ `\sf Ab0` |$\texttt{Ab0}$ `\texttt{Ab0}` |$\mathcal{AB0}$ `\mathcal{AB0}`
|
|
||||||
| |$\tt Ab0$ `\tt Ab0` |$\mathscr{AB}$ `\mathscr{AB}`
|
|
||||||
|
|
||||||
One can stack font family, font weight, and font shape by using the `\textXX` versions of the font functions. So `\textsf{\textbf{H}}` will produce $\textsf{\textbf{H}}$. The other versions do not stack, e.g., `\mathsf{\mathbf{H}}` will produce $\mathsf{\mathbf{H}}$.
|
|
||||||
|
|
||||||
In cases where KaTeX fonts do not have a bold glyph, `\pmb` can simulate one. For example, `\pmb{\mu}` renders as : $\pmb{\mu}$
|
|
||||||
|
|
||||||
**Size**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------|:-----
|
|
||||||
|$\Huge AB$ `\Huge AB` |$\normalsize AB$ `\normalsize AB`
|
|
||||||
|$\huge AB$ `\huge AB` |$\small AB$ `\small AB`
|
|
||||||
|$\LARGE AB$ `\LARGE AB`|$\footnotesize AB$ `\footnotesize AB`
|
|
||||||
|$\Large AB$ `\Large AB`|$\scriptsize AB$ `\scriptsize AB`
|
|
||||||
|$\large AB$ `\large AB`|$\tiny AB$ `\tiny AB`
|
|
||||||
|
|
||||||
|
|
||||||
**Style**
|
|
||||||
|
|
||||||
||
|
|
||||||
|:-------------------------------------------------------|
|
|
||||||
|$\displaystyle\sum_{i=1}^n$ `\displaystyle\sum_{i=1}^n`
|
|
||||||
|$\textstyle\sum_{i=1}^n$ `\textstyle\sum_{i=1}^n`
|
|
||||||
|$\scriptstyle x$ `\scriptstyle x` (The size of a first sub/superscript)
|
|
||||||
|$\scriptscriptstyle x$ `\scriptscriptstyle x` (The size of subsequent sub/superscripts)
|
|
||||||
|$\lim\limits_x$ `\lim\limits_x`
|
|
||||||
|$\lim\nolimits_x$ `\lim\nolimits_x`
|
|
||||||
|$\verb!x^2!$ `\verb!x^2!`
|
|
||||||
|
|
||||||
`\text{…}` will accept nested `$…$` fragments and render them in math mode.
|
|
||||||
|
|
||||||
## Symbols and Punctuation
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|`% comment`|$\dots$ `\dots`|$\KaTeX$ `\KaTeX`
|
|
||||||
|$\%$ `\%`|$\cdots$ `\cdots`|$\LaTeX$ `\LaTeX`
|
|
||||||
|$\#$ `\#`|$\ddots$ `\ddots`|$\TeX$ `\TeX`
|
|
||||||
|$\&$ `\&`|$\ldots$ `\ldots`|$\nabla$ `\nabla`
|
|
||||||
|$\_$ `\_`|$\vdots$ `\vdots`|$\infty$ `\infty`
|
|
||||||
|$\text{\textunderscore}$ `\text{\textunderscore}`|$\dotsb$ `\dotsb`|$\infin$ `\infin`
|
|
||||||
|$\text{--}$ `\text{--}`|$\dotsc$ `\dotsc`|$\checkmark$ `\checkmark`
|
|
||||||
|$\text{\textendash}$ `\text{\textendash}`|$\dotsi$ `\dotsi`|$\dag$ `\dag`
|
|
||||||
|$\text{---}$ `\text{---}`|$\dotsm$ `\dotsm`|$\dagger$ `\dagger`
|
|
||||||
|$\text{\textemdash}$ `\text{\textemdash}`|$\dotso$ `\dotso`|$\text{\textdagger}$ `\text{\textdagger}`
|
|
||||||
|$\text{\textasciitilde}$ `\text{\textasciitilde}`|$\sdot$ `\sdot`|$\ddag$ `\ddag`
|
|
||||||
|$\text{\textasciicircum}$ `\text{\textasciicircum}`|$\mathellipsis$ `\mathellipsis`|$\ddagger$ `\ddagger`
|
|
||||||
|$`$ <code>`</code>|$\text{\textellipsis}$ `\text{\textellipsis}`|$\text{\textdaggerdbl}$ `\text{\textdaggerdbl}`
|
|
||||||
|$\text{\textquoteleft}$ `text{\textquoteleft}`|$\Box$ `\Box`|$\Dagger$ `\Dagger`
|
|
||||||
|$\lq$ `\lq`|$\square$ `\square`|$\angle$ `\angle`
|
|
||||||
|$\text{\textquoteright}$ `\text{\textquoteright}`|$\blacksquare$ `\blacksquare`|$\measuredangle$ `\measuredangle`
|
|
||||||
|$\rq$ `\rq`|$\triangle$ `\triangle`|$\sphericalangle$ `\sphericalangle`
|
|
||||||
|$\text{\textquotedblleft}$ `\text{\textquotedblleft}`|$\triangledown$ `\triangledown`|$\top$ `\top`
|
|
||||||
|$"$ `"`|$\triangleleft$ `\triangleleft`|$\bot$ `\bot`
|
|
||||||
|$\text{\textquotedblright}$ `\text{\textquotedblright}`|$\triangleright$ `\triangleright`|$\$$ `\$`
|
|
||||||
|$\colon$ `\colon`|$\bigtriangledown$ `\bigtriangledown`|$\text{\textdollar}$ `\text{\textdollar}`
|
|
||||||
|$\backprime$ `\backprime`|$\bigtriangleup$ `\bigtriangleup`|$\pounds$ `\pounds`
|
|
||||||
|$\prime$ `\prime`|$\blacktriangle$ `\blacktriangle`|$\mathsterling$ `\mathsterling`
|
|
||||||
|$\text{\textless}$ `\text{\textless}`|$\blacktriangledown$ `\blacktriangledown`|$\text{\textsterling}$ `\text{\textsterling}`
|
|
||||||
|$\text{\textgreater}$ `\text{\textgreater}`|$\blacktriangleleft$ `\blacktriangleleft`|$\yen$ `\yen`
|
|
||||||
|$\text{\textbar}$ `\text{\textbar}`|$\blacktriangleright$ `\blacktriangleright`|$\surd$ `\surd`
|
|
||||||
|$\text{\textbardbl}$ `\text{\textbardbl}`|$\diamond$ `\diamond`|$\degree$ `\degree`
|
|
||||||
|$\text{\textbraceleft}$ `\text{\textbraceleft}`|$\Diamond$ `\Diamond`|$\text{\textdegree}$ `\text{\textdegree}`
|
|
||||||
|$\text{\textbraceright}$ `\text{\textbraceright}`|$\lozenge$ `\lozenge`|$\mho$ `\mho`
|
|
||||||
|$\text{\textbackslash}$ `\text{\textbackslash}`|$\blacklozenge$ `\blacklozenge`|$\diagdown$ `\diagdown`
|
|
||||||
|$\text{\P}$ `\text{\P}`|$\star$ `\star`|$\diagup$ `\diagup`
|
|
||||||
|$\text{\S}$ `\text{\S}`|$\bigstar$ `\bigstar`|$\flat$ `\flat`
|
|
||||||
|$\text{\sect}$ `\text{\sect}`|$\clubsuit$ `\clubsuit`|$\natural$ `\natural`
|
|
||||||
|$\copyright$ `\copyright`|$\clubs$ `\clubs`|$\sharp$ `\sharp`
|
|
||||||
|$\circledR$ `\circledR`|$\diamondsuit$ `\diamondsuit`|$\heartsuit$ `\heartsuit`
|
|
||||||
|$\text{\textregistered}$ `\text{\textregistered}`|$\diamonds$ `\diamonds`|$\hearts$ `\hearts`
|
|
||||||
|$\circledS$ `\circledS`|$\spadesuit$ `\spadesuit`|$\spades$ `\spades`
|
|
||||||
|$\text{\textcircled a}$ `\text{\textcircled a}`|$\maltese$ `\maltese`||
|
|
||||||
|
|
||||||
Direct Input: $£ ¥ ∇ ∞ · ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ … ⋮ ⋯ ⋱ !$ ‼
|
|
||||||
|
|
||||||
## Units
|
|
||||||
|
|
||||||
In KaTeX, units are proportioned as they are in TeX.<br>
|
|
||||||
KaTeX units are different than CSS units.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="unit-tbl">
|
|
||||||
|
|
||||||
| KaTeX Unit | Value | KaTeX Unit | Value |
|
|
||||||
|:---|:---------------------|:---|:----------------|
|
|
||||||
| em | CSS em | bp | 1/72 inch × F × G|
|
|
||||||
| ex | CSS ex | pc | 12 KaTeX pt|
|
|
||||||
| mu | 1/18 CSS em | dd | 1238/1157 KaTeX pt |
|
|
||||||
| pt | 1/72.27 inch × F × G | cc | 14856/1157 KaTeX pt |
|
|
||||||
| mm | 1 mm × F × G | nd | 685/642 KaTeX pt |
|
|
||||||
| cm | 1 cm × F × G | nc | 1370/107 KaTeX pt|
|
|
||||||
| in | 1 inch × F × G | sp | 1/65536 KaTeX pt |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
where:
|
|
||||||
|
|
||||||
<div style="margin-left: 1.5em;">
|
|
||||||
|
|
||||||
F = (font size of surrounding HTML text)/(10 pt)
|
|
||||||
|
|
||||||
G = 1.21 by default, because KaTeX font-size is normally 1.21 × the surrounding font size. This value [can be overridden](font.md#font-size-and-lengths) by the CSS of an HTML page.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
The effect of style and size:
|
|
||||||
|
|
||||||
<div class="katex-cards" id="unit-blocks">
|
|
||||||
|
|
||||||
| Unit | textstyle | scriptscript | huge |
|
|
||||||
|:------:|:-----------------:|:------------:|:------:|
|
|
||||||
|em or ex|$\rule{1em}{1em}$ |$\scriptscriptstyle\rule{1em}{1em}$ |$\huge\rule{1em}{1em}$
|
|
||||||
| mu |$\rule{18mu}{18mu}$|$\scriptscriptstyle\rule{18mu}{18mu}$|$\huge\rule{18mu}{18mu}$
|
|
||||||
| others |$\rule{10pt}{10pt}$|$\scriptscriptstyle\rule{10pt}{10pt}$|$\huge\rule{10pt}{10pt}$
|
|
||||||
|
|
||||||
</div>
|
|
@@ -1,111 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.0-autorender
|
|
||||||
title: Auto-render Extension
|
|
||||||
original_id: autorender
|
|
||||||
---
|
|
||||||
This is an extension to automatically render all of the math inside of text. It
|
|
||||||
searches all of the text nodes within a given element for the given delimiters,
|
|
||||||
ignoring certain tags like `<pre>`, and renders the math in place.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
This extension isn't part of KaTeX proper, so the script needs to be included
|
|
||||||
(via a `<script>` tag) in the page along with KaTeX itself. For example,
|
|
||||||
using a CDN:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.css" integrity="sha384-BdGj8xC2eZkQaxoQ8nSLefg4AV4/AwB3Fj+8SUSo7pnKP6Eoy18liIKTPn9oBYNG" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.js" integrity="sha384-JiKN5O8x9Hhs/UE5cT5AAJqieYlOZbGT3CHws/y97o3ty4R7/O5poG9F3JoiOYw1" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above, the [`defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
indicates that the script doesn't need to execute until the page has loaded,
|
|
||||||
speeding up page rendering; and the `onload` attribute calls
|
|
||||||
`renderMathInElement` once the auto-render script loads.
|
|
||||||
|
|
||||||
Alternatively, you can call the `renderMathInElement` when (or after) the
|
|
||||||
[`DOMContentLoaded` event](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded)
|
|
||||||
fires on the document or in another deferred script.
|
|
||||||
This approach is useful for specifying or computing options, or if you don't
|
|
||||||
want to use a `defer` or `onload` attribute.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.css" integrity="sha384-BdGj8xC2eZkQaxoQ8nSLefg4AV4/AwB3Fj+8SUSo7pnKP6Eoy18liIKTPn9oBYNG" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.js" integrity="sha384-JiKN5O8x9Hhs/UE5cT5AAJqieYlOZbGT3CHws/y97o3ty4R7/O5poG9F3JoiOYw1" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
renderMathInElement(document.body, {
|
|
||||||
// ...options...
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
ECMAScript module is also available:
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.css" integrity="sha384-BdGj8xC2eZkQaxoQ8nSLefg4AV4/AwB3Fj+8SUSo7pnKP6Eoy18liIKTPn9oBYNG" crossorigin="anonymous">
|
|
||||||
<script type="module">
|
|
||||||
import renderMathInElement from "https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/contrib/auto-render.mjs";
|
|
||||||
renderMathInElement(document.body);
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules. -->
|
|
||||||
|
|
||||||
## API
|
|
||||||
This extension exposes a single function, `window.renderMathInElement`, with
|
|
||||||
the following API:
|
|
||||||
|
|
||||||
```js
|
|
||||||
function renderMathInElement(elem, options)
|
|
||||||
```
|
|
||||||
|
|
||||||
`elem` is an HTML DOM element. The function will recursively search for text
|
|
||||||
nodes inside this element and render the math in them.
|
|
||||||
|
|
||||||
`options` is an optional object argument that can have the same keys as [the
|
|
||||||
object passed to `katex.render`](https://github.com/KaTeX/KaTeX/#rendering-options),
|
|
||||||
in addition to several auto-render-specific keys:
|
|
||||||
|
|
||||||
- `delimiters`: This is a list of delimiters to look for math. Each delimiter
|
|
||||||
has three properties:
|
|
||||||
|
|
||||||
- `left`: A string which starts the math expression (i.e. the left delimiter).
|
|
||||||
- `right`: A string which ends the math expression (i.e. the right delimiter).
|
|
||||||
- `display`: A boolean of whether the math in the expression should be
|
|
||||||
rendered in display mode or not.
|
|
||||||
|
|
||||||
The default value is:
|
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{left: "$$", right: "$$", display: true},
|
|
||||||
{left: "\\(", right: "\\)", display: false},
|
|
||||||
{left: "\\[", right: "\\]", display: true}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
- `ignoredTags`: This is a list of DOM node types to ignore when recursing
|
|
||||||
through. The default value is
|
|
||||||
`["script", "noscript", "style", "textarea", "pre", "code"]`.
|
|
||||||
|
|
||||||
- `ignoredClasses`: This is a list of DOM node class names to ignore when
|
|
||||||
recursing through. By default, this value is not set.
|
|
||||||
|
|
||||||
- `errorCallback`: A callback method returning a message and an error stack
|
|
||||||
in case of an critical error during rendering. The default uses `console.error`.
|
|
||||||
|
|
||||||
- `preProcess`: A callback function, `(math: string) => string`, used to process
|
|
||||||
math expressions before rendering.
|
|
||||||
|
|
||||||
The `displayMode` property of the options object is ignored, and is
|
|
||||||
instead taken from the `display` key of the corresponding entry in the
|
|
||||||
`delimiters` key.
|
|
||||||
|
|
||||||
The same `options.macros` object (which defaults to an empty object `{}`)
|
|
||||||
is passed into several calls to `katex.render`, so that consecutive equations
|
|
||||||
can build up shared macros by `\gdef`.
|
|
@@ -1,119 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.0-browser
|
|
||||||
title: Browser
|
|
||||||
original_id: browser
|
|
||||||
---
|
|
||||||
> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11.
|
|
||||||
|
|
||||||
## Starter template
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.css" integrity="sha384-BdGj8xC2eZkQaxoQ8nSLefg4AV4/AwB3Fj+8SUSo7pnKP6Eoy18liIKTPn9oBYNG" crossorigin="anonymous">
|
|
||||||
|
|
||||||
<!-- The loading of KaTeX is deferred to speed up page rendering -->
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.js" integrity="sha384-JiKN5O8x9Hhs/UE5cT5AAJqieYlOZbGT3CHws/y97o3ty4R7/O5poG9F3JoiOYw1" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
<!-- To automatically render math in text elements, include the auto-render extension: -->
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
</head>
|
|
||||||
...
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Loading as Global
|
|
||||||
If you include the `katex.js` directly, the `katex` object will be available as
|
|
||||||
a global variable.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.css" integrity="sha384-IfEbO0yhy2n4/+OZc9LUjnq7UDEUifPgfe34YcKod1rOJyX0JNBJ4/6XKpclZtj3" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.js" integrity="sha384-07m3BXnpyYn3KtPIt7XjRYaNz2mc2OKdnUmRGNQxx7cMbT78d1JTy71cyEiCBQHr" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides minified versions:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.css" integrity="sha384-BdGj8xC2eZkQaxoQ8nSLefg4AV4/AwB3Fj+8SUSo7pnKP6Eoy18liIKTPn9oBYNG" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.js" integrity="sha384-JiKN5O8x9Hhs/UE5cT5AAJqieYlOZbGT3CHws/y97o3ty4R7/O5poG9F3JoiOYw1" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
The examples above load the script [deferred using the `defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to speed up page rendering. The `katex` object will be available after
|
|
||||||
[`DOMContentLoaded` event is fired on the `document`](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded).
|
|
||||||
If you do not use `defer`, `katex` object will be available after the corresponding
|
|
||||||
`script` tag.
|
|
||||||
|
|
||||||
If KaTeX is not used immediately or not critical, it is possible to load KaTeX
|
|
||||||
asynchronously. Add [`async` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to `script` and use [`rel="preload"` and `onload` attribute](https://github.com/filamentgroup/loadCSS)
|
|
||||||
on `link`.
|
|
||||||
|
|
||||||
You can prefetch KaTeX fonts to prevent FOUT or FOIT. Use [Font Loading API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API)
|
|
||||||
or [Web Font Loader](https://github.com/typekit/webfontloader):
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
window.WebFontConfig = {
|
|
||||||
custom: {
|
|
||||||
families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7',
|
|
||||||
'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script',
|
|
||||||
'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3',
|
|
||||||
'KaTeX_Size4', 'KaTeX_Typewriter'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use [`rel="preload"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content).
|
|
||||||
Add `<link rel="preload" href=(path to WOFF2 font) as="font" type="font/woff2" crossorigin="anonymous">`
|
|
||||||
to `head`. Note that [only few browsers support it](https://caniuse.com/#feat=link-rel-preload)
|
|
||||||
and they all support WOFF2 so preloading WOFF2 fonts is enough.
|
|
||||||
|
|
||||||
See [Google Web Fundamentals - Web Font Optimization](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/webfont-optimization)
|
|
||||||
for more detail.
|
|
||||||
|
|
||||||
## Module Loaders
|
|
||||||
### AMD
|
|
||||||
```html
|
|
||||||
<script type="text/javascript">
|
|
||||||
require([
|
|
||||||
"https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.js",
|
|
||||||
], katex => {
|
|
||||||
...
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.css" integrity="sha384-IfEbO0yhy2n4/+OZc9LUjnq7UDEUifPgfe34YcKod1rOJyX0JNBJ4/6XKpclZtj3" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
### ECMAScript module
|
|
||||||
```html
|
|
||||||
<script type="module" type="text/javascript">
|
|
||||||
import katex from 'https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.mjs';
|
|
||||||
...
|
|
||||||
</script>
|
|
||||||
<script nomodule defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.js" integrity="sha384-07m3BXnpyYn3KtPIt7XjRYaNz2mc2OKdnUmRGNQxx7cMbT78d1JTy71cyEiCBQHr" crossorigin="anonymous"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.css" integrity="sha384-IfEbO0yhy2n4/+OZc9LUjnq7UDEUifPgfe34YcKod1rOJyX0JNBJ4/6XKpclZtj3" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
> Use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules.
|
|
||||||
|
|
||||||
## Download & Host Things Yourself
|
|
||||||
Download a [KaTeX release](https://github.com/KaTeX/KaTeX/releases),
|
|
||||||
copy `katex.js`, `katex.css`
|
|
||||||
(or `katex.min.js` and `katex.min.css` to use minified versions),
|
|
||||||
and the `fonts` directory, and include or import it like above.
|
|
||||||
|
|
||||||
You can also build from source. See [Building from Source](node.md#building-from-source)
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
## Bundler
|
|
||||||
[Use Node.js package managers to install KaTeX and import it](node.md) in your
|
|
||||||
project. Then bundle using bundlers like [webpack](https://webpack.js.org/) or
|
|
||||||
[rollup.js](https://rollupjs.org/). Note that you have to bundle the stylesheet
|
|
||||||
(`katex.css`) or include it manually.
|
|
@@ -1,47 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.0-font
|
|
||||||
title: Font
|
|
||||||
original_id: font
|
|
||||||
---
|
|
||||||
By changing the variables in the `fonts.less` file at the [katex-fonts submodule](https://github.com/KaTeX/katex-fonts/),
|
|
||||||
several properties of the way fonts are used can be changed.
|
|
||||||
|
|
||||||
## Font size and lengths
|
|
||||||
By default, KaTeX math is rendered in a 1.21× larger font than the surrounding
|
|
||||||
context, which makes super- and subscripts easier to read. You can control
|
|
||||||
this using CSS, for example, to set to 1.1×:
|
|
||||||
|
|
||||||
```css
|
|
||||||
.katex { font-size: 1.1em; }
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX supports all TeX units, including absolute units like `cm` and `in`.
|
|
||||||
Absolute units are currently scaled relative to the default TeX font size of
|
|
||||||
10pt, so that `\kern1cm` produces the same results as `\kern2.845275em`.
|
|
||||||
As a result, relative and absolute units are both uniformly scaled relative
|
|
||||||
to LaTeX with a 10pt font; for example, the rectangle `\rule{1cm}{1em}` has
|
|
||||||
the same aspect ratio in KaTeX as in LaTeX. However, because most browsers
|
|
||||||
default to a larger font size, this typically means that a 1cm kern in KaTeX
|
|
||||||
will appear larger than 1cm in browser units.
|
|
||||||
|
|
||||||
## Kinds of fonts used
|
|
||||||
|
|
||||||
KaTeX provides fonts in three different formats: `ttf`, `woff`, and `woff2`.
|
|
||||||
|
|
||||||
- `ttf`s are included to support very old browsers and local installation. [Browser support](https://caniuse.com/#feat=ttf)
|
|
||||||
- `woff` is the format that is most widely supported (all modern browsers support it), so it probably provides the most benefit to being included. [Browser support](https://caniuse.com/#feat=woff)
|
|
||||||
- `woff2`s are included for modern browsers, because they are much smaller and faster to load. [Browser support](https://caniuse.com/#feat=woff2)
|
|
||||||
|
|
||||||
KaTeX will automatically include only necessary fonts for target environments
|
|
||||||
specified by [Browserslist config](https://github.com/browserslist/browserslist#queries).
|
|
||||||
|
|
||||||
To force a font type to be included or excluded, set `USE_(FONT NAME)` environment
|
|
||||||
variable to `"true"` or `"false"`, respectively.`
|
|
||||||
|
|
||||||
## Location of font files
|
|
||||||
|
|
||||||
The default build of KaTeX expects the KaTeX fonts to be located in a directory called `fonts` which is a sibling of the `katex.min.css` stylesheet. This can be changed as follows:
|
|
||||||
|
|
||||||
1. At the top of the [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less) file, set `@font-folder` to the location of your fonts. You can use relative or absolute paths, so setting it to `"/fonts"` would cause it to search for the fonts in a root `fonts` folder, while `"../fonts"` would search in a `fonts` directory one level above the `katex.min.css` file.
|
|
||||||
2. Rebuild KaTeX by running `yarn build` from the top-level directory.
|
|
||||||
3. Use the newly generated `dist/katex.min.css` file, and place the fonts where you indicated.
|
|
@@ -1,47 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.0-issues
|
|
||||||
title: Common Issues
|
|
||||||
original_id: issues
|
|
||||||
---
|
|
||||||
- Be sure to include `<!DOCTYPE html>` at the top of your HTML file, as
|
|
||||||
otherwise your browser will render in "[quirks mode](https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode)"
|
|
||||||
which can cause KaTeX to sometimes render incorrectly.
|
|
||||||
This header is needed even inside `<iframe>`s
|
|
||||||
(which don't inherit the parent document's doctype).
|
|
||||||
- Many Markdown preprocessors, such as the one that Jekyll and GitHub Pages use,
|
|
||||||
have a "smart quotes" feature. This changes `'` to `’` which is an issue for
|
|
||||||
math containing primes, e.g. `f'`. This can be worked around by defining a
|
|
||||||
single character macro which changes them back, e.g. `{"’", "'"}`.
|
|
||||||
- KaTeX follows LaTeX's rendering of `aligned` and `matrix` environments unlike
|
|
||||||
MathJax. When displaying fractions one above another in these vertical
|
|
||||||
layouts there may not be enough space between rows for people who are used to
|
|
||||||
MathJax's rendering. The distance between rows can be adjusted by using
|
|
||||||
`\\[0.1em]` instead of the standard line separator distance.
|
|
||||||
- KaTeX does not support the `align` environment because LaTeX doesn't support
|
|
||||||
`align` in math mode. The `aligned` environment offers the same functionality
|
|
||||||
but in math mode, so use that instead.
|
|
||||||
- MathJax defines `\color` to be like `\textcolor` by default; set KaTeX's
|
|
||||||
`colorIsTextColor` option to `true` for this behavior. KaTeX's default
|
|
||||||
behavior matches MathJax with its `color.js` extension enabled.
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
To check the stylesheet (katex.css) is properly loaded, add following code to
|
|
||||||
anywhere in the document:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<style>
|
|
||||||
.katex-version {display: none;}
|
|
||||||
.katex-version::after {content:"0.10.2 or earlier";}
|
|
||||||
</style>
|
|
||||||
<span class="katex">
|
|
||||||
<span class="katex-mathml">The KaTeX stylesheet is not loaded!</span>
|
|
||||||
<span class="katex-version rule">KaTeX stylesheet version: </span>
|
|
||||||
</span>
|
|
||||||
```
|
|
||||||
|
|
||||||
If it is loaded properly, it'll show its version. Make sure its version matches
|
|
||||||
the version of the JavaScript file (katex.js), which is defined in `katex.version`.
|
|
||||||
If it is not loaded properly, it'll show:
|
|
||||||
|
|
||||||
> The KaTeX stylesheet is not loaded!
|
|
@@ -1,53 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.0-libs
|
|
||||||
title: Extensions & Libraries
|
|
||||||
original_id: libs
|
|
||||||
---
|
|
||||||
## Extensions
|
|
||||||
|
|
||||||
These extensions are provided by KaTeX.
|
|
||||||
|
|
||||||
- [Auto-render](autorender.md): Automatically renders all of the math inside text
|
|
||||||
- [Copy-tex](https://github.com/Khan/KaTeX/tree/master/contrib/copy-tex): When selecting and copying KaTeX-rendered elements, copies their LaTeX source to the clipboard
|
|
||||||
- [`math/tex` Custom Script Type](https://github.com/Khan/KaTeX/tree/master/contrib/mathtex-script-type): Automatically displays LaTeX math inside `script` tags with `type=math/tex`
|
|
||||||
- [mhchem](https://github.com/Khan/KaTeX/tree/master/contrib/mhchem): Write beautiful chemical equations easily
|
|
||||||
|
|
||||||
## Libraries
|
|
||||||
|
|
||||||
These libraries are maintained by third-parties.
|
|
||||||
|
|
||||||
### Angular2+
|
|
||||||
- [ng-katex](https://github.com/garciparedes/ng-katex): Angular module to write beautiful math expressions with TeX syntax boosted by KaTeX library
|
|
||||||
|
|
||||||
### iOS
|
|
||||||
- [KaTeX-iOS](https://github.com/ianarawjo/KaTeX-iOS): iOS UIView that renders TeX expressions with KaTeX
|
|
||||||
|
|
||||||
### Android
|
|
||||||
- [KaTeXView](https://github.com/judemanutd/KaTeXView): An android library that uses Khan Academy KaTeX for TeX math rendering.
|
|
||||||
|
|
||||||
### React
|
|
||||||
- [react-latex](https://github.com/zzish/react-latex): React component to render latex strings, based on KaTeX
|
|
||||||
- [react-katex](https://github.com/talyssonoc/react-katex): React components that use KaTeX to typeset math expressions
|
|
||||||
|
|
||||||
### Ruby
|
|
||||||
|
|
||||||
- [katex-ruby](https://github.com/glebm/katex-ruby): Provides server-side rendering and integration with popular Ruby web frameworks (Rails, Hanami, and anything that uses Sprockets).
|
|
||||||
|
|
||||||
### Vue
|
|
||||||
- [vue-katex](https://github.com/lucpotage/vue-katex): Vue plugin to render TeX expressions using KaTeX.
|
|
||||||
|
|
||||||
### AsciiMath
|
|
||||||
|
|
||||||
If you want to render math written in [AsciiMath](http://asciimath.org/),
|
|
||||||
you'll need to first convert AsciiMath into LaTeX input, then call KaTeX.
|
|
||||||
|
|
||||||
- [asciimath2tex](https://github.com/christianp/asciimath2tex): Converts AsciiMath to TeX, with KaTeX in mind
|
|
||||||
|
|
||||||
### Canvas LaTeX
|
|
||||||
|
|
||||||
- [canvas-latex](https://github.com/CurriculumAssociates/canvas-latex): Renders mathematical expressions on HTML5's canvas element. Supports popular libraries like: CreateJS, and PIXI.
|
|
||||||
|
|
||||||
### Web-Components
|
|
||||||
|
|
||||||
- [katex-element](https://github.com/georges-gomes/katex-element): KaTeX wrapped in a custom element. Simply use `<katex-element>` in HTML - framework independent.
|
|
||||||
- [katex-expression](https://github.com/navsgh/katex-expression): A web component/custom element (built with Stencil) to render KaTeX expressions. Stencil builds web components that run natively or near-natively in all widely used desktop and mobile browsers. Stencil uses a dynamic loader to load the custom elements polyfill only on browsers that need it.
|
|
@@ -1,65 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.0-options
|
|
||||||
title: Options
|
|
||||||
original_id: options
|
|
||||||
---
|
|
||||||
You can provide an object of options as the last argument to [`katex.render` and `katex.renderToString`](api.md). Available options are:
|
|
||||||
|
|
||||||
- `displayMode`: `boolean`. If `true` the math will be rendered in display mode, which will put the math in display style (so `\int` and `\sum` are large, for example), and will center the math on the page on its own line. If `false` the math will be rendered in inline mode. (default: `false`)
|
|
||||||
- `output`: `string`. Determines the markup language of the output. The valid choices are:
|
|
||||||
- `html`: Outputs KaTeX in HTML only.
|
|
||||||
- `mathml`: Outputs KaTeX in MathML only.
|
|
||||||
- `htmlAndMathml`: Outputs HTML for visual rendering and includes MathML for accessibility. This is the default.
|
|
||||||
- `leqno`: `boolean`. If `true`, display math has `\tag`s rendered on the left instead of the right, like `\usepackage[leqno]{amsmath}` in LaTeX.
|
|
||||||
- `fleqn`: `boolean`. If `true`, display math renders flush left, like `\documentclass[fleqn]` in LaTeX.
|
|
||||||
- `throwOnError`: `boolean`. If `true` (the default), KaTeX will throw a `ParseError` when it encounters an unsupported command or invalid LaTeX. If `false`, KaTeX will render unsupported commands as text, and render invalid LaTeX as its source code with hover text giving the error, in the color given by `errorColor`.
|
|
||||||
- `errorColor`: `string`. A color string given in the format `"#XXX"` or `"#XXXXXX"`. This option determines the color that unsupported commands and invalid LaTeX are rendered in when `throwOnError` is set to `false`. (default: `#cc0000`)
|
|
||||||
- `macros`: `object`. A collection of custom macros. Each macro is a property with a name like `\name` (written `"\\name"` in JavaScript) which maps to a string that describes the expansion of the macro, or a function that accepts an instance of `MacroExpander` as first argument and returns the expansion as a string. `MacroExpander` is an internal API and subject to non-backwards compatible changes. See [`src/macros.js`](https://github.com/KaTeX/KaTeX/blob/master/src/macros.js) for its usage. Single-character keys can also be included in which case the character will be redefined as the given macro (similar to TeX active characters). *This object will be modified* if the LaTeX code defines its own macros via `\gdef`, which enables consecutive calls to KaTeX to share state.
|
|
||||||
- `minRuleThickness`: `number`. Specifies a minimum thickness, in ems, for fraction lines, `\sqrt` top lines, `{array}` vertical lines, `\hline`, `\hdashline`, `\underline`, `\overline`, and the borders of `\fbox`, `\boxed`, and `\fcolorbox`. The usual value for these items is `0.04`, so for `minRuleThickness` to be effective it should probably take a value slightly above `0.04`, say `0.05` or `0.06`. Negative values will be ignored.
|
|
||||||
- `colorIsTextColor`: `boolean`. If `true`, `\color` will work like LaTeX's `\textcolor`, and take two arguments (e.g., `\color{blue}{hello}`), which restores the old behavior of KaTeX (pre-0.8.0). If `false` (the default), `\color` will work like LaTeX's `\color`, and take one argument (e.g., `\color{blue}hello`). In both cases, `\textcolor` works as in LaTeX (e.g., `\textcolor{blue}{hello}`).
|
|
||||||
- `maxSize`: `number`. All user-specified sizes, e.g. in `\rule{500em}{500em}`, will be capped to `maxSize` ems. If set to `Infinity` (the default), users can make elements and spaces arbitrarily large.
|
|
||||||
- `maxExpand`: `number`. Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to `Infinity`, the macro expander will try to fully expand as in LaTeX. (default: 1000)
|
|
||||||
- `strict`: `boolean` or `string` or `function` (default: `"warn"`). If `false` or `"ignore`", allow features that make writing LaTeX convenient but are not actually supported by (Xe)LaTeX (similar to MathJax). If `true` or `"error"` (LaTeX faithfulness mode), throw an error for any such transgressions. If `"warn"` (the default), warn about such behavior via `console.warn`. Provide a custom function `handler(errorCode, errorMsg, token)` to customize behavior depending on the type of transgression (summarized by the string code `errorCode` and detailed in `errorMsg`); this function can also return `"ignore"`, `"error"`, or `"warn"` to use a built-in behavior. A list of such features and their `errorCode`s:
|
|
||||||
|
|
||||||
- `"unknownSymbol"`: Use of unknown Unicode symbol, which will likely also
|
|
||||||
lead to warnings about missing character metrics, and layouts may be
|
|
||||||
incorrect (especially in terms of vertical heights).
|
|
||||||
- `"unicodeTextInMathMode"`: Use of Unicode text characters in math mode.
|
|
||||||
- `"mathVsTextUnits"`: Mismatch of math vs. text commands and units/mode.
|
|
||||||
- `"commentAtEnd"`: Use of `%` comment without a terminating newline.
|
|
||||||
LaTeX would thereby comment out the end of math mode (e.g. `$`),
|
|
||||||
causing an error.
|
|
||||||
|
|
||||||
A second category of `errorCode`s never throw errors, but their strictness
|
|
||||||
affects the behavior of KaTeX:
|
|
||||||
|
|
||||||
- `"newLineInDisplayMode"`: Use of `\\` or `\newline` in display mode
|
|
||||||
(outside an array/tabular environment). In strict mode, no line break
|
|
||||||
results, as in LaTeX.
|
|
||||||
|
|
||||||
- `trust`: `boolean` or `function` (default: `false`). If `false` (do not trust input), prevent any commands like `\includegraphics` that could enable adverse behavior, rendering them instead in `errorColor`. If `true` (trust input), allow all such commands. Provide a custom function `handler(context)` to customize behavior depending on the context (command, arguments e.g. a URL, etc.). A list of possible contexts:
|
|
||||||
|
|
||||||
- `{command: "\\url", url, protocol}`
|
|
||||||
- `{command: "\\href", url, protocol}`
|
|
||||||
- `{command: "\\includegraphics", url, protocol}`
|
|
||||||
|
|
||||||
Here are some sample trust settings:
|
|
||||||
|
|
||||||
- Forbid specific command: `trust: (context) => context.command !== '\\includegraphics'`
|
|
||||||
- Allow specific command: `trust: (context) => context.command === '\\url'`
|
|
||||||
- Allow multiple specific commands: `trust: (context) => ['\\url', '\\href'].includes(context.command)`
|
|
||||||
- Allow all commands with a specific protocol: `trust: (context) => context.protocol === 'http'`
|
|
||||||
- Allow all commands with specific protocols: `trust: (context) => ['http', 'https', '_relative'].includes(context.protocol)`
|
|
||||||
- Allow all commands but forbid specific protocol: `trust: (context) => context.protocol !== 'file'`
|
|
||||||
- Allow certain commands with specific protocols: `trust: (context) => ['\\url', '\\href'].includes(context.command) && ['http', 'https', '_relative'].includes(context.protocol)`
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
katex.render("c = \\pm\\sqrt{a^2 + b^2}\\in\\RR", element, {
|
|
||||||
displayMode: true,
|
|
||||||
macros: {
|
|
||||||
"\\RR": "\\mathbb{R}"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
@@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.0-security
|
|
||||||
title: Security
|
|
||||||
original_id: security
|
|
||||||
---
|
|
||||||
Any HTML generated by KaTeX *should* be safe from `<script>` or other code
|
|
||||||
injection attacks.
|
|
||||||
|
|
||||||
Of course, it is always a good idea to sanitize the HTML, though you will need
|
|
||||||
a rather generous whitelist (including some of SVG and MathML) to support
|
|
||||||
all of KaTeX.
|
|
||||||
|
|
||||||
A variety of options give finer control over the security of KaTeX
|
|
||||||
with untrusted inputs; refer to [Options](options.md) for more details.
|
|
||||||
* `maxSize` can prevent large width/height visual affronts.
|
|
||||||
* `maxExpand` can prevent infinite macro loop attacks.
|
|
||||||
* `trust` can allow certain commands that are not always safe (e.g., `\includegraphics`)
|
|
||||||
|
|
||||||
The error message thrown by KaTeX may contain unescaped LaTeX source code.
|
|
||||||
See [Handling Errors](error.md) for more details.
|
|
||||||
|
|
||||||
> If you discovered a security issue, please let us know via https://hackerone.com/khanacademy
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,658 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.0-supported
|
|
||||||
title: Supported Functions
|
|
||||||
original_id: supported
|
|
||||||
---
|
|
||||||
This is a list of TeX functions supported by KaTeX. It is sorted into logical groups.
|
|
||||||
|
|
||||||
There is a similar [Support Table](support_table.md), sorted alphabetically, that lists both supported and un-supported functions.
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/static/katex.min.css"/>
|
|
||||||
<style>
|
|
||||||
p {overflow-wrap: break-word;}
|
|
||||||
table tr,
|
|
||||||
table td {
|
|
||||||
vertical-align: middle;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Accents
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------------------------|:----------------------------------------------------|:-----
|
|
||||||
|$a'$ `a'` |$\tilde{a}$ `\tilde{a}`|$\mathring{g}$ `\mathring{g}`
|
|
||||||
|$a''$ `a''`|$\widetilde{ac}$ `\widetilde{ac}` |$\overgroup{AB}$ `\overgroup{AB}`
|
|
||||||
|$a^{\prime}$ `a^{\prime}` |$\utilde{AB}$ `\utilde{AB}` |$\undergroup{AB}$ `\undergroup{AB}`
|
|
||||||
|$\acute{a}$ `\acute{a}`|$\vec{F}$ `\vec{F}` |$\Overrightarrow{AB}$ `\Overrightarrow{AB}`
|
|
||||||
|$\bar{y}$ `\bar{y}` |$\overleftarrow{AB}$ `\overleftarrow{AB}`|$\overrightarrow{AB}$ `\overrightarrow{AB}`
|
|
||||||
|$\breve{a}$ `\breve{a}`|$\underleftarrow{AB}$ `\underleftarrow{AB}` |$\underrightarrow{AB}$ `\underrightarrow{AB}`
|
|
||||||
|$\check{a}$ `\check{a}`|$\overleftharpoon{ac}$ `\overleftharpoon{ac}` |$\overrightharpoon{ac}$ `\overrightharpoon{ac}`
|
|
||||||
|$\dot{a}$ `\dot{a}` |$\overleftrightarrow{AB}$ `\overleftrightarrow{AB}` |$\overbrace{AB}$ `\overbrace{AB}`
|
|
||||||
|$\ddot{a}$ `\ddot{a}` |$\underleftrightarrow{AB}$ `\underleftrightarrow{AB}`|$\underbrace{AB}$ `\underbrace{AB}`
|
|
||||||
|$\grave{a}$ `\grave{a}`|$\overline{AB}$ `\overline{AB}` |$\overlinesegment{AB}$ `\overlinesegment{AB}`
|
|
||||||
|$\hat{\theta}$ `\hat{\theta}`|$\underline{AB}$ `\underline{AB}` |$\underlinesegment{AB}$ `\underlinesegment{AB}`
|
|
||||||
|$\widehat{ac}$ `\widehat{ac}`|$\widecheck{ac}$ `\widecheck{ac}` |
|
|
||||||
|
|
||||||
***Accent functions inside \\text{…}***
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:-----
|
|
||||||
|$\text{\'{a}}$ `\'{a}`|$\text{\~{a}}$ `\~{a}`|$\text{\.{a}}$ `\.{a}`|$\text{\H{a}}$ `\H{a}`
|
|
||||||
|$\text{\`{a}}$ <code>\\`{a}</code>|$\text{\={a}}$ `\={a}`|$\text{\"{a}}$ `\"{a}`|$\text{\v{a}}$ `\v{a}`
|
|
||||||
|$\text{\^{a}}$ `\^{a}`|$\text{\u{a}}$ `\u{a}`|$\text{\r{a}}$ `\r{a}`|
|
|
||||||
|
|
||||||
See also [letters](#letters)
|
|
||||||
|
|
||||||
## Delimiters
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:-----------------------------------|:---------------------------------------|:----------|:-------------------------------------------------------|:-----
|
|
||||||
|$(~)$ `( )` |$\lparen~\rparen$ `\lparen`<br>$~~~~$`\rparen`|$⌈~⌉$ `⌈ ⌉`|$\lceil~\rceil$ `\lceil`<br>$~~~~~$`\rceil` |$\uparrow$ `\uparrow`
|
|
||||||
|$[~]$ `[ ]` |$\lbrack~\rbrack$ `\lbrack`<br>$~~~~$`\rbrack`|$⌊~⌋$ `⌊ ⌋`|$\lfloor~\rfloor$ `\lfloor`<br>$~~~~~$`\rfloor` |$\downarrow$ `\downarrow`
|
|
||||||
|$\{ \}$ `\{ \}`|$\lbrace \rbrace$ `\lbrace`<br>$~~~~$`\rbrace`|$⎰⎱$ `⎰⎱` |$\lmoustache \rmoustache$ `\lmoustache`<br>$~~~~$`\rmoustache`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$⟨~⟩$ `⟨ ⟩` |$\langle~\rangle$ `\langle`<br>$~~~~$`\rangle`|$⟮~⟯$ `⟮ ⟯`|$\lgroup~\rgroup$ `\lgroup`<br>$~~~~~$`\rgroup` |$\Uparrow$ `\Uparrow`
|
|
||||||
|$\vert$ <code>|</code> |$\vert$ `\vert` |$┌ ┐$ `┌ ┐`|$\ulcorner \urcorner$ `\ulcorner`<br>$~~~~$`\urcorner` |$\Downarrow$ `\Downarrow`
|
|
||||||
|$\Vert$ <code>\|</code> |$\Vert$ `\Vert` |$└ ┘$ `└ ┘`|$\llcorner \lrcorner$ `\llcorner`<br>$~~~~$`\lrcorner` |$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\lvert~\rvert$ `\lvert`<br>$~~~~$`\rvert`|$\lVert~\rVert$ `\lVert`<br>$~~~~~$`\rVert` |`\left.`| `\right.` |$\backslash$ `\backslash`
|
|
||||||
|$\lang~\rang$ `\lang`<br>$~~~~$`\rang`|$\lt~\gt$ `\lt \gt`|$⟦~⟧$ `⟦ ⟧`|$\llbracket~\rrbracket$ `\llbracket`<br>$~~~~$`\rrbracket`|$\lBrace~\rBrace$ `\lBrace \rBrace`
|
|
||||||
|
|
||||||
**Delimiter Sizing**
|
|
||||||
|
|
||||||
$\left(\LARGE{AB}\right)$ `\left(\LARGE{AB}\right)`
|
|
||||||
|
|
||||||
$( \big( \Big( \bigg( \Bigg($ `( \big( \Big( \bigg( \Bigg(`
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:--------|:------|:--------|:-------|:------|
|
|
||||||
|`\left` |`\big` |`\bigl` |`\bigm` |`\bigr`
|
|
||||||
|`\middle`|`\Big` |`\Bigl` |`\Bigm` | `\Bigr`
|
|
||||||
|`\right` |`\bigg`|`\biggl` |`\biggm`|`\biggr`
|
|
||||||
| |`\Bigg`|`\Biggl` |`\Biggm`|`\Biggr`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Environments
|
|
||||||
|
|
||||||
<div class="katex-cards" id="environments">
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:--------
|
|
||||||
|$\begin{matrix} a & b \\ c & d \end{matrix}$ | `\begin{matrix}`<br> `a & b \\`<br> `c & d`<br>`\end{matrix}` |$\begin{array}{cc}a & b\\c & d\end{array}$ | `\begin{array}{cc}`<br> `a & b \\`<br> `c & d`<br>`\end{array}`
|
|
||||||
|$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$ |`\begin{pmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{pmatrix}` |$\begin{bmatrix} a & b \\ c & d \end{bmatrix}$ | `\begin{bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{bmatrix}`
|
|
||||||
|$\begin{vmatrix} a & b \\ c & d \end{vmatrix}$ |`\begin{vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{vmatrix}` |$\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}$ |`\begin{Vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Vmatrix}`
|
|
||||||
|$\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}$ |`\begin{Bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Bmatrix}`|$\def\arraystretch{1.5}\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}$|`\def\arraystretch{1.5}`<br> `\begin{array}{c:c:c}`<br> `a & b & c \\ \hline`<br> `d & e & f \\`<br> `\hdashline`<br> `g & h & i`<br>`\end{array}`
|
|
||||||
|$\begin{aligned} a&=b+c \\ d+e&=f \end{aligned}$ |`\begin{aligned}`<br> `a&=b+c \\`<br> `d+e&=f`<br>`\end{aligned}`|$\begin{alignedat}{2}10&x+&3&y=2\\3&x+&13&y=4\end{alignedat}$ |`\begin{alignedat}{2}`<br> `10&x+ &3&y = 2 \\`<br> ` 3&x+&13&y = 4`<br>`\end{alignedat}`
|
|
||||||
|$\begin{gathered} a=b \\ e=b+c \end{gathered}$ |`\begin{gathered}`<br> `a=b \\ `<br> `e=b+c`<br>`\end{gathered}`|$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$ |`x = \begin{cases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{cases}`
|
|
||||||
|$\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}$ | `\begin{smallmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{smallmatrix}` | | |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
KaTeX also supports `darray` and `dcases`.
|
|
||||||
|
|
||||||
Acceptable line separators include: `\\`, `\cr`, `\\[distance]`, and `\cr[distance]`. *Distance* can be written with any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
The `{array}` environment supports `|` and `:` vertical separators.
|
|
||||||
|
|
||||||
The `{array}` environment does not yet support `\cline` or `\multicolumn`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## HTML
|
|
||||||
|
|
||||||
The following "raw HTML" features are potentially dangerous for untrusted
|
|
||||||
inputs, so they are disabled by default, and attempting to use them produces
|
|
||||||
the command names in red (which you can configure via the `errorColor`
|
|
||||||
[option](options.md)). To fully trust your LaTeX input, you need to pass
|
|
||||||
an option of `trust: true`; you can also enable just some of the commands
|
|
||||||
or for just some URLs via the `trust` [option](options.md).
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------|:-------------------|
|
|
||||||
| $\href{https://katex.org/}{\KaTeX}$ | `\href{https://katex.org/}{\KaTeX}` |
|
|
||||||
| $\url{https://katex.org/}$ | `\url{https://katex.org/}` |
|
|
||||||
| $\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://katex.org/img/khan-academy.png}$ | `\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://katex.org/img/khan-academy.png}` |
|
|
||||||
|
|
||||||
`\includegraphics` supports `height`, `width`, `totalheight`, and `alt` in its first argument. `height` is required.
|
|
||||||
|
|
||||||
|
|
||||||
## Letters and Unicode
|
|
||||||
|
|
||||||
**Greek Letters**
|
|
||||||
|
|
||||||
Direct Input: $Α Β Γ Δ Ε Ζ Η Θ Ι \allowbreak Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω$
|
|
||||||
$\allowbreak α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π \allowbreak ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ ϝ$
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|---------------|-------------|-------------|---------------|
|
|
||||||
| $\Alpha$ `\Alpha` | $\Beta$ `\Beta` | $\Gamma$ `\Gamma`| $\Delta$ `\Delta`
|
|
||||||
| $\Epsilon$ `\Epsilon` | $\Zeta$ `\Zeta` | $\Eta$ `\Eta` | $\Theta$ `\Theta`
|
|
||||||
| $\Iota$ `\Iota` | $\Kappa$ `\Kappa` | $\Lambda$ `\Lambda` | $\Mu$ `\Mu`
|
|
||||||
| $\Nu$ `\Nu` | $\Xi$ `\Xi` | $\Omicron$ `\Omicron` | $\Pi$ `\Pi`
|
|
||||||
| $\Rho$ `\Rho` | $\Sigma$ `\Sigma` | $\Tau$ `\Tau` | $\Upsilon$ `\Upsilon`
|
|
||||||
| $\Phi$ `\Phi` | $\Chi$ `\Chi` | $\Psi$ `\Psi` | $\Omega$ `\Omega`
|
|
||||||
| $\varGamma$ `\varGamma`| $\varDelta$ `\varDelta` | $\varTheta$ `\varTheta` | $\varLambda$ `\varLambda` |
|
|
||||||
| $\varXi$ `\varXi`| $\varPi$ `\varPi` | $\varSigma$ `\varSigma` | $\varUpsilon$ `\varUpsilon` |
|
|
||||||
| $\varPhi$ `\varPhi` | $\varPsi$ `\varPsi`| $\varOmega$ `\varOmega` ||
|
|
||||||
| $\alpha$ `\alpha`| $\beta$ `\beta` | $\gamma$ `\gamma` | $\delta$ `\delta`|
|
|
||||||
| $\epsilon$ `\epsilon` | $\zeta$ `\zeta` | $\eta$ `\eta`| $\theta$ `\theta`|
|
|
||||||
| $\iota$ `\iota` | $\kappa$ `\kappa` | $\lambda$ `\lambda`| $\mu$ `\mu`|
|
|
||||||
| $\nu$ `\nu`| $\xi$ `\xi` | $\omicron$ `\omicron` | $\pi$ `\pi`|
|
|
||||||
| $\rho$ `\rho` | $\sigma$ `\sigma` | $\tau$ `\tau`| $\upsilon$ `\upsilon` |
|
|
||||||
| $\phi$ `\phi` | $\chi$ `\chi`| $\psi$ `\psi`| $\omega$ `\omega`|
|
|
||||||
| $\varepsilon$ `\varepsilon` | $\varkappa$ `\varkappa` | $\vartheta$ `\vartheta` | $\thetasym$ `\thetasym`
|
|
||||||
| $\varpi$ `\varpi`| $\varrho$ `\varrho` | $\varsigma$ `\varsigma` | $\varphi$ `\varphi`
|
|
||||||
| $\digamma $ `\digamma`
|
|
||||||
|
|
||||||
**Other Letters**
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:----------|:----------|:----------|:----------|:----------|
|
|
||||||
|$\imath$ `\imath`|$\nabla$ `\nabla`|$\Im$ `\Im`|$\Reals$ `\Reals`|$\text{\OE}$ `\text{\OE}`
|
|
||||||
|$\jmath$ `\jmath`|$\partial$ `\partial`|$\image$ `\image`|$\wp$ `\wp`|$\text{\o}$ `\text{\o}`
|
|
||||||
|$\aleph$ `\aleph`|$\Game$ `\Game`|$\Bbbk$ `\Bbbk`|$\weierp$ `\weierp`|$\text{\O}$ `\text{\O}`
|
|
||||||
|$\alef$ `\alef`|$\Finv$ `\Finv`|$\N$ `\N`|$\Z$ `\Z`|$\text{\ss}$ `\text{\ss}`
|
|
||||||
|$\alefsym$ `\alefsym`|$\cnums$ `\cnums`|$\natnums$ `\natnums`|$\text{\aa}$ `\text{\aa}`|$\text{\i}$ `\text{\i}`
|
|
||||||
|$\beth$ `\beth`|$\Complex$ `\Complex`|$\R$ `\R`|$\text{\AA}$ `\text{\AA}`|$\text{\j}$ `\text{\j}`
|
|
||||||
|$\gimel$ `\gimel`|$\ell$ `\ell`|$\Re$ `\Re`|$\text{\ae}$ `\text{\ae}`
|
|
||||||
|$\daleth$ `\daleth`|$\hbar$ `\hbar`|$\real$ `\real`|$\text{\AE}$ `\text{\AE}`
|
|
||||||
|$\eth$ `\eth`|$\hslash$ `\hslash`|$\reals$ `\reals`|$\text{\oe}$ `\text{\oe}`
|
|
||||||
|
|
||||||
Direct Input: $∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð$
|
|
||||||
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåçèéêëìíîïðñòóôöùúûüýþÿ
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="math-alpha">
|
|
||||||
|
|
||||||
**Unicode Mathematical Alphanumeric Symbols**
|
|
||||||
|
|
||||||
| Item | Range | Item | Range |
|
|
||||||
|-------------|---------------------|-------------------|---------------|
|
|
||||||
| Bold | $\text{𝐀-𝐙 𝐚-𝐳 𝟎-𝟗}$ | Double-struck | $\text{𝔸-}ℤ\ 𝕜$
|
|
||||||
| Italic | $\text{𝐴-𝑍 𝑎-𝑧}$ | Sans serif | $\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}$
|
|
||||||
| Bold Italic | $\text{𝑨-𝒁 𝒂-𝒛}$ | Sans serif bold | $\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}$
|
|
||||||
| Script | $\text{𝒜-𝒵}$ | Sans serif italic | $\text{𝘈-𝘡 𝘢-𝘻}$
|
|
||||||
| Fractur | $\text{𝔄-}ℨ\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
**Unicode**
|
|
||||||
|
|
||||||
The letters listed above will render properly in any KaTeX rendering mode.
|
|
||||||
|
|
||||||
In addition, Brahmic, Georgian, Chinese, Japanese, and Korean glyphs are always accepted in text mode. However, these glyphs will be rendered from system fonts (not KaTeX-supplied fonts) so their typography may clash.
|
|
||||||
You can provide rules for CSS classes `.latin_fallback`, `.cyrillic_fallback`, `.brahmic_fallback`, `.georgian_fallback`, `.cjk_fallback`, and `.hangul_fallback` to provide fallback fonts for these languages.
|
|
||||||
Use of these glyphs may cause small vertical alignment issues: KaTeX has detailed metrics for listed symbols and most Latin, Greek, and Cyrillic letters, but other accepted glyphs are treated as if they are each as tall as the letter M in the current KaTeX font.
|
|
||||||
|
|
||||||
If the KaTeX rendering mode is set to `strict: false` or `strict: "warn"` (default), then KaTeX will accept all Unicode letters in both text and math mode.
|
|
||||||
All unrecognized characters will be treated as if they appeared in text mode, and are subject to the same issues of using system fonts and possibly using incorrect vertical alignment.
|
|
||||||
|
|
||||||
For Persian composite characters, a user-supplied [plug-in](https://github.com/HosseinAgha/persian-katex-plugin) is under development.
|
|
||||||
|
|
||||||
## Layout
|
|
||||||
|
|
||||||
### Annotation
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:------------------------------|:-----
|
|
||||||
|$\cancel{5}$ `\cancel{5}`|$\overbrace{a+b+c}^{\text{note}}$ `\overbrace{a+b+c}^{\text{note}}`
|
|
||||||
|$\bcancel{5}$ `\bcancel{5}` |$\underbrace{a+b+c}_{\text{note}}$ `\underbrace{a+b+c}_{\text{note}}`
|
|
||||||
|$\xcancel{ABC}$ `\xcancel{ABC}`|$\not =$ `\not =`
|
|
||||||
|$\sout{abc}$ `\sout{abc}`|$\boxed{\pi=\frac c d}$ `\boxed{\pi=\frac c d}`
|
|
||||||
|
|
||||||
`\tag{hi} x+y^{2x}`
|
|
||||||
$$\tag{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
`\tag*{hi} x+y^{2x}`
|
|
||||||
$$\tag*{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
### Line Breaks
|
|
||||||
|
|
||||||
KaTeX 0.10.0+ will insert automatic line breaks in inline math after relations or binary operators such as “=” or “+”. These can be suppressed by `\nobreak` or by placing math inside a pair of braces, as in `{F=ma}`. `\allowbreak` will allow automatic line breaks at locations other than relations or operators.
|
|
||||||
|
|
||||||
Hard line breaks are `\\` and `\newline`.
|
|
||||||
|
|
||||||
In display math, KaTeX does not insert automatic line breaks. It ignores display math hard line breaks when rendering option `strict: true`.
|
|
||||||
|
|
||||||
### Vertical Layout
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------|:----------------------------------------|:-----
|
|
||||||
|$x_n$ `x_n` |$\stackrel{!}{=}$ `\stackrel{!}{=}` |$a \atop b$ `a \atop b`
|
|
||||||
|$e^x$ `e^x` |$\overset{!}{=}$ `\overset{!}{=}` |$a\raisebox{0.25em}{b}c$ `a\raisebox{0.25em}{b}c`
|
|
||||||
|$_u^o $ `_u^o `|$\underset{!}{=}$ `\underset{!}{=}` | $$\sum_{\substack{0<i<m\\0<j<n}}$$ `\sum_{\substack{0<i<m\\0<j<n}}`
|
|
||||||
|
|
||||||
The second argument of `\raisebox` can contain math if it is nested within `$…$` delimiters, as in `\raisebox{0.25em}{$\frac a b$}`
|
|
||||||
|
|
||||||
### Overlap and Spacing
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------|:-------|
|
|
||||||
|${=}\mathllap{/\,}$ `{=}\mathllap{/\,}` | $\left(x^{\smash{2}}\right)$ `\left(x^{\smash{2}}\right)`
|
|
||||||
|$\mathrlap{\,/}{=}$ `\mathrlap{\,/}{=}` | $\sqrt{\smash[b]{y}}$ `\sqrt{\smash[b]{y}} `
|
|
||||||
|
|
||||||
$\displaystyle\sum_{\mathclap{1\le i\le j\le n}} x_{ij}$ `\sum_{\mathclap{1\le i\le j\le n}} x_{ij}`
|
|
||||||
|
|
||||||
KaTeX also supports `\llap`, `\rlap`, and `\clap`, but they will take only text, not math, as arguments.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="spacing-tbl">
|
|
||||||
|
|
||||||
**Spacing**
|
|
||||||
|
|
||||||
| Function | Produces | Function | Produces|
|
|
||||||
|:----------------|:-------------------|:---------------------|:--------------------------------------|
|
|
||||||
| `\,` | ³∕₁₈ em space | `\kern{distance}` | space, width = *distance*
|
|
||||||
| `\thinspace` | ³∕₁₈ em space | `\mkern{distance}` | space, width = *distance*
|
|
||||||
| `\>` | ⁴∕₁₈ em space | `\mskip{distance}` | space, width = *distance*
|
|
||||||
| `\:` | ⁴∕₁₈ em space | `\hskip{distance}` | space, width = *distance*
|
|
||||||
| `\medspace` | ⁴∕₁₈ em space | `\hspace{distance}` | space, width = *distance*
|
|
||||||
| `\;` | ⁵∕₁₈ em space | `\hspace*{distance}` | space, width = *distance*
|
|
||||||
| `\thickspace` | ⁵∕₁₈ em space | `\phantom{content}` | space the width and height of content
|
|
||||||
| `\enspace` | ½ em space | `\hphantom{content}` | space the width of content
|
|
||||||
| `\quad` | 1 em space | `\vphantom{content}` | a strut the height of content
|
|
||||||
| `\qquad` | 2 em space | `\!` | – ³∕₁₈ em space
|
|
||||||
| `~` | non-breaking space | `\negthinspace` | – ³∕₁₈ em space
|
|
||||||
| `\<space>` | space | `\negmedspace` | – ⁴∕₁₈ em space
|
|
||||||
| `\nobreakspace` | non-breaking space | `\negthickspace` | – ⁵∕₁₈ em space
|
|
||||||
| `\space` | space |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
**Notes:**
|
|
||||||
|
|
||||||
`distance` will accept any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
`\kern`, `\mkern`, `\mskip`, and `\hspace` accept unbraced distances, as in: `\kern1em`.
|
|
||||||
|
|
||||||
`\mkern` and `\mskip` will not work in text mode and both will write a console warning for any unit except `mu`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Logic and Set Theory
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:--------------------|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\forall$ `\forall` |$\complement$ `\complement`|$\therefore$ `\therefore` |$\emptyset$ `\emptyset`
|
|
||||||
|$\exists$ `\exists` |$\subset$ `\subset` |$\because$ `\because` |$\empty$ `\empty`
|
|
||||||
|$\exist$ `\exist` |$\supset$ `\supset` |$\mapsto$ `\mapsto` |$\varnothing$ `\varnothing`
|
|
||||||
|$\nexists$ `\nexists`|$\mid$ `\mid` |$\to$ `\to` |$\implies$ `\implies`
|
|
||||||
|$\in$ `\in` |$\land$ `\land` |$\gets$ `\gets` |$\impliedby$ `\impliedby`
|
|
||||||
|$\isin$ `\isin` |$\lor$ `\lor` |$\leftrightarrow$ `\leftrightarrow`|$\iff$ `\iff`
|
|
||||||
|$\notin$ `\notin` |$\ni$ `\ni` |$\notni$ `\notni` |$\neg$ `\neg` or `\lnot`
|
|
||||||
|
|
||||||
Direct Input: $∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬$ ℂ ℍ ℕ ℙ ℚ ℝ
|
|
||||||
|
|
||||||
## Macros
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------------------------------------|:------
|
|
||||||
|$\def\foo{x^2} \foo + \foo$ | `\def\foo{x^2} \foo + \foo`
|
|
||||||
|$\gdef\bar#1{#1^2} \bar{y} + \bar{y}$ | `\gdef\bar#1{#1^2} \bar{y} + \bar{y}`
|
|
||||||
| | `\global\def\macroname#1#2…{definition}`
|
|
||||||
| | `\newcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\renewcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\providecommand\macroname[numargs]{definition}`
|
|
||||||
|
|
||||||
Macros can also be defined in the KaTeX [rendering options](options.md).
|
|
||||||
|
|
||||||
Macros accept up to nine arguments: #1, #2, etc.
|
|
||||||
|
|
||||||
`\gdef` and `\global\def` macros will persist between math expressions.
|
|
||||||
|
|
||||||
Available functions include:
|
|
||||||
|
|
||||||
`\char` `\mathchoice` `\TextOrMath` `\@ifstar` `\@ifnextchar` `\@firstoftwo` `\@secondoftwo` `\relax`
|
|
||||||
|
|
||||||
@ is a valid character for commands, as if `\makeatletter` were in effect.
|
|
||||||
|
|
||||||
## Operators
|
|
||||||
|
|
||||||
### Big Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|------------------|-------------------------|--------------------------|--------------|
|
|
||||||
| $\sum$ `\sum` | $\prod$ `\prod` | $\bigotimes$ `\bigotimes`| $\bigvee$ `\bigvee`
|
|
||||||
| $\int$ `\int` | $\coprod$ `\coprod` | $\bigoplus$ `\bigoplus` | $\bigwedge$ `\bigwedge`
|
|
||||||
| $\iint$ `\iint` | $\intop$ `\intop` | $\bigodot$ `\bigodot` | $\bigcap$ `\bigcap`
|
|
||||||
| $\iiint$ `\iiint`| $\smallint$ `\smallint` | $\biguplus$ `\biguplus` | $\bigcup$ `\bigcup`
|
|
||||||
| $\oint$ `\oint` | $\oiint$ `\oiint` | $\oiiint$ `\oiiint` | $\bigsqcup$ `\bigsqcup`
|
|
||||||
|
|
||||||
Direct Input: $∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆$
|
|
||||||
|
|
||||||
### Binary Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-------------|-------------------|-------------------|--------------------|
|
|
||||||
| $+$ `+`| $\cdot$ `\cdot` | $\gtrdot$ `\gtrdot`| $x \pmod a$ `x \pmod a`|
|
|
||||||
| $-$ `-`| $\cdotp$ `\cdotp` | $\intercal$ `\intercal` | $x \pod a$ `x \pod a` |
|
|
||||||
| $/$ `/`| $\centerdot$ `\centerdot`| $\land$ `\land` | $\rhd$ `\rhd` |
|
|
||||||
| $*$ `*`| $\circ$ `\circ` | $\leftthreetimes$ `\leftthreetimes` | $\rightthreetimes$ `\rightthreetimes` |
|
|
||||||
| $\amalg$ `\amalg` | $\circledast$ `\circledast` | $\ldotp$ `\ldotp` | $\rtimes$ `\rtimes` |
|
|
||||||
| $\And$ `\And`| $\circledcirc$ `\circledcirc` | $\lor$ `\lor`| $\setminus$ `\setminus` |
|
|
||||||
| $\ast$ `\ast`| $\circleddash$ `\circleddash` | $\lessdot$ `\lessdot` | $\smallsetminus$ `\smallsetminus`|
|
|
||||||
| $\barwedge$ `\barwedge` | $\Cup$ `\Cup`| $\lhd$ `\lhd`| $\sqcap$ `\sqcap` |
|
|
||||||
| $\bigcirc$ `\bigcirc` | $\cup$ `\cup`| $\ltimes$ `\ltimes`| $\sqcup$ `\sqcup` |
|
|
||||||
| $\bmod$ `\bmod` | $\curlyvee$ `\curlyvee` | $x \mod a$ `x\mod a`| $\times$ `\times` |
|
|
||||||
| $\boxdot$ `\boxdot`| $\curlywedge$ `\curlywedge` | $\mp$ `\mp` | $\unlhd$ `\unlhd` |
|
|
||||||
| $\boxminus$ `\boxminus` | $\div$ `\div`| $\odot$ `\odot` | $\unrhd$ `\unrhd` |
|
|
||||||
| $\boxplus$ `\boxplus` | $\divideontimes$ `\divideontimes` | $\ominus$ `\ominus`| $\uplus$ `\uplus` |
|
|
||||||
| $\boxtimes$ `\boxtimes` | $\dotplus$ `\dotplus` | $\oplus$ `\oplus` | $\vee$ `\vee` |
|
|
||||||
| $\bullet$ `\bullet`| $\doublebarwedge$ `\doublebarwedge` | $\otimes$ `\otimes`| $\veebar$ `\veebar` |
|
|
||||||
| $\Cap$ `\Cap`| $\doublecap$ `\doublecap`| $\oslash$ `\oslash`| $\wedge$ `\wedge` |
|
|
||||||
| $\cap$ `\cap`| $\doublecup$ `\doublecup`| $\pm$ `\pm` or `\plusmn` | $\wr$ `\wr` |
|
|
||||||
|
|
||||||
Direct Input: $+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝$
|
|
||||||
|
|
||||||
### Fractions and Binomials
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\frac{a}{b}$ `\frac{a}{b}`|$\tfrac{a}{b}$ `\tfrac{a}{b}`|$\genfrac ( ] {2pt}{1}a{a+1}$ `\genfrac ( ] {2pt}{1}a{a+1}`
|
|
||||||
|${a \over b}$ `{a \over b}`|$\dfrac{a}{b}$ `\dfrac{a}{b}`|${a \above{2pt} b+1}$ `{a \above{2pt} b+1}`
|
|
||||||
|$a/b$ `a/b` | |$\cfrac{a}{1 + \cfrac{1}{b}}$ `\cfrac{a}{1 + \cfrac{1}{b}}`
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:--------
|
|
||||||
|$\binom{n}{k}$ `\binom{n}{k}` |$\dbinom{n}{k}$ `\dbinom{n}{k}`|${n\brace k}$ `{n\brace k}`
|
|
||||||
|${n \choose k}$ `{n \choose k}`|$\tbinom{n}{k}$ `\tbinom{n}{k}`|${n\brack k}$ `{n\brack k}`
|
|
||||||
|
|
||||||
### Math Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-----------|---------|-----------------|-----------|
|
|
||||||
| $\arcsin$ `\arcsin` | $\cotg$ `\cotg` | $\ln$ `\ln` | $\det$ `\det` |
|
|
||||||
| $\arccos$ `\arccos` | $\coth$ `\coth` | $\log$ `\log` | $\gcd$ `\gcd` |
|
|
||||||
| $\arctan$ `\arctan` | $\csc$ `\csc` | $\sec$ `\sec` | $\inf$ `\inf` |
|
|
||||||
| $\arctg$ `\arctg` | $\ctg$ `\ctg` | $\sin$ `\sin` | $\lim$ `\lim` |
|
|
||||||
| $\arcctg$ `\arcctg` | $\cth$ `\cth` | $\sinh$ `\sinh`| $\liminf$ `\liminf` |
|
|
||||||
| $\arg$ `\arg` | $\deg$ `\deg` | $\sh$ `\sh` | $\limsup$ `\limsup` |
|
|
||||||
| $\ch$ `\ch` | $\dim$ `\dim` | $\tan$ `\tan` | $\max$ `\max` |
|
|
||||||
| $\cos$ `\cos` | $\exp$ `\exp` | $\tanh$ `\tanh`| $\min$ `\min` |
|
|
||||||
| $\cosec$ `\cosec` | $\hom$ `\hom` | $\tg$ `\tg` | $\Pr$ `\Pr` |
|
|
||||||
| $\cosh$ `\cosh`| $\ker$ `\ker` | $\th$ `\th` | $\sup$ `\sup` |
|
|
||||||
| $\cot$ `\cot` | $\lg$ `\lg`| $\argmax$ `\argmax` | $\argmin$ `\argmin` |
|
|
||||||
| $\plim$ `\plim` | $\operatorname{f}$ `\operatorname{f}`| $\operatorname*{f}$ `\operatorname*{f}`| |
|
|
||||||
|
|
||||||
Functions on the right column of this table can take `\limits`.
|
|
||||||
|
|
||||||
### \sqrt
|
|
||||||
|
|
||||||
$\sqrt{x}$ `\sqrt{x}`
|
|
||||||
|
|
||||||
$\sqrt[3]{x}$ `\sqrt[3]{x}`
|
|
||||||
|
|
||||||
## Relations
|
|
||||||
|
|
||||||
$\stackrel{!}{=}$ `\stackrel{!}{=}`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:----------------------------|:--------------------------------|:--------------------------------|:-----
|
|
||||||
|$=$ `=` |$\eqcirc$ `\eqcirc` |$\lesseqgtr$ `\lesseqgtr` |$\sqsupset$ `\sqsupset`
|
|
||||||
|$<$ `<` |$\eqcolon$ `\eqcolon`|$\lesseqqgtr$ `\lesseqqgtr`|$\sqsupseteq$ `\sqsupseteq`
|
|
||||||
|$>$ `>` |$\Eqcolon$ `\Eqcolon`|$\lessgtr$ `\lessgtr`|$\Subset$ `\Subset`
|
|
||||||
|$:$ `:` |$\eqqcolon$ `\eqqcolon` |$\lesssim$ `\lesssim`|$\subset$ `\subset` or `\sub`
|
|
||||||
|$\approx$ `\approx` |$\Eqqcolon$ `\Eqqcolon` |$\ll$ `\ll` |$\subseteq$ `\subseteq` or `\sube`
|
|
||||||
|$\approxeq$ `\approxeq`|$\eqsim$ `\eqsim` |$\lll$ `\lll` |$\subseteqq$ `\subseteqq`
|
|
||||||
|$\asymp$ `\asymp`|$\eqslantgtr$ `\eqslantgtr`|$\llless$ `\llless` |$\succ$ `\succ`
|
|
||||||
|$\backepsilon$ `\backepsilon`|$\eqslantless$ `\eqslantless` |$\lt$ `\lt` |$\succapprox$ `\succapprox`
|
|
||||||
|$\backsim$ `\backsim` |$\equiv$ `\equiv` |$\mid$ `\mid` |$\succcurlyeq$ `\succcurlyeq`
|
|
||||||
|$\backsimeq$ `\backsimeq` |$\fallingdotseq$ `\fallingdotseq`|$\models$ `\models` |$\succeq$ `\succeq`
|
|
||||||
|$\between$ `\between` |$\frown$ `\frown` |$\multimap$ `\multimap` |$\succsim$ `\succsim`
|
|
||||||
|$\bowtie$ `\bowtie` |$\ge$ `\ge` |$\owns$ `\owns`|$\Supset$ `\Supset`
|
|
||||||
|$\bumpeq$ `\bumpeq` |$\geq$ `\geq` |$\parallel$ `\parallel` |$\supset$ `\supset`
|
|
||||||
|$\Bumpeq$ `\Bumpeq` |$\geqq$ `\geqq`|$\perp$ `\perp`|$\supseteq$ `\supseteq` or `\supe`
|
|
||||||
|$\circeq$ `\circeq` |$\geqslant$ `\geqslant` |$\pitchfork$ `\pitchfork` |$\supseteqq$ `\supseteqq`
|
|
||||||
|$\colonapprox$ `\colonapprox`|$\gg$ `\gg` |$\prec$ `\prec`|$\thickapprox$ `\thickapprox`
|
|
||||||
|$\Colonapprox$ `\Colonapprox`|$\ggg$ `\ggg` |$\precapprox$ `\precapprox`|$\thicksim$ `\thicksim`
|
|
||||||
|$\coloneq$ `\coloneq` |$\gggtr$ `\gggtr` |$\preccurlyeq$ `\preccurlyeq` |$\trianglelefteq$ `\trianglelefteq`
|
|
||||||
|$\Coloneq$ `\Coloneq` |$\gt$ `\gt` |$\preceq$ `\preceq` |$\triangleq$ `\triangleq`
|
|
||||||
|$\coloneqq$ `\coloneqq`|$\gtrapprox$ `\gtrapprox` |$\precsim$ `\precsim`|$\trianglerighteq$ `\trianglerighteq`
|
|
||||||
|$\Coloneqq$ `\Coloneqq`|$\gtreqless$ `\gtreqless` |$\propto$ `\propto` |$\varpropto$ `\varpropto`
|
|
||||||
|$\colonsim$ `\colonsim`|$\gtreqqless$ `\gtreqqless`|$\risingdotseq$ `\risingdotseq` |$\vartriangle$ `\vartriangle`
|
|
||||||
|$\Colonsim$ `\Colonsim`|$\gtrless$ `\gtrless`|$\shortmid$ `\shortmid` |$\vartriangleleft$ `\vartriangleleft`
|
|
||||||
|$\cong$ `\cong` |$\gtrsim$ `\gtrsim` |$\shortparallel$ `\shortparallel`|$\vartriangleright$ `\vartriangleright`
|
|
||||||
|$\curlyeqprec$ `\curlyeqprec`|$\in$ `\in` or `\isin` |$\sim$ `\sim` |$\vcentcolon$ `\vcentcolon`
|
|
||||||
|$\curlyeqsucc$ `\curlyeqsucc`|$\Join$ `\Join`|$\simeq$ `\simeq` |$\vdash$ `\vdash`
|
|
||||||
|$\dashv$ `\dashv`|$\le$ `\le` |$\smallfrown$ `\smallfrown`|$\vDash$ `\vDash`
|
|
||||||
|$\dblcolon$ `\dblcolon`|$\leq$ `\leq` |$\smallsmile$ `\smallsmile`|$\Vdash$ `\Vdash`
|
|
||||||
|$\doteq$ `\doteq`|$\leqq$ `\leqq`|$\smile$ `\smile` |$\Vvdash$ `\Vvdash`
|
|
||||||
|$\Doteq$ `\Doteq`|$\leqslant$ `\leqslant` |$\sqsubset$ `\sqsubset` |
|
|
||||||
|$\doteqdot$ `\doteqdot`|$\lessapprox$ `\lessapprox`|$\sqsubseteq$ `\sqsubseteq`|
|
|
||||||
|
|
||||||
|
|
||||||
Direct Input: $= < > : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⟂ ⊨$ `≔ ≕ ⩴`
|
|
||||||
|
|
||||||
### Negated Relations
|
|
||||||
|
|
||||||
$\not =$ `\not =`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|--------------|-------------------|---------------------|------------------|
|
|
||||||
| $\gnapprox$ `\gnapprox` | $\ngeqslant$ `\ngeqslant`| $\nsubseteq$ `\nsubseteq` | $\precneqq$ `\precneqq`|
|
|
||||||
| $\gneq$ `\gneq`| $\ngtr$ `\ngtr` | $\nsubseteqq$ `\nsubseteqq` | $\precnsim$ `\precnsim`|
|
|
||||||
| $\gneqq$ `\gneqq` | $\nleq$ `\nleq` | $\nsucc$ `\nsucc`| $\subsetneq$ `\subsetneq` |
|
|
||||||
| $\gnsim$ `\gnsim` | $\nleqq$ `\nleqq` | $\nsucceq$ `\nsucceq` | $\subsetneqq$ `\subsetneqq` |
|
|
||||||
| $\gvertneqq$ `\gvertneqq` | $\nleqslant$ `\nleqslant`| $\nsupseteq$ `\nsupseteq` | $\succnapprox$ `\succnapprox`|
|
|
||||||
| $\lnapprox$ `\lnapprox` | $\nless$ `\nless` | $\nsupseteqq$ `\nsupseteqq` | $\succneqq$ `\succneqq`|
|
|
||||||
| $\lneq$ `\lneq`| $\nmid$ `\nmid` | $\ntriangleleft$ `\ntriangleleft` | $\succnsim$ `\succnsim`|
|
|
||||||
| $\lneqq$ `\lneqq` | $\notin$ `\notin` | $\ntrianglelefteq$ `\ntrianglelefteq` | $\supsetneq$ `\supsetneq` |
|
|
||||||
| $\lnsim$ `\lnsim` | $\notni$ `\notni` | $\ntriangleright$ `\ntriangleright`| $\supsetneqq$ `\supsetneqq` |
|
|
||||||
| $\lvertneqq$ `\lvertneqq` | $\nparallel$ `\nparallel`| $\ntrianglerighteq$ `\ntrianglerighteq` | $\varsubsetneq$ `\varsubsetneq` |
|
|
||||||
| $\ncong$ `\ncong` | $\nprec$ `\nprec` | $\nvdash$ `\nvdash` | $\varsubsetneqq$ `\varsubsetneqq` |
|
|
||||||
| $\ne$ `\ne` | $\npreceq$ `\npreceq` | $\nvDash$ `\nvDash` | $\varsupsetneq$ `\varsupsetneq` |
|
|
||||||
| $\neq$ `\neq` | $\nshortmid$ `\nshortmid`| $\nVDash$ `\nVDash` | $\varsupsetneqq$ `\varsupsetneqq` |
|
|
||||||
| $\ngeq$ `\ngeq`| $\nshortparallel$ `\nshortparallel` | $\nVdash$ `\nVdash` |
|
|
||||||
| $\ngeqq$ `\ngeqq` | $\nsim$ `\nsim` | $\precnapprox$ `\precnapprox`|
|
|
||||||
|
|
||||||
Direct Input: $∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌$
|
|
||||||
|
|
||||||
### Arrows
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|$\circlearrowleft$ `\circlearrowleft`|$\leftharpoonup$ `\leftharpoonup`|$\rArr$ `\rArr`
|
|
||||||
|$\circlearrowright$ `\circlearrowright`|$\leftleftarrows$ `\leftleftarrows`|$\rarr$ `\rarr`
|
|
||||||
|$\curvearrowleft$ `\curvearrowleft`|$\leftrightarrow$ `\leftrightarrow`|$\restriction$ `\restriction`
|
|
||||||
|$\curvearrowright$ `\curvearrowright`|$\Leftrightarrow$ `\Leftrightarrow`|$\rightarrow$ `\rightarrow`
|
|
||||||
|$\Darr$ `\Darr`|$\leftrightarrows$ `\leftrightarrows`|$\Rightarrow$ `\Rightarrow`
|
|
||||||
|$\dArr$ `\dArr`|$\leftrightharpoons$ `\leftrightharpoons`|$\rightarrowtail$ `\rightarrowtail`
|
|
||||||
|$\darr$ `\darr`|$\leftrightsquigarrow$ `\leftrightsquigarrow`|$\rightharpoondown$ `\rightharpoondown`
|
|
||||||
|$\dashleftarrow$ `\dashleftarrow`|$\Lleftarrow$ `\Lleftarrow`|$\rightharpoonup$ `\rightharpoonup`
|
|
||||||
|$\dashrightarrow$ `\dashrightarrow`|$\longleftarrow$ `\longleftarrow`|$\rightleftarrows$ `\rightleftarrows`
|
|
||||||
|$\downarrow$ `\downarrow`|$\Longleftarrow$ `\Longleftarrow`|$\rightleftharpoons$ `\rightleftharpoons`
|
|
||||||
|$\Downarrow$ `\Downarrow`|$\longleftrightarrow$ `\longleftrightarrow`|$\rightrightarrows$ `\rightrightarrows`
|
|
||||||
|$\downdownarrows$ `\downdownarrows`|$\Longleftrightarrow$ `\Longleftrightarrow`|$\rightsquigarrow$ `\rightsquigarrow`
|
|
||||||
|$\downharpoonleft$ `\downharpoonleft`|$\longmapsto$ `\longmapsto`|$\Rrightarrow$ `\Rrightarrow`
|
|
||||||
|$\downharpoonright$ `\downharpoonright`|$\longrightarrow$ `\longrightarrow`|$\Rsh$ `\Rsh`
|
|
||||||
|$\gets$ `\gets`|$\Longrightarrow$ `\Longrightarrow`|$\searrow$ `\searrow`
|
|
||||||
|$\Harr$ `\Harr`|$\looparrowleft$ `\looparrowleft`|$\swarrow$ `\swarrow`
|
|
||||||
|$\hArr$ `\hArr`|$\looparrowright$ `\looparrowright`|$\to$ `\to`
|
|
||||||
|$\harr$ `\harr`|$\Lrarr$ `\Lrarr`|$\twoheadleftarrow$ `\twoheadleftarrow`
|
|
||||||
|$\hookleftarrow$ `\hookleftarrow`|$\lrArr$ `\lrArr`|$\twoheadrightarrow$ `\twoheadrightarrow`
|
|
||||||
|$\hookrightarrow$ `\hookrightarrow`|$\lrarr$ `\lrarr`|$\Uarr$ `\Uarr`
|
|
||||||
|$\iff$ `\iff`|$\Lsh$ `\Lsh`|$\uArr$ `\uArr`
|
|
||||||
|$\impliedby$ `\impliedby`|$\mapsto$ `\mapsto`|$\uarr$ `\uarr`
|
|
||||||
|$\implies$ `\implies`|$\nearrow$ `\nearrow`|$\uparrow$ `\uparrow`
|
|
||||||
|$\Larr$ `\Larr`|$\nleftarrow$ `\nleftarrow`|$\Uparrow$ `\Uparrow`
|
|
||||||
|$\lArr$ `\lArr`|$\nLeftarrow$ `\nLeftarrow`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$\larr$ `\larr`|$\nleftrightarrow$ `\nleftrightarrow`|$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\leadsto$ `\leadsto`|$\nLeftrightarrow$ `\nLeftrightarrow`|$\upharpoonleft$ `\upharpoonleft`
|
|
||||||
|$\leftarrow$ `\leftarrow`|$\nrightarrow$ `\nrightarrow`|$\upharpoonright$ `\upharpoonright`
|
|
||||||
|$\Leftarrow$ `\Leftarrow`|$\nRightarrow$ `\nRightarrow`|$\upuparrows$ `\upuparrows`
|
|
||||||
|$\leftarrowtail$ `\leftarrowtail`|$\nwarrow$ `\nwarrow`
|
|
||||||
|$\leftharpoondown$ `\leftharpoondown`|$\Rarr$ `\Rarr`
|
|
||||||
|
|
||||||
Direct Input: $← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼$ ↽
|
|
||||||
|
|
||||||
**Extensible Arrows**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------------------------------------|:-----
|
|
||||||
|$\xleftarrow{abc}$ `\xleftarrow{abc}` |$\xrightarrow[under]{over}$ `\xrightarrow[under]{over}`
|
|
||||||
|$\xLeftarrow{abc}$ `\xLeftarrow{abc}` |$\xRightarrow{abc}$ `\xRightarrow{abc}`
|
|
||||||
|$\xleftrightarrow{abc}$ `\xleftrightarrow{abc}` |$\xLeftrightarrow{abc}$ `\xLeftrightarrow{abc}`
|
|
||||||
|$\xhookleftarrow{abc}$ `\xhookleftarrow{abc}` |$\xhookrightarrow{abc}$ `\xhookrightarrow{abc}`
|
|
||||||
|$\xtwoheadleftarrow{abc}$ `\xtwoheadleftarrow{abc}` |$\xtwoheadrightarrow{abc}$ `\xtwoheadrightarrow{abc}`
|
|
||||||
|$\xleftharpoonup{abc}$ `\xleftharpoonup{abc}` |$\xrightharpoonup{abc}$ `\xrightharpoonup{abc}`
|
|
||||||
|$\xleftharpoondown{abc}$ `\xleftharpoondown{abc}` |$\xrightharpoondown{abc}$ `\xrightharpoondown{abc}`
|
|
||||||
|$\xleftrightharpoons{abc}$ `\xleftrightharpoons{abc}`|$\xrightleftharpoons{abc}$ `\xrightleftharpoons{abc}`
|
|
||||||
|$\xtofrom{abc}$ `\xtofrom{abc}` |$\xmapsto{abc}$ `\xmapsto{abc}`
|
|
||||||
|$\xlongequal{abc}$ `\xlongequal{abc}`
|
|
||||||
|
|
||||||
Extensible arrows all can take an optional argument in the same manner<br>as `\xrightarrow[under]{over}`.
|
|
||||||
|
|
||||||
## Style, Color, Size, and Font
|
|
||||||
|
|
||||||
**Class Assignment**
|
|
||||||
|
|
||||||
`\mathbin` `\mathclose` `\mathinner` `\mathop`<br>
|
|
||||||
`\mathopen` `\mathord` `\mathpunct` `\mathrel`
|
|
||||||
|
|
||||||
**Color**
|
|
||||||
|
|
||||||
$\color{blue} F=ma$ `\color{blue} F=ma`
|
|
||||||
|
|
||||||
Note that KaTeX `\color` acts like a switch. This aligns with LaTeX and differs from MathJax.
|
|
||||||
Other KaTeX color functions expect the content to be a function argument:
|
|
||||||
|
|
||||||
$\textcolor{blue}{F=ma}$ `\textcolor{blue}{F=ma}`<br>
|
|
||||||
$\textcolor{#228B22}{F=ma}$ `\textcolor{#228B22}{F=ma}`<br>
|
|
||||||
$\colorbox{aqua}{A}$ `\colorbox{aqua}{A}`<br>
|
|
||||||
$\fcolorbox{red}{aqua}{A}$ `\fcolorbox{red}{aqua}{A}`
|
|
||||||
|
|
||||||
For color definition, KaTeX color functions will accept the standard HTML [predefined color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords). They will also accept an RGB argument in CSS hexadecimal style. The "#" is optional before a six-digit specification.
|
|
||||||
|
|
||||||
**Font**
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:-----
|
|
||||||
|$\mathrm{Ab0}$ `\mathrm{Ab0}` |$\mathbf{Ab0}$ `\mathbf{Ab0}` |$\mathit{Ab0}$ `\mathit{Ab0}`
|
|
||||||
|$\mathnormal{Ab0}$ `\mathnormal{Ab0}`|$\textbf{Ab0}$ `\textbf{Ab0}` |$\textit{Ab0}$ `\textit{Ab0}`
|
|
||||||
|$\textrm{Ab0}$ `\textrm{Ab0}` |$\bf Ab0$ `\bf Ab0` |$\it Ab0$ `\it Ab0`
|
|
||||||
|$\rm Ab0$ `\rm Ab0` |$\bold{Ab0}$ `\bold{Ab0}` |$\textup{Ab0}$ `\textup{Ab0}`
|
|
||||||
|$\textnormal{Ab0}$ `\textnormal{Ab0}`|$\boldsymbol{Ab0}$ `\boldsymbol{Ab}`|$\Bbb{AB}$ `\Bbb{AB}`
|
|
||||||
|$\text{Ab0}$ `\text{Ab0}` |$\bm{Ab0}$ `\bm{Ab0}` |$\mathbb{AB}$ `\mathbb{AB}`
|
|
||||||
|$\mathsf{Ab0}$ `\mathsf{Ab0}` |$\textmd{Ab0}$ `\textmd{Ab0}` |$\frak{Ab0}$ `\frak{Ab0}`
|
|
||||||
|$\textsf{Ab0}$ `\textsf{Ab0}` |$\mathtt{Ab0}$ `\mathtt{Ab0}` |$\mathfrak{Ab0}$ `\mathfrak{Ab0}`
|
|
||||||
|$\sf Ab0$ `\sf Ab0` |$\texttt{Ab0}$ `\texttt{Ab0}` |$\mathcal{AB0}$ `\mathcal{AB0}`
|
|
||||||
| |$\tt Ab0$ `\tt Ab0` |$\mathscr{AB}$ `\mathscr{AB}`
|
|
||||||
|
|
||||||
One can stack font family, font weight, and font shape by using the `\textXX` versions of the font functions. So `\textsf{\textbf{H}}` will produce $\textsf{\textbf{H}}$. The other versions do not stack, e.g., `\mathsf{\mathbf{H}}` will produce $\mathsf{\mathbf{H}}$.
|
|
||||||
|
|
||||||
In cases where KaTeX fonts do not have a bold glyph, `\pmb` can simulate one. For example, `\pmb{\mu}` renders as : $\pmb{\mu}$
|
|
||||||
|
|
||||||
**Size**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------|:-----
|
|
||||||
|$\Huge AB$ `\Huge AB` |$\normalsize AB$ `\normalsize AB`
|
|
||||||
|$\huge AB$ `\huge AB` |$\small AB$ `\small AB`
|
|
||||||
|$\LARGE AB$ `\LARGE AB`|$\footnotesize AB$ `\footnotesize AB`
|
|
||||||
|$\Large AB$ `\Large AB`|$\scriptsize AB$ `\scriptsize AB`
|
|
||||||
|$\large AB$ `\large AB`|$\tiny AB$ `\tiny AB`
|
|
||||||
|
|
||||||
|
|
||||||
**Style**
|
|
||||||
|
|
||||||
||
|
|
||||||
|:-------------------------------------------------------|
|
|
||||||
|$\displaystyle\sum_{i=1}^n$ `\displaystyle\sum_{i=1}^n`
|
|
||||||
|$\textstyle\sum_{i=1}^n$ `\textstyle\sum_{i=1}^n`
|
|
||||||
|$\scriptstyle x$ `\scriptstyle x` (The size of a first sub/superscript)
|
|
||||||
|$\scriptscriptstyle x$ `\scriptscriptstyle x` (The size of subsequent sub/superscripts)
|
|
||||||
|$\lim\limits_x$ `\lim\limits_x`
|
|
||||||
|$\lim\nolimits_x$ `\lim\nolimits_x`
|
|
||||||
|$\verb!x^2!$ `\verb!x^2!`
|
|
||||||
|
|
||||||
`\text{…}` will accept nested `$…$` fragments and render them in math mode.
|
|
||||||
|
|
||||||
## Symbols and Punctuation
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|`% comment`|$\dots$ `\dots`|$\KaTeX$ `\KaTeX`
|
|
||||||
|$\%$ `\%`|$\cdots$ `\cdots`|$\LaTeX$ `\LaTeX`
|
|
||||||
|$\#$ `\#`|$\ddots$ `\ddots`|$\TeX$ `\TeX`
|
|
||||||
|$\&$ `\&`|$\ldots$ `\ldots`|$\nabla$ `\nabla`
|
|
||||||
|$\_$ `\_`|$\vdots$ `\vdots`|$\infty$ `\infty`
|
|
||||||
|$\text{\textunderscore}$ `\text{\textunderscore}`|$\dotsb$ `\dotsb`|$\infin$ `\infin`
|
|
||||||
|$\text{--}$ `\text{--}`|$\dotsc$ `\dotsc`|$\checkmark$ `\checkmark`
|
|
||||||
|$\text{\textendash}$ `\text{\textendash}`|$\dotsi$ `\dotsi`|$\dag$ `\dag`
|
|
||||||
|$\text{---}$ `\text{---}`|$\dotsm$ `\dotsm`|$\dagger$ `\dagger`
|
|
||||||
|$\text{\textemdash}$ `\text{\textemdash}`|$\dotso$ `\dotso`|$\text{\textdagger}$ `\text{\textdagger}`
|
|
||||||
|$\text{\textasciitilde}$ `\text{\textasciitilde}`|$\sdot$ `\sdot`|$\ddag$ `\ddag`
|
|
||||||
|$\text{\textasciicircum}$ `\text{\textasciicircum}`|$\mathellipsis$ `\mathellipsis`|$\ddagger$ `\ddagger`
|
|
||||||
|$`$ <code>`</code>|$\text{\textellipsis}$ `\text{\textellipsis}`|$\text{\textdaggerdbl}$ `\text{\textdaggerdbl}`
|
|
||||||
|$\text{\textquoteleft}$ `text{\textquoteleft}`|$\Box$ `\Box`|$\Dagger$ `\Dagger`
|
|
||||||
|$\lq$ `\lq`|$\square$ `\square`|$\angle$ `\angle`
|
|
||||||
|$\text{\textquoteright}$ `\text{\textquoteright}`|$\blacksquare$ `\blacksquare`|$\measuredangle$ `\measuredangle`
|
|
||||||
|$\rq$ `\rq`|$\triangle$ `\triangle`|$\sphericalangle$ `\sphericalangle`
|
|
||||||
|$\text{\textquotedblleft}$ `\text{\textquotedblleft}`|$\triangledown$ `\triangledown`|$\top$ `\top`
|
|
||||||
|$"$ `"`|$\triangleleft$ `\triangleleft`|$\bot$ `\bot`
|
|
||||||
|$\text{\textquotedblright}$ `\text{\textquotedblright}`|$\triangleright$ `\triangleright`|$\$$ `\$`
|
|
||||||
|$\colon$ `\colon`|$\bigtriangledown$ `\bigtriangledown`|$\text{\textdollar}$ `\text{\textdollar}`
|
|
||||||
|$\backprime$ `\backprime`|$\bigtriangleup$ `\bigtriangleup`|$\pounds$ `\pounds`
|
|
||||||
|$\prime$ `\prime`|$\blacktriangle$ `\blacktriangle`|$\mathsterling$ `\mathsterling`
|
|
||||||
|$\text{\textless}$ `\text{\textless}`|$\blacktriangledown$ `\blacktriangledown`|$\text{\textsterling}$ `\text{\textsterling}`
|
|
||||||
|$\text{\textgreater}$ `\text{\textgreater}`|$\blacktriangleleft$ `\blacktriangleleft`|$\yen$ `\yen`
|
|
||||||
|$\text{\textbar}$ `\text{\textbar}`|$\blacktriangleright$ `\blacktriangleright`|$\surd$ `\surd`
|
|
||||||
|$\text{\textbardbl}$ `\text{\textbardbl}`|$\diamond$ `\diamond`|$\degree$ `\degree`
|
|
||||||
|$\text{\textbraceleft}$ `\text{\textbraceleft}`|$\Diamond$ `\Diamond`|$\text{\textdegree}$ `\text{\textdegree}`
|
|
||||||
|$\text{\textbraceright}$ `\text{\textbraceright}`|$\lozenge$ `\lozenge`|$\mho$ `\mho`
|
|
||||||
|$\text{\textbackslash}$ `\text{\textbackslash}`|$\blacklozenge$ `\blacklozenge`|$\diagdown$ `\diagdown`
|
|
||||||
|$\text{\P}$ `\text{\P}`|$\star$ `\star`|$\diagup$ `\diagup`
|
|
||||||
|$\text{\S}$ `\text{\S}`|$\bigstar$ `\bigstar`|$\flat$ `\flat`
|
|
||||||
|$\text{\sect}$ `\text{\sect}`|$\clubsuit$ `\clubsuit`|$\natural$ `\natural`
|
|
||||||
|$\copyright$ `\copyright`|$\clubs$ `\clubs`|$\sharp$ `\sharp`
|
|
||||||
|$\circledR$ `\circledR`|$\diamondsuit$ `\diamondsuit`|$\heartsuit$ `\heartsuit`
|
|
||||||
|$\text{\textregistered}$ `\text{\textregistered}`|$\diamonds$ `\diamonds`|$\hearts$ `\hearts`
|
|
||||||
|$\circledS$ `\circledS`|$\spadesuit$ `\spadesuit`|$\spades$ `\spades`
|
|
||||||
|$\text{\textcircled a}$ `\text{\textcircled a}`|$\maltese$ `\maltese`||
|
|
||||||
|
|
||||||
Direct Input: $£ ¥ ∇ ∞ · ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ … ⋮ ⋯ ⋱ !$ ‼
|
|
||||||
|
|
||||||
## Units
|
|
||||||
|
|
||||||
In KaTeX, units are proportioned as they are in TeX.<br>
|
|
||||||
KaTeX units are different than CSS units.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="unit-tbl">
|
|
||||||
|
|
||||||
| KaTeX Unit | Value | KaTeX Unit | Value |
|
|
||||||
|:---|:---------------------|:---|:----------------|
|
|
||||||
| em | CSS em | bp | 1/72 inch × F × G|
|
|
||||||
| ex | CSS ex | pc | 12 KaTeX pt|
|
|
||||||
| mu | 1/18 CSS em | dd | 1238/1157 KaTeX pt |
|
|
||||||
| pt | 1/72.27 inch × F × G | cc | 14856/1157 KaTeX pt |
|
|
||||||
| mm | 1 mm × F × G | nd | 685/642 KaTeX pt |
|
|
||||||
| cm | 1 cm × F × G | nc | 1370/107 KaTeX pt|
|
|
||||||
| in | 1 inch × F × G | sp | 1/65536 KaTeX pt |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
where:
|
|
||||||
|
|
||||||
<div style="margin-left: 1.5em;">
|
|
||||||
|
|
||||||
F = (font size of surrounding HTML text)/(10 pt)
|
|
||||||
|
|
||||||
G = 1.21 by default, because KaTeX font-size is normally 1.21 × the surrounding font size. This value [can be overridden](font.md#font-size-and-lengths) by the CSS of an HTML page.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
The effect of style and size:
|
|
||||||
|
|
||||||
<div class="katex-cards" id="unit-blocks">
|
|
||||||
|
|
||||||
| Unit | textstyle | scriptscript | huge |
|
|
||||||
|:------:|:-----------------:|:------------:|:------:|
|
|
||||||
|em or ex|$\rule{1em}{1em}$ |$\scriptscriptstyle\rule{1em}{1em}$ |$\huge\rule{1em}{1em}$
|
|
||||||
| mu |$\rule{18mu}{18mu}$|$\scriptscriptstyle\rule{18mu}{18mu}$|$\huge\rule{18mu}{18mu}$
|
|
||||||
| others |$\rule{10pt}{10pt}$|$\scriptscriptstyle\rule{10pt}{10pt}$|$\huge\rule{10pt}{10pt}$
|
|
||||||
|
|
||||||
</div>
|
|
@@ -1,111 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.1-autorender
|
|
||||||
title: Auto-render Extension
|
|
||||||
original_id: autorender
|
|
||||||
---
|
|
||||||
This is an extension to automatically render all of the math inside of text. It
|
|
||||||
searches all of the text nodes within a given element for the given delimiters,
|
|
||||||
ignoring certain tags like `<pre>`, and renders the math in place.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
This extension isn't part of KaTeX proper, so the script needs to be included
|
|
||||||
(via a `<script>` tag) in the page along with KaTeX itself. For example,
|
|
||||||
using a CDN:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above, the [`defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
indicates that the script doesn't need to execute until the page has loaded,
|
|
||||||
speeding up page rendering; and the `onload` attribute calls
|
|
||||||
`renderMathInElement` once the auto-render script loads.
|
|
||||||
|
|
||||||
Alternatively, you can call the `renderMathInElement` when (or after) the
|
|
||||||
[`DOMContentLoaded` event](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded)
|
|
||||||
fires on the document or in another deferred script.
|
|
||||||
This approach is useful for specifying or computing options, or if you don't
|
|
||||||
want to use a `defer` or `onload` attribute.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
renderMathInElement(document.body, {
|
|
||||||
// ...options...
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
ECMAScript module is also available:
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
|
|
||||||
<script type="module">
|
|
||||||
import renderMathInElement from "https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.mjs";
|
|
||||||
renderMathInElement(document.body);
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules. -->
|
|
||||||
|
|
||||||
## API
|
|
||||||
This extension exposes a single function, `window.renderMathInElement`, with
|
|
||||||
the following API:
|
|
||||||
|
|
||||||
```js
|
|
||||||
function renderMathInElement(elem, options)
|
|
||||||
```
|
|
||||||
|
|
||||||
`elem` is an HTML DOM element. The function will recursively search for text
|
|
||||||
nodes inside this element and render the math in them.
|
|
||||||
|
|
||||||
`options` is an optional object argument that can have the same keys as [the
|
|
||||||
object passed to `katex.render`](https://github.com/KaTeX/KaTeX/#rendering-options),
|
|
||||||
in addition to several auto-render-specific keys:
|
|
||||||
|
|
||||||
- `delimiters`: This is a list of delimiters to look for math. Each delimiter
|
|
||||||
has three properties:
|
|
||||||
|
|
||||||
- `left`: A string which starts the math expression (i.e. the left delimiter).
|
|
||||||
- `right`: A string which ends the math expression (i.e. the right delimiter).
|
|
||||||
- `display`: A boolean of whether the math in the expression should be
|
|
||||||
rendered in display mode or not.
|
|
||||||
|
|
||||||
The default value is:
|
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{left: "$$", right: "$$", display: true},
|
|
||||||
{left: "\\(", right: "\\)", display: false},
|
|
||||||
{left: "\\[", right: "\\]", display: true}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
- `ignoredTags`: This is a list of DOM node types to ignore when recursing
|
|
||||||
through. The default value is
|
|
||||||
`["script", "noscript", "style", "textarea", "pre", "code"]`.
|
|
||||||
|
|
||||||
- `ignoredClasses`: This is a list of DOM node class names to ignore when
|
|
||||||
recursing through. By default, this value is not set.
|
|
||||||
|
|
||||||
- `errorCallback`: A callback method returning a message and an error stack
|
|
||||||
in case of an critical error during rendering. The default uses `console.error`.
|
|
||||||
|
|
||||||
- `preProcess`: A callback function, `(math: string) => string`, used to process
|
|
||||||
math expressions before rendering.
|
|
||||||
|
|
||||||
The `displayMode` property of the options object is ignored, and is
|
|
||||||
instead taken from the `display` key of the corresponding entry in the
|
|
||||||
`delimiters` key.
|
|
||||||
|
|
||||||
The same `options.macros` object (which defaults to an empty object `{}`)
|
|
||||||
is passed into several calls to `katex.render`, so that consecutive equations
|
|
||||||
can build up shared macros by `\gdef`.
|
|
@@ -1,119 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.11.1-browser
|
|
||||||
title: Browser
|
|
||||||
original_id: browser
|
|
||||||
---
|
|
||||||
> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11.
|
|
||||||
|
|
||||||
## Starter template
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
|
|
||||||
|
|
||||||
<!-- The loading of KaTeX is deferred to speed up page rendering -->
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
<!-- To automatically render math in text elements, include the auto-render extension: -->
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
</head>
|
|
||||||
...
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Loading as Global
|
|
||||||
If you include the `katex.js` directly, the `katex` object will be available as
|
|
||||||
a global variable.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.css" integrity="sha384-bsHo4/LA+lkZv61JspMDQB9QP1TtO4IgOf2yYS+J6VdAYLVyx1c3XKcsHh0Vy8Ws" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.js" integrity="sha384-4z8mjH4yIpuK9dIQGR1JwbrfYsStrNK6MP+2Enhue4eyo0XlBDXOIPc8b6ZU0ajz" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides minified versions:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
The examples above load the script [deferred using the `defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to speed up page rendering. The `katex` object will be available after
|
|
||||||
[`DOMContentLoaded` event is fired on the `document`](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded).
|
|
||||||
If you do not use `defer`, `katex` object will be available after the corresponding
|
|
||||||
`script` tag.
|
|
||||||
|
|
||||||
If KaTeX is not used immediately or not critical, it is possible to load KaTeX
|
|
||||||
asynchronously. Add [`async` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to `script` and use [`rel="preload"` and `onload` attribute](https://github.com/filamentgroup/loadCSS)
|
|
||||||
on `link`.
|
|
||||||
|
|
||||||
You can prefetch KaTeX fonts to prevent FOUT or FOIT. Use [Font Loading API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API)
|
|
||||||
or [Web Font Loader](https://github.com/typekit/webfontloader):
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
window.WebFontConfig = {
|
|
||||||
custom: {
|
|
||||||
families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7',
|
|
||||||
'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script',
|
|
||||||
'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3',
|
|
||||||
'KaTeX_Size4', 'KaTeX_Typewriter'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use [`rel="preload"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content).
|
|
||||||
Add `<link rel="preload" href=(path to WOFF2 font) as="font" type="font/woff2" crossorigin="anonymous">`
|
|
||||||
to `head`. Note that [only few browsers support it](https://caniuse.com/#feat=link-rel-preload)
|
|
||||||
and they all support WOFF2 so preloading WOFF2 fonts is enough.
|
|
||||||
|
|
||||||
See [Google Web Fundamentals - Web Font Optimization](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/webfont-optimization)
|
|
||||||
for more detail.
|
|
||||||
|
|
||||||
## Module Loaders
|
|
||||||
### AMD
|
|
||||||
```html
|
|
||||||
<script type="text/javascript">
|
|
||||||
require([
|
|
||||||
"https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.js",
|
|
||||||
], katex => {
|
|
||||||
...
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.css" integrity="sha384-bsHo4/LA+lkZv61JspMDQB9QP1TtO4IgOf2yYS+J6VdAYLVyx1c3XKcsHh0Vy8Ws" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
### ECMAScript module
|
|
||||||
```html
|
|
||||||
<script type="module" type="text/javascript">
|
|
||||||
import katex from 'https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.mjs';
|
|
||||||
...
|
|
||||||
</script>
|
|
||||||
<script nomodule defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.js" integrity="sha384-4z8mjH4yIpuK9dIQGR1JwbrfYsStrNK6MP+2Enhue4eyo0XlBDXOIPc8b6ZU0ajz" crossorigin="anonymous"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.css" integrity="sha384-bsHo4/LA+lkZv61JspMDQB9QP1TtO4IgOf2yYS+J6VdAYLVyx1c3XKcsHh0Vy8Ws" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
> Use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules.
|
|
||||||
|
|
||||||
## Download & Host Things Yourself
|
|
||||||
Download a [KaTeX release](https://github.com/KaTeX/KaTeX/releases),
|
|
||||||
copy `katex.js`, `katex.css`
|
|
||||||
(or `katex.min.js` and `katex.min.css` to use minified versions),
|
|
||||||
and the `fonts` directory, and include or import it like above.
|
|
||||||
|
|
||||||
You can also build from source. See [Building from Source](node.md#building-from-source)
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
## Bundler
|
|
||||||
[Use Node.js package managers to install KaTeX and import it](node.md) in your
|
|
||||||
project. Then bundle using bundlers like [webpack](https://webpack.js.org/) or
|
|
||||||
[rollup.js](https://rollupjs.org/). Note that you have to bundle the stylesheet
|
|
||||||
(`katex.css`) or include it manually.
|
|
@@ -1,124 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.12.0-autorender
|
|
||||||
title: Auto-render Extension
|
|
||||||
original_id: autorender
|
|
||||||
---
|
|
||||||
This is an extension to automatically render all of the math inside of text. It
|
|
||||||
searches all of the text nodes within a given element for the given delimiters,
|
|
||||||
ignoring certain tags like `<pre>`, and renders the math in place.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
This extension isn't part of KaTeX proper, so the script needs to be included
|
|
||||||
(via a `<script>` tag) in the page along with KaTeX itself. For example,
|
|
||||||
using a CDN:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above, the [`defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
indicates that the script doesn't need to execute until the page has loaded,
|
|
||||||
speeding up page rendering; and the `onload` attribute calls
|
|
||||||
`renderMathInElement` once the auto-render script loads.
|
|
||||||
|
|
||||||
Alternatively, you can call the `renderMathInElement` when (or after) the
|
|
||||||
[`DOMContentLoaded` event](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded)
|
|
||||||
fires on the document or in another deferred script.
|
|
||||||
This approach is useful for specifying or computing options, or if you don't
|
|
||||||
want to use a `defer` or `onload` attribute.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
renderMathInElement(document.body, {
|
|
||||||
// ...options...
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
ECMAScript module is also available:
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
|
|
||||||
<script type="module">
|
|
||||||
import renderMathInElement from "https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.mjs";
|
|
||||||
renderMathInElement(document.body);
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules. -->
|
|
||||||
|
|
||||||
## API
|
|
||||||
This extension exposes a single function, `window.renderMathInElement`, with
|
|
||||||
the following API:
|
|
||||||
|
|
||||||
```js
|
|
||||||
function renderMathInElement(elem, options)
|
|
||||||
```
|
|
||||||
|
|
||||||
`elem` is an HTML DOM element. The function will recursively search for text
|
|
||||||
nodes inside this element and render the math in them.
|
|
||||||
|
|
||||||
`options` is an optional object argument that can have the same keys as [the
|
|
||||||
object passed to `katex.render`](https://github.com/KaTeX/KaTeX/#rendering-options),
|
|
||||||
in addition to two auto-render-specific keys:
|
|
||||||
|
|
||||||
- `delimiters`: This is a list of delimiters to look for math, processed in
|
|
||||||
the same order as the list. Each delimiter has three properties:
|
|
||||||
|
|
||||||
- `left`: A string which starts the math expression (i.e. the left delimiter).
|
|
||||||
- `right`: A string which ends the math expression (i.e. the right delimiter).
|
|
||||||
- `display`: A boolean of whether the math in the expression should be
|
|
||||||
rendered in display mode or not.
|
|
||||||
|
|
||||||
The default value is:
|
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{left: "$$", right: "$$", display: true},
|
|
||||||
{left: "\\(", right: "\\)", display: false},
|
|
||||||
{left: "\\[", right: "\\]", display: true}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
If you want to add support for inline math via `$...$`, be sure to list it
|
|
||||||
*after* `$$`, as in the following. (Because rules are processed in order,
|
|
||||||
putting a `$` rule first would catch `$$` as an empty math expression.)
|
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{left: "$$", right: "$$", display: true},
|
|
||||||
{left: "$", right: "$", display: false},
|
|
||||||
{left: "\\(", right: "\\)", display: false},
|
|
||||||
{left: "\\[", right: "\\]", display: true}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
- `ignoredTags`: This is a list of DOM node types to ignore when recursing
|
|
||||||
through. The default value is
|
|
||||||
`["script", "noscript", "style", "textarea", "pre", "code", "option"]`.
|
|
||||||
|
|
||||||
- `ignoredClasses`: This is a list of DOM node class names to ignore when
|
|
||||||
recursing through. By default, this value is not set.
|
|
||||||
|
|
||||||
- `errorCallback`: A callback method returning a message and an error stack
|
|
||||||
in case of an critical error during rendering. The default uses `console.error`.
|
|
||||||
|
|
||||||
- `preProcess`: A callback function, `(math: string) => string`, used to process
|
|
||||||
math expressions before rendering.
|
|
||||||
|
|
||||||
The `displayMode` property of the options object is ignored, and is
|
|
||||||
instead taken from the `display` key of the corresponding entry in the
|
|
||||||
`delimiters` key.
|
|
||||||
|
|
||||||
The same `options.macros` object (which defaults to an empty object `{}`)
|
|
||||||
is passed into several calls to `katex.render`, so that consecutive equations
|
|
||||||
can build up shared macros by `\gdef`.
|
|
@@ -1,119 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.12.0-browser
|
|
||||||
title: Browser
|
|
||||||
original_id: browser
|
|
||||||
---
|
|
||||||
> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 11.
|
|
||||||
|
|
||||||
## Starter template
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
|
|
||||||
|
|
||||||
<!-- The loading of KaTeX is deferred to speed up page rendering -->
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
<!-- To automatically render math in text elements, include the auto-render extension: -->
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
</head>
|
|
||||||
...
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Loading as Global
|
|
||||||
If you include the `katex.js` directly, the `katex` object will be available as
|
|
||||||
a global variable.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.css" integrity="sha384-qCEsSYDSH0x5I45nNW4oXemORUZnYFtPy/FqB/OjqxabTMW5HVaaH9USK4fN3goV" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.js" integrity="sha384-YFVvRUwgqxkAVN9bmAVLsKilmOKfQLyUx0ZlmDNs0aBUTsvMLnRxE3Km0NrZa0i9" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides minified versions:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
The examples above load the script [deferred using the `defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to speed up page rendering. The `katex` object will be available after
|
|
||||||
[`DOMContentLoaded` event is fired on the `document`](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded).
|
|
||||||
If you do not use `defer`, `katex` object will be available after the corresponding
|
|
||||||
`script` tag.
|
|
||||||
|
|
||||||
If KaTeX is not used immediately or not critical, it is possible to load KaTeX
|
|
||||||
asynchronously. Add [`async` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to `script` and use [`rel="preload"` and `onload` attribute](https://github.com/filamentgroup/loadCSS)
|
|
||||||
on `link`.
|
|
||||||
|
|
||||||
You can prefetch KaTeX fonts to prevent FOUT or FOIT. Use [Font Loading API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API)
|
|
||||||
or [Web Font Loader](https://github.com/typekit/webfontloader):
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
window.WebFontConfig = {
|
|
||||||
custom: {
|
|
||||||
families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7',
|
|
||||||
'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script',
|
|
||||||
'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3',
|
|
||||||
'KaTeX_Size4', 'KaTeX_Typewriter'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use [`rel="preload"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content).
|
|
||||||
Add `<link rel="preload" href=(path to WOFF2 font) as="font" type="font/woff2" crossorigin="anonymous">`
|
|
||||||
to `head`. Note that [only few browsers support it](https://caniuse.com/#feat=link-rel-preload)
|
|
||||||
and they all support WOFF2 so preloading WOFF2 fonts is enough.
|
|
||||||
|
|
||||||
See [Google Web Fundamentals - Web Font Optimization](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/webfont-optimization)
|
|
||||||
for more detail.
|
|
||||||
|
|
||||||
## Module Loaders
|
|
||||||
### AMD
|
|
||||||
```html
|
|
||||||
<script type="text/javascript">
|
|
||||||
require([
|
|
||||||
"https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.js",
|
|
||||||
], katex => {
|
|
||||||
...
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.css" integrity="sha384-qCEsSYDSH0x5I45nNW4oXemORUZnYFtPy/FqB/OjqxabTMW5HVaaH9USK4fN3goV" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
### ECMAScript module
|
|
||||||
```html
|
|
||||||
<script type="module" type="text/javascript">
|
|
||||||
import katex from 'https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.mjs';
|
|
||||||
...
|
|
||||||
</script>
|
|
||||||
<script nomodule defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.js" integrity="sha384-YFVvRUwgqxkAVN9bmAVLsKilmOKfQLyUx0ZlmDNs0aBUTsvMLnRxE3Km0NrZa0i9" crossorigin="anonymous"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.css" integrity="sha384-qCEsSYDSH0x5I45nNW4oXemORUZnYFtPy/FqB/OjqxabTMW5HVaaH9USK4fN3goV" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
> Use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules.
|
|
||||||
|
|
||||||
## Download & Host Things Yourself
|
|
||||||
Download a [KaTeX release](https://github.com/KaTeX/KaTeX/releases),
|
|
||||||
copy `katex.js`, `katex.css`
|
|
||||||
(or `katex.min.js` and `katex.min.css` to use minified versions),
|
|
||||||
and the `fonts` directory, and include or import it like above.
|
|
||||||
|
|
||||||
You can also build from source. See [Building from Source](node.md#building-from-source)
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
## Bundler
|
|
||||||
[Use Node.js package managers to install KaTeX and import it](node.md) in your
|
|
||||||
project. Then bundle using bundlers like [webpack](https://webpack.js.org/) or
|
|
||||||
[rollup.js](https://rollupjs.org/). Note that you have to bundle the stylesheet
|
|
||||||
(`katex.css`) or include it manually.
|
|
@@ -1,52 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.12.0-issues
|
|
||||||
title: Common Issues
|
|
||||||
original_id: issues
|
|
||||||
---
|
|
||||||
- Be sure to include `<!DOCTYPE html>` at the top of your HTML file, as
|
|
||||||
otherwise your browser will render in "[quirks mode](https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode)"
|
|
||||||
which can cause KaTeX to sometimes render incorrectly.
|
|
||||||
This header is needed even inside `<iframe>`s
|
|
||||||
(which don't inherit the parent document's doctype).
|
|
||||||
- Many Markdown preprocessors, such as the one that Jekyll and GitHub Pages use,
|
|
||||||
have a "smart quotes" feature. This changes `'` to `’` which is an issue for
|
|
||||||
math containing primes, e.g. `f'`. This can be worked around by defining a
|
|
||||||
single character macro which changes them back, e.g. `{"’", "'"}`.
|
|
||||||
- KaTeX follows LaTeX's rendering of `aligned` and `matrix` environments unlike
|
|
||||||
MathJax. When displaying fractions one above another in these vertical
|
|
||||||
layouts there may not be enough space between rows for people who are used to
|
|
||||||
MathJax's rendering. The distance between rows can be adjusted by using
|
|
||||||
`\\[0.1em]` instead of the standard line separator distance.
|
|
||||||
- KaTeX does not support the `align` environment because LaTeX doesn't support
|
|
||||||
`align` in math mode. The `aligned` environment offers the same functionality
|
|
||||||
but in math mode, so use that instead.
|
|
||||||
- MathJax defines `\color` to be like `\textcolor` by default; set KaTeX's
|
|
||||||
`colorIsTextColor` option to `true` for this behavior. KaTeX's default
|
|
||||||
behavior matches MathJax with its `color.js` extension enabled.
|
|
||||||
- Equivalents of MathJax `\class`, `\cssId`, and `\style` are `\htmlClass`,
|
|
||||||
`\htmlId`, and `\htmlStyle`, respectively, to avoid ambiguity.
|
|
||||||
- Some symbols are defined using macro instead of `\DeclareMathSymbol` or similar
|
|
||||||
as in LaTeX. This may cause different behavior in expansion. They may expand
|
|
||||||
into multiple tokens and be affected by `\expandafter` and `\noexpand`.
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
To check the stylesheet (katex.css) is properly loaded, add following code to
|
|
||||||
anywhere in the document:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<style>
|
|
||||||
.katex-version {display: none;}
|
|
||||||
.katex-version::after {content:"0.10.2 or earlier";}
|
|
||||||
</style>
|
|
||||||
<span class="katex">
|
|
||||||
<span class="katex-mathml">The KaTeX stylesheet is not loaded!</span>
|
|
||||||
<span class="katex-version rule">KaTeX stylesheet version: </span>
|
|
||||||
</span>
|
|
||||||
```
|
|
||||||
|
|
||||||
If it is loaded properly, it'll show its version. Make sure its version matches
|
|
||||||
the version of the JavaScript file (katex.js), which is defined in `katex.version`.
|
|
||||||
If it is not loaded properly, it'll show:
|
|
||||||
|
|
||||||
> The KaTeX stylesheet is not loaded!
|
|
@@ -1,57 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.12.0-libs
|
|
||||||
title: Extensions & Libraries
|
|
||||||
original_id: libs
|
|
||||||
---
|
|
||||||
## Extensions
|
|
||||||
|
|
||||||
These extensions are provided by KaTeX.
|
|
||||||
|
|
||||||
- [Auto-render](autorender.md): Automatically renders all of the math inside text
|
|
||||||
- [Copy-tex](https://github.com/Khan/KaTeX/tree/master/contrib/copy-tex): When selecting and copying KaTeX-rendered elements, copies their LaTeX source to the clipboard
|
|
||||||
- [`math/tex` Custom Script Type](https://github.com/Khan/KaTeX/tree/master/contrib/mathtex-script-type): Automatically displays LaTeX math inside `script` tags with `type=math/tex`
|
|
||||||
- [mhchem](https://github.com/Khan/KaTeX/tree/master/contrib/mhchem): Write beautiful chemical equations easily
|
|
||||||
|
|
||||||
## Libraries
|
|
||||||
|
|
||||||
These libraries are maintained by third-parties.
|
|
||||||
|
|
||||||
### Angular2+
|
|
||||||
- [ng-katex](https://github.com/garciparedes/ng-katex): Angular module to write beautiful math expressions with TeX syntax boosted by KaTeX library
|
|
||||||
|
|
||||||
### iOS
|
|
||||||
- [KaTeX-iOS](https://github.com/ianarawjo/KaTeX-iOS): iOS UIView that renders TeX expressions with KaTeX
|
|
||||||
|
|
||||||
### Android
|
|
||||||
- [KaTeXView](https://github.com/judemanutd/KaTeXView): An android library that uses Khan Academy KaTeX for TeX math rendering.
|
|
||||||
|
|
||||||
### React
|
|
||||||
- [react-latex](https://github.com/zzish/react-latex): React component to render latex strings, based on KaTeX
|
|
||||||
- [react-katex](https://github.com/talyssonoc/react-katex): React components that use KaTeX to typeset math expressions
|
|
||||||
|
|
||||||
### Ruby
|
|
||||||
|
|
||||||
- [katex-ruby](https://github.com/glebm/katex-ruby): Provides server-side rendering and integration with popular Ruby web frameworks (Rails, Hanami, and anything that uses Sprockets).
|
|
||||||
|
|
||||||
### Rust
|
|
||||||
|
|
||||||
- [katex-rs](https://github.com/xu-cheng/katex-rs): Rust bindings to provide server-side rendering.
|
|
||||||
|
|
||||||
### Vue
|
|
||||||
- [vue-katex](https://github.com/lucpotage/vue-katex): Vue plugin to render TeX expressions using KaTeX.
|
|
||||||
|
|
||||||
### AsciiMath
|
|
||||||
|
|
||||||
If you want to render math written in [AsciiMath](http://asciimath.org/),
|
|
||||||
you'll need to first convert AsciiMath into LaTeX input, then call KaTeX.
|
|
||||||
|
|
||||||
- [asciimath2tex](https://github.com/christianp/asciimath2tex): Converts AsciiMath to TeX, with KaTeX in mind
|
|
||||||
|
|
||||||
### Canvas LaTeX
|
|
||||||
|
|
||||||
- [canvas-latex](https://github.com/CurriculumAssociates/canvas-latex): Renders mathematical expressions on HTML5's canvas element. Supports popular libraries like: CreateJS, and PIXI.
|
|
||||||
|
|
||||||
### Web-Components
|
|
||||||
|
|
||||||
- [katex-element](https://github.com/georges-gomes/katex-element): KaTeX wrapped in a custom element. Simply use `<katex-element>` in HTML - framework independent.
|
|
||||||
- [katex-expression](https://github.com/navsgh/katex-expression): A web component/custom element (built with Stencil) to render KaTeX expressions. Stencil builds web components that run natively or near-natively in all widely used desktop and mobile browsers. Stencil uses a dynamic loader to load the custom elements polyfill only on browsers that need it.
|
|
@@ -1,100 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.12.0-node
|
|
||||||
title: Node.js
|
|
||||||
original_id: node
|
|
||||||
---
|
|
||||||
## Installation
|
|
||||||
### npm
|
|
||||||
Install with `npm`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install katex
|
|
||||||
# or globally
|
|
||||||
npm install -g katex
|
|
||||||
```
|
|
||||||
|
|
||||||
### Yarn
|
|
||||||
Install with `Yarn`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn add katex
|
|
||||||
# or globally
|
|
||||||
yarn global add katex
|
|
||||||
```
|
|
||||||
|
|
||||||
### Building from Source
|
|
||||||
To build you will need Git, Node.js 10 or later, and Yarn.
|
|
||||||
|
|
||||||
Clone a copy of the GitHub source repository and its submodules:
|
|
||||||
```bash
|
|
||||||
git clone --recursive https://github.com/KaTeX/KaTeX.git
|
|
||||||
cd KaTeX
|
|
||||||
```
|
|
||||||
|
|
||||||
Then install dependencies and run `build` script:
|
|
||||||
```bash
|
|
||||||
yarn
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
It will automatically transpile code and include only necessary fonts for
|
|
||||||
target environments specified by [Browserslist config](https://github.com/browserslist/browserslist#environment-variables).
|
|
||||||
For example, if you are making a web app for a kiosk with Chrome 68, run
|
|
||||||
`BROWSERSLIST="Chrome 68" yarn build` and it will produce build with no
|
|
||||||
transpilation, as it fully supports ES6, and only include WOFF2 fonts.
|
|
||||||
|
|
||||||
You can override included fonts using environment variables. Set `USE_(FONT NAME)`
|
|
||||||
environment variable to `"true"` or `"false"`, to force a font type to be included
|
|
||||||
or excluded, respectively.`
|
|
||||||
|
|
||||||
If you'd like to use the built KaTeX in other projects, install the package by
|
|
||||||
specifying the path:
|
|
||||||
```bash
|
|
||||||
yarn add /path/to/KaTeX
|
|
||||||
# or using npm
|
|
||||||
npm install /path/to/KaTeX
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can manually download the package and source code from
|
|
||||||
[GitHub releases](https://github.com/KaTeX/KaTeX/releases).
|
|
||||||
|
|
||||||
## Importing
|
|
||||||
KaTeX is exported as a CommonJS module, which can be imported using `require`:
|
|
||||||
```js
|
|
||||||
const katex = require('katex');
|
|
||||||
```
|
|
||||||
|
|
||||||
If you're using a module loader, transpiler, or bundler that supports interoperability
|
|
||||||
between ECMAScript module and CommonJS module, you can use `import`:
|
|
||||||
```js
|
|
||||||
import katex from 'katex';
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides an ECMAScript module:
|
|
||||||
```js
|
|
||||||
import katex from 'katex/dist/katex.mjs'
|
|
||||||
```
|
|
||||||
|
|
||||||
> The ES module contains ES6 syntaxes and features, and may need transpiling to
|
|
||||||
use in old environments.
|
|
||||||
|
|
||||||
See the [API](api.html) for available functions in the `katex` module.
|
|
||||||
|
|
||||||
## Including in webpages
|
|
||||||
|
|
||||||
To render any HTML generated by e.g. `katex.renderToString`, you will
|
|
||||||
still need to link the CSS file, make the KaTeX font files available to the
|
|
||||||
client, and use the HTML5 doctype. See [browser usage](browser.html).
|
|
||||||
Note, however, that you do not need to include `katex.js` on the client.
|
|
||||||
|
|
||||||
## Using mhchem extension
|
|
||||||
|
|
||||||
The [mhchem extension](https://github.com/Khan/KaTeX/tree/master/contrib/mhchem)
|
|
||||||
adds its features by modifying the `katex` module. So you can use KaTeX with
|
|
||||||
mhchem in Node as follows:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const katex = require('katex');
|
|
||||||
require('katex/dist/contrib/mhchem.js'); // modify katex module
|
|
||||||
const html = katex.renderToString('\\ce{CO2 + C -> 2 C0}");
|
|
||||||
```
|
|
@@ -1,72 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.12.0-options
|
|
||||||
title: Options
|
|
||||||
original_id: options
|
|
||||||
---
|
|
||||||
You can provide an object of options as the last argument to [`katex.render` and `katex.renderToString`](api.md). Available options are:
|
|
||||||
|
|
||||||
- `displayMode`: `boolean`. If `true` the math will be rendered in display mode, which will put the math in display style (so `\int` and `\sum` are large, for example), and will center the math on the page on its own line. If `false` the math will be rendered in inline mode. (default: `false`)
|
|
||||||
- `output`: `string`. Determines the markup language of the output. The valid choices are:
|
|
||||||
- `html`: Outputs KaTeX in HTML only.
|
|
||||||
- `mathml`: Outputs KaTeX in MathML only.
|
|
||||||
- `htmlAndMathml`: Outputs HTML for visual rendering and includes MathML for accessibility. This is the default.
|
|
||||||
- `leqno`: `boolean`. If `true`, display math has `\tag`s rendered on the left instead of the right, like `\usepackage[leqno]{amsmath}` in LaTeX.
|
|
||||||
- `fleqn`: `boolean`. If `true`, display math renders flush left with a `2em` left margin, like `\documentclass[fleqn]` in LaTeX with the `amsmath` package.
|
|
||||||
- `throwOnError`: `boolean`. If `true` (the default), KaTeX will throw a `ParseError` when it encounters an unsupported command or invalid LaTeX. If `false`, KaTeX will render unsupported commands as text, and render invalid LaTeX as its source code with hover text giving the error, in the color given by `errorColor`.
|
|
||||||
- `errorColor`: `string`. A color string given in the format `"#XXX"` or `"#XXXXXX"`. This option determines the color that unsupported commands and invalid LaTeX are rendered in when `throwOnError` is set to `false`. (default: `#cc0000`)
|
|
||||||
- `macros`: `object`. A collection of custom macros. Each macro is a property with a name like `\name` (written `"\\name"` in JavaScript) which maps to a string that describes the expansion of the macro, or a function that accepts an instance of `MacroExpander` as first argument and returns the expansion as a string. `MacroExpander` is an internal API and subject to non-backwards compatible changes. See [`src/macros.js`](https://github.com/KaTeX/KaTeX/blob/master/src/macros.js) for its usage. Single-character keys can also be included in which case the character will be redefined as the given macro (similar to TeX active characters). *This object will be modified* if the LaTeX code defines its own macros via `\gdef`, which enables consecutive calls to KaTeX to share state.
|
|
||||||
- `minRuleThickness`: `number`. Specifies a minimum thickness, in ems, for fraction lines, `\sqrt` top lines, `{array}` vertical lines, `\hline`, `\hdashline`, `\underline`, `\overline`, and the borders of `\fbox`, `\boxed`, and `\fcolorbox`. The usual value for these items is `0.04`, so for `minRuleThickness` to be effective it should probably take a value slightly above `0.04`, say `0.05` or `0.06`. Negative values will be ignored.
|
|
||||||
- `colorIsTextColor`: `boolean`. If `true`, `\color` will work like LaTeX's `\textcolor`, and take two arguments (e.g., `\color{blue}{hello}`), which restores the old behavior of KaTeX (pre-0.8.0). If `false` (the default), `\color` will work like LaTeX's `\color`, and take one argument (e.g., `\color{blue}hello`). In both cases, `\textcolor` works as in LaTeX (e.g., `\textcolor{blue}{hello}`).
|
|
||||||
- `maxSize`: `number`. All user-specified sizes, e.g. in `\rule{500em}{500em}`, will be capped to `maxSize` ems. If set to `Infinity` (the default), users can make elements and spaces arbitrarily large.
|
|
||||||
- `maxExpand`: `number`. Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to `Infinity`, the macro expander will try to fully expand as in LaTeX. (default: 1000)
|
|
||||||
- `strict`: `boolean` or `string` or `function` (default: `"warn"`). If `false` or `"ignore`", allow features that make writing LaTeX convenient but are not actually supported by (Xe)LaTeX (similar to MathJax). If `true` or `"error"` (LaTeX faithfulness mode), throw an error for any such transgressions. If `"warn"` (the default), warn about such behavior via `console.warn`. Provide a custom function `handler(errorCode, errorMsg, token)` to customize behavior depending on the type of transgression (summarized by the string code `errorCode` and detailed in `errorMsg`); this function can also return `"ignore"`, `"error"`, or `"warn"` to use a built-in behavior. A list of such features and their `errorCode`s:
|
|
||||||
|
|
||||||
- `"unknownSymbol"`: Use of unknown Unicode symbol, which will likely also
|
|
||||||
lead to warnings about missing character metrics, and layouts may be
|
|
||||||
incorrect (especially in terms of vertical heights).
|
|
||||||
- `"unicodeTextInMathMode"`: Use of Unicode text characters in math mode.
|
|
||||||
- `"mathVsTextUnits"`: Mismatch of math vs. text commands and units/mode.
|
|
||||||
- `"commentAtEnd"`: Use of `%` comment without a terminating newline.
|
|
||||||
LaTeX would thereby comment out the end of math mode (e.g. `$`),
|
|
||||||
causing an error.
|
|
||||||
- `"htmlExtension"`: Use of HTML extension (`\html`-prefixed) commands,
|
|
||||||
which are provieded for HTML manipulation.
|
|
||||||
|
|
||||||
A second category of `errorCode`s never throw errors, but their strictness
|
|
||||||
affects the behavior of KaTeX:
|
|
||||||
|
|
||||||
- `"newLineInDisplayMode"`: Use of `\\` or `\newline` in display mode
|
|
||||||
(outside an array/tabular environment). In strict mode, no line break
|
|
||||||
results, as in LaTeX.
|
|
||||||
|
|
||||||
- `trust`: `boolean` or `function` (default: `false`). If `false` (do not trust input), prevent any commands like `\includegraphics` that could enable adverse behavior, rendering them instead in `errorColor`. If `true` (trust input), allow all such commands. Provide a custom function `handler(context)` to customize behavior depending on the context (command, arguments e.g. a URL, etc.). A list of possible contexts:
|
|
||||||
|
|
||||||
- `{command: "\\url", url, protocol}`
|
|
||||||
- `{command: "\\href", url, protocol}`
|
|
||||||
- `{command: "\\includegraphics", url, protocol}`
|
|
||||||
- `{command: "\\htmlClass", class}`
|
|
||||||
- `{command: "\\htmlId", id}`
|
|
||||||
- `{command: "\\htmlStyle", style}`
|
|
||||||
- `{command: "\\htmlData", attributes}`
|
|
||||||
|
|
||||||
Here are some sample trust settings:
|
|
||||||
|
|
||||||
- Forbid specific command: `trust: (context) => context.command !== '\\includegraphics'`
|
|
||||||
- Allow specific command: `trust: (context) => context.command === '\\url'`
|
|
||||||
- Allow multiple specific commands: `trust: (context) => ['\\url', '\\href'].includes(context.command)`
|
|
||||||
- Allow all commands with a specific protocol: `trust: (context) => context.protocol === 'http'`
|
|
||||||
- Allow all commands with specific protocols: `trust: (context) => ['http', 'https', '_relative'].includes(context.protocol)`
|
|
||||||
- Allow all commands but forbid specific protocol: `trust: (context) => context.protocol !== 'file'`
|
|
||||||
- Allow certain commands with specific protocols: `trust: (context) => ['\\url', '\\href'].includes(context.command) && ['http', 'https', '_relative'].includes(context.protocol)`
|
|
||||||
- `globalGroup`: `boolean` (default: `false`). Place KaTeX code in the global group. As a consequence, `\def` and `\newcommand` persist in `macros` across render calls. In LaTeX, constructs such as `\begin{equation}` and `$$` create a local group and prevent definitions from becoming visible outside of those blocks.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
katex.render("c = \\pm\\sqrt{a^2 + b^2}\\in\\RR", element, {
|
|
||||||
displayMode: true,
|
|
||||||
macros: {
|
|
||||||
"\\RR": "\\mathbb{R}"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
@@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.12.0-security
|
|
||||||
title: Security
|
|
||||||
original_id: security
|
|
||||||
---
|
|
||||||
Any HTML generated by KaTeX *should* be safe from `<script>` or other code
|
|
||||||
injection attacks.
|
|
||||||
|
|
||||||
Of course, it is always a good idea to sanitize the HTML, though you will need
|
|
||||||
a rather generous whitelist (including some of SVG and MathML) to support
|
|
||||||
all of KaTeX.
|
|
||||||
|
|
||||||
A variety of options give finer control over the security of KaTeX
|
|
||||||
with untrusted inputs; refer to [Options](options.md) for more details.
|
|
||||||
* `maxSize` can prevent large width/height visual affronts.
|
|
||||||
* `maxExpand` can prevent infinite macro loop attacks.
|
|
||||||
* `trust` can allow certain commands that may load external resources or change HTML attributes and thus are not always safe (e.g., `\includegraphics` or `\htmlClass`)
|
|
||||||
|
|
||||||
The error message thrown by KaTeX may contain unescaped LaTeX source code.
|
|
||||||
See [Handling Errors](error.md) for more details.
|
|
||||||
|
|
||||||
> If you discovered a security issue, please let us know via https://hackerone.com/khanacademy
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,683 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.12.0-supported
|
|
||||||
title: Supported Functions
|
|
||||||
original_id: supported
|
|
||||||
---
|
|
||||||
This is a list of TeX functions supported by KaTeX. It is sorted into logical groups.
|
|
||||||
|
|
||||||
There is a similar [Support Table](support_table.md), sorted alphabetically, that lists both supported and un-supported functions.
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous"/>
|
|
||||||
<style>
|
|
||||||
p {overflow-wrap: break-word;}
|
|
||||||
table tr,
|
|
||||||
table td {
|
|
||||||
vertical-align: middle;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Accents
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------------------------|:----------------------------------------------------|:-----
|
|
||||||
|$a'$ `a'` |$\tilde{a}$ `\tilde{a}`|$\mathring{g}$ `\mathring{g}`
|
|
||||||
|$a''$ `a''`|$\widetilde{ac}$ `\widetilde{ac}` |$\overgroup{AB}$ `\overgroup{AB}`
|
|
||||||
|$a^{\prime}$ `a^{\prime}` |$\utilde{AB}$ `\utilde{AB}` |$\undergroup{AB}$ `\undergroup{AB}`
|
|
||||||
|$\acute{a}$ `\acute{a}`|$\vec{F}$ `\vec{F}` |$\Overrightarrow{AB}$ `\Overrightarrow{AB}`
|
|
||||||
|$\bar{y}$ `\bar{y}` |$\overleftarrow{AB}$ `\overleftarrow{AB}`|$\overrightarrow{AB}$ `\overrightarrow{AB}`
|
|
||||||
|$\breve{a}$ `\breve{a}`|$\underleftarrow{AB}$ `\underleftarrow{AB}` |$\underrightarrow{AB}$ `\underrightarrow{AB}`
|
|
||||||
|$\check{a}$ `\check{a}`|$\overleftharpoon{ac}$ `\overleftharpoon{ac}` |$\overrightharpoon{ac}$ `\overrightharpoon{ac}`
|
|
||||||
|$\dot{a}$ `\dot{a}` |$\overleftrightarrow{AB}$ `\overleftrightarrow{AB}` |$\overbrace{AB}$ `\overbrace{AB}`
|
|
||||||
|$\ddot{a}$ `\ddot{a}` |$\underleftrightarrow{AB}$ `\underleftrightarrow{AB}`|$\underbrace{AB}$ `\underbrace{AB}`
|
|
||||||
|$\grave{a}$ `\grave{a}`|$\overline{AB}$ `\overline{AB}` |$\overlinesegment{AB}$ `\overlinesegment{AB}`
|
|
||||||
|$\hat{\theta}$ `\hat{\theta}`|$\underline{AB}$ `\underline{AB}` |$\underlinesegment{AB}$ `\underlinesegment{AB}`
|
|
||||||
|$\widehat{ac}$ `\widehat{ac}`|$\widecheck{ac}$ `\widecheck{ac}` |
|
|
||||||
|
|
||||||
***Accent functions inside \\text{…}***
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:-----
|
|
||||||
|$\text{\'{a}}$ `\'{a}`|$\text{\~{a}}$ `\~{a}`|$\text{\.{a}}$ `\.{a}`|$\text{\H{a}}$ `\H{a}`
|
|
||||||
|$\text{\`{a}}$ <code>\\`{a}</code>|$\text{\={a}}$ `\={a}`|$\text{\"{a}}$ `\"{a}`|$\text{\v{a}}$ `\v{a}`
|
|
||||||
|$\text{\^{a}}$ `\^{a}`|$\text{\u{a}}$ `\u{a}`|$\text{\r{a}}$ `\r{a}`|
|
|
||||||
|
|
||||||
See also [letters](#letters)
|
|
||||||
|
|
||||||
## Delimiters
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:-----------------------------------|:---------------------------------------|:----------|:-------------------------------------------------------|:-----
|
|
||||||
|$(~)$ `( )` |$\lparen~\rparen$ `\lparen`<br>$~~~~$`\rparen`|$⌈~⌉$ `⌈ ⌉`|$\lceil~\rceil$ `\lceil`<br>$~~~~~$`\rceil` |$\uparrow$ `\uparrow`
|
|
||||||
|$[~]$ `[ ]` |$\lbrack~\rbrack$ `\lbrack`<br>$~~~~$`\rbrack`|$⌊~⌋$ `⌊ ⌋`|$\lfloor~\rfloor$ `\lfloor`<br>$~~~~~$`\rfloor` |$\downarrow$ `\downarrow`
|
|
||||||
|$\{ \}$ `\{ \}`|$\lbrace \rbrace$ `\lbrace`<br>$~~~~$`\rbrace`|$⎰⎱$ `⎰⎱` |$\lmoustache \rmoustache$ `\lmoustache`<br>$~~~~$`\rmoustache`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$⟨~⟩$ `⟨ ⟩` |$\langle~\rangle$ `\langle`<br>$~~~~$`\rangle`|$⟮~⟯$ `⟮ ⟯`|$\lgroup~\rgroup$ `\lgroup`<br>$~~~~~$`\rgroup` |$\Uparrow$ `\Uparrow`
|
|
||||||
|$\vert$ <code>|</code> |$\vert$ `\vert` |$┌ ┐$ `┌ ┐`|$\ulcorner \urcorner$ `\ulcorner`<br>$~~~~$`\urcorner` |$\Downarrow$ `\Downarrow`
|
|
||||||
|$\Vert$ <code>\|</code> |$\Vert$ `\Vert` |$└ ┘$ `└ ┘`|$\llcorner \lrcorner$ `\llcorner`<br>$~~~~$`\lrcorner` |$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\lvert~\rvert$ `\lvert`<br>$~~~~$`\rvert`|$\lVert~\rVert$ `\lVert`<br>$~~~~~$`\rVert` |`\left.`| `\right.` |$\backslash$ `\backslash`
|
|
||||||
|$\lang~\rang$ `\lang`<br>$~~~~$`\rang`|$\lt~\gt$ `\lt \gt`|$⟦~⟧$ `⟦ ⟧`|$\llbracket~\rrbracket$ `\llbracket`<br>$~~~~$`\rrbracket`|$\lBrace~\rBrace$ `\lBrace \rBrace`
|
|
||||||
|
|
||||||
**Delimiter Sizing**
|
|
||||||
|
|
||||||
$\left(\LARGE{AB}\right)$ `\left(\LARGE{AB}\right)`
|
|
||||||
|
|
||||||
$( \big( \Big( \bigg( \Bigg($ `( \big( \Big( \bigg( \Bigg(`
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:--------|:------|:--------|:-------|:------|
|
|
||||||
|`\left` |`\big` |`\bigl` |`\bigm` |`\bigr`
|
|
||||||
|`\middle`|`\Big` |`\Bigl` |`\Bigm` | `\Bigr`
|
|
||||||
|`\right` |`\bigg`|`\biggl` |`\biggm`|`\biggr`
|
|
||||||
| |`\Bigg`|`\Biggl` |`\Biggm`|`\Biggr`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Environments
|
|
||||||
|
|
||||||
<div class="katex-cards" id="environments">
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:--------
|
|
||||||
|$\begin{matrix} a & b \\ c & d \end{matrix}$ | `\begin{matrix}`<br> `a & b \\`<br> `c & d`<br>`\end{matrix}` |$\begin{array}{cc}a & b\\c & d\end{array}$ | `\begin{array}{cc}`<br> `a & b \\`<br> `c & d`<br>`\end{array}`
|
|
||||||
|$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$ |`\begin{pmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{pmatrix}` |$\begin{bmatrix} a & b \\ c & d \end{bmatrix}$ | `\begin{bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{bmatrix}`
|
|
||||||
|$\begin{vmatrix} a & b \\ c & d \end{vmatrix}$ |`\begin{vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{vmatrix}` |$\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}$ |`\begin{Vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Vmatrix}`
|
|
||||||
|$\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}$ |`\begin{Bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Bmatrix}`|$\def\arraystretch{1.5}\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}$|`\def\arraystretch{1.5}`<br> `\begin{array}{c:c:c}`<br> `a & b & c \\ \hline`<br> `d & e & f \\`<br> `\hdashline`<br> `g & h & i`<br>`\end{array}`
|
|
||||||
|$\begin{aligned} a&=b+c \\ d+e&=f \end{aligned}$ |`\begin{aligned}`<br> `a&=b+c \\`<br> `d+e&=f`<br>`\end{aligned}`|$\begin{alignedat}{2}10&x+&3&y=2\\3&x+&13&y=4\end{alignedat}$ |`\begin{alignedat}{2}`<br> `10&x+ &3&y = 2 \\`<br> ` 3&x+&13&y = 4`<br>`\end{alignedat}`
|
|
||||||
|$\begin{gathered} a=b \\ e=b+c \end{gathered}$ |`\begin{gathered}`<br> `a=b \\ `<br> `e=b+c`<br>`\end{gathered}`|$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$ |`x = \begin{cases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{cases}`
|
|
||||||
|$\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}$ | `\begin{smallmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{smallmatrix}` |$\begin{rcases} a &\text{if } b \\ c &\text{if } d \end{rcases}⇒…$ |`\begin{rcases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{rcases}⇒…`|
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
KaTeX also supports `darray`, `dcases`, and `drcases`.
|
|
||||||
|
|
||||||
Acceptable line separators include: `\\`, `\cr`, `\\[distance]`, and `\cr[distance]`. *Distance* can be written with any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
The `{array}` environment supports `|` and `:` vertical separators.
|
|
||||||
|
|
||||||
The `{array}` environment does not yet support `\cline` or `\multicolumn`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## HTML
|
|
||||||
|
|
||||||
The following "raw HTML" features are potentially dangerous for untrusted
|
|
||||||
inputs, so they are disabled by default, and attempting to use them produces
|
|
||||||
the command names in red (which you can configure via the `errorColor`
|
|
||||||
[option](options.md)). To fully trust your LaTeX input, you need to pass
|
|
||||||
an option of `trust: true`; you can also enable just some of the commands
|
|
||||||
or for just some URLs via the `trust` [option](options.md).
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------|:-------------------|
|
|
||||||
| $\href{https://katex.org/}{\KaTeX}$ | `\href{https://katex.org/}{\KaTeX}` |
|
|
||||||
| $\url{https://katex.org/}$ | `\url{https://katex.org/}` |
|
|
||||||
| $\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://katex.org/img/khan-academy.png}$ | `\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://katex.org/img/khan-academy.png}` |
|
|
||||||
| $\htmlId{bar}{x}$ <code>…<span id="bar" class="enclosing">…x…</span>…</code> | `\htmlId{bar}{x}` |
|
|
||||||
| $\htmlClass{foo}{x}$ <code>…<span class="enclosing foo">…x…</span>…</code> | `\htmlClass{foo}{x}` |
|
|
||||||
| $\htmlStyle{color: red;}{x}$ <code>…<span style="color: red;" class="enclosing">…x…</span>…</code> | `\htmlStyle{color: red;}{x}` |
|
|
||||||
| $\htmlData{foo=a, bar=b}{x}$ <code>…<span data-foo="a" data-bar="b" class="enclosing">…x…</span>…</code> | `\htmlData{foo=a, bar=b}{x}` |
|
|
||||||
|
|
||||||
`\includegraphics` supports `height`, `width`, `totalheight`, and `alt` in its first argument. `height` is required.
|
|
||||||
|
|
||||||
HTML extension (`\html`-prefixed) commands are non-standard, so loosening `strict` option for `htmlExtension` is required.
|
|
||||||
|
|
||||||
|
|
||||||
## Letters and Unicode
|
|
||||||
|
|
||||||
**Greek Letters**
|
|
||||||
|
|
||||||
Direct Input: $Α Β Γ Δ Ε Ζ Η Θ Ι \allowbreak Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω$
|
|
||||||
$\allowbreak α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π \allowbreak ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ ϝ$
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|---------------|-------------|-------------|---------------|
|
|
||||||
| $\Alpha$ `\Alpha` | $\Beta$ `\Beta` | $\Gamma$ `\Gamma`| $\Delta$ `\Delta`
|
|
||||||
| $\Epsilon$ `\Epsilon` | $\Zeta$ `\Zeta` | $\Eta$ `\Eta` | $\Theta$ `\Theta`
|
|
||||||
| $\Iota$ `\Iota` | $\Kappa$ `\Kappa` | $\Lambda$ `\Lambda` | $\Mu$ `\Mu`
|
|
||||||
| $\Nu$ `\Nu` | $\Xi$ `\Xi` | $\Omicron$ `\Omicron` | $\Pi$ `\Pi`
|
|
||||||
| $\Rho$ `\Rho` | $\Sigma$ `\Sigma` | $\Tau$ `\Tau` | $\Upsilon$ `\Upsilon`
|
|
||||||
| $\Phi$ `\Phi` | $\Chi$ `\Chi` | $\Psi$ `\Psi` | $\Omega$ `\Omega`
|
|
||||||
| $\varGamma$ `\varGamma`| $\varDelta$ `\varDelta` | $\varTheta$ `\varTheta` | $\varLambda$ `\varLambda` |
|
|
||||||
| $\varXi$ `\varXi`| $\varPi$ `\varPi` | $\varSigma$ `\varSigma` | $\varUpsilon$ `\varUpsilon` |
|
|
||||||
| $\varPhi$ `\varPhi` | $\varPsi$ `\varPsi`| $\varOmega$ `\varOmega` ||
|
|
||||||
| $\alpha$ `\alpha`| $\beta$ `\beta` | $\gamma$ `\gamma` | $\delta$ `\delta`|
|
|
||||||
| $\epsilon$ `\epsilon` | $\zeta$ `\zeta` | $\eta$ `\eta`| $\theta$ `\theta`|
|
|
||||||
| $\iota$ `\iota` | $\kappa$ `\kappa` | $\lambda$ `\lambda`| $\mu$ `\mu`|
|
|
||||||
| $\nu$ `\nu`| $\xi$ `\xi` | $\omicron$ `\omicron` | $\pi$ `\pi`|
|
|
||||||
| $\rho$ `\rho` | $\sigma$ `\sigma` | $\tau$ `\tau`| $\upsilon$ `\upsilon` |
|
|
||||||
| $\phi$ `\phi` | $\chi$ `\chi`| $\psi$ `\psi`| $\omega$ `\omega`|
|
|
||||||
| $\varepsilon$ `\varepsilon` | $\varkappa$ `\varkappa` | $\vartheta$ `\vartheta` | $\thetasym$ `\thetasym`
|
|
||||||
| $\varpi$ `\varpi`| $\varrho$ `\varrho` | $\varsigma$ `\varsigma` | $\varphi$ `\varphi`
|
|
||||||
| $\digamma $ `\digamma`
|
|
||||||
|
|
||||||
**Other Letters**
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:----------|:----------|:----------|:----------|:----------|
|
|
||||||
|$\imath$ `\imath`|$\nabla$ `\nabla`|$\Im$ `\Im`|$\Reals$ `\Reals`|$\text{\OE}$ `\text{\OE}`
|
|
||||||
|$\jmath$ `\jmath`|$\partial$ `\partial`|$\image$ `\image`|$\wp$ `\wp`|$\text{\o}$ `\text{\o}`
|
|
||||||
|$\aleph$ `\aleph`|$\Game$ `\Game`|$\Bbbk$ `\Bbbk`|$\weierp$ `\weierp`|$\text{\O}$ `\text{\O}`
|
|
||||||
|$\alef$ `\alef`|$\Finv$ `\Finv`|$\N$ `\N`|$\Z$ `\Z`|$\text{\ss}$ `\text{\ss}`
|
|
||||||
|$\alefsym$ `\alefsym`|$\cnums$ `\cnums`|$\natnums$ `\natnums`|$\text{\aa}$ `\text{\aa}`|$\text{\i}$ `\text{\i}`
|
|
||||||
|$\beth$ `\beth`|$\Complex$ `\Complex`|$\R$ `\R`|$\text{\AA}$ `\text{\AA}`|$\text{\j}$ `\text{\j}`
|
|
||||||
|$\gimel$ `\gimel`|$\ell$ `\ell`|$\Re$ `\Re`|$\text{\ae}$ `\text{\ae}`
|
|
||||||
|$\daleth$ `\daleth`|$\hbar$ `\hbar`|$\real$ `\real`|$\text{\AE}$ `\text{\AE}`
|
|
||||||
|$\eth$ `\eth`|$\hslash$ `\hslash`|$\reals$ `\reals`|$\text{\oe}$ `\text{\oe}`
|
|
||||||
|
|
||||||
Direct Input: $∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð$
|
|
||||||
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåçèéêëìíîïðñòóôöùúûüýþÿ
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="math-alpha">
|
|
||||||
|
|
||||||
**Unicode Mathematical Alphanumeric Symbols**
|
|
||||||
|
|
||||||
| Item | Range | Item | Range |
|
|
||||||
|-------------|---------------------|-------------------|---------------|
|
|
||||||
| Bold | $\text{𝐀-𝐙 𝐚-𝐳 𝟎-𝟗}$ | Double-struck | $\text{𝔸-}ℤ\ 𝕜$
|
|
||||||
| Italic | $\text{𝐴-𝑍 𝑎-𝑧}$ | Sans serif | $\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}$
|
|
||||||
| Bold Italic | $\text{𝑨-𝒁 𝒂-𝒛}$ | Sans serif bold | $\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}$
|
|
||||||
| Script | $\text{𝒜-𝒵}$ | Sans serif italic | $\text{𝘈-𝘡 𝘢-𝘻}$
|
|
||||||
| Fractur | $\text{𝔄-}ℨ\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
**Unicode**
|
|
||||||
|
|
||||||
The letters listed above will render properly in any KaTeX rendering mode.
|
|
||||||
|
|
||||||
In addition, Brahmic, Georgian, Chinese, Japanese, and Korean glyphs are always accepted in text mode. However, these glyphs will be rendered from system fonts (not KaTeX-supplied fonts) so their typography may clash.
|
|
||||||
You can provide rules for CSS classes `.latin_fallback`, `.cyrillic_fallback`, `.brahmic_fallback`, `.georgian_fallback`, `.cjk_fallback`, and `.hangul_fallback` to provide fallback fonts for these languages.
|
|
||||||
Use of these glyphs may cause small vertical alignment issues: KaTeX has detailed metrics for listed symbols and most Latin, Greek, and Cyrillic letters, but other accepted glyphs are treated as if they are each as tall as the letter M in the current KaTeX font.
|
|
||||||
|
|
||||||
If the KaTeX rendering mode is set to `strict: false` or `strict: "warn"` (default), then KaTeX will accept all Unicode letters in both text and math mode.
|
|
||||||
All unrecognized characters will be treated as if they appeared in text mode, and are subject to the same issues of using system fonts and possibly using incorrect vertical alignment.
|
|
||||||
|
|
||||||
For Persian composite characters, a user-supplied [plug-in](https://github.com/HosseinAgha/persian-katex-plugin) is under development.
|
|
||||||
|
|
||||||
## Layout
|
|
||||||
|
|
||||||
### Annotation
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:------------------------------|:-----
|
|
||||||
|$\cancel{5}$ `\cancel{5}`|$\overbrace{a+b+c}^{\text{note}}$ `\overbrace{a+b+c}^{\text{note}}`
|
|
||||||
|$\bcancel{5}$ `\bcancel{5}` |$\underbrace{a+b+c}_{\text{note}}$ `\underbrace{a+b+c}_{\text{note}}`
|
|
||||||
|$\xcancel{ABC}$ `\xcancel{ABC}`|$\not =$ `\not =`
|
|
||||||
|$\sout{abc}$ `\sout{abc}`|$\boxed{\pi=\frac c d}$ `\boxed{\pi=\frac c d}`
|
|
||||||
|
|
||||||
`\tag{hi} x+y^{2x}`
|
|
||||||
$$\tag{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
`\tag*{hi} x+y^{2x}`
|
|
||||||
$$\tag*{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
### Line Breaks
|
|
||||||
|
|
||||||
KaTeX 0.10.0+ will insert automatic line breaks in inline math after relations or binary operators such as “=” or “+”. These can be suppressed by `\nobreak` or by placing math inside a pair of braces, as in `{F=ma}`. `\allowbreak` will allow automatic line breaks at locations other than relations or operators.
|
|
||||||
|
|
||||||
Hard line breaks are `\\` and `\newline`.
|
|
||||||
|
|
||||||
In display math, KaTeX does not insert automatic line breaks. It ignores display math hard line breaks when rendering option `strict: true`.
|
|
||||||
|
|
||||||
### Vertical Layout
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------|:----------------------------------------|:-----
|
|
||||||
|$x_n$ `x_n` |$\stackrel{!}{=}$ `\stackrel{!}{=}` |$a \atop b$ `a \atop b`
|
|
||||||
|$e^x$ `e^x` |$\overset{!}{=}$ `\overset{!}{=}` |$a\raisebox{0.25em}{b}c$ `a\raisebox{0.25em}{b}c`
|
|
||||||
|$_u^o $ `_u^o `|$\underset{!}{=}$ `\underset{!}{=}` | $$\sum_{\substack{0<i<m\\0<j<n}}$$ `\sum_{\substack{0<i<m\\0<j<n}}`
|
|
||||||
|
|
||||||
The second argument of `\raisebox` can contain math if it is nested within `$…$` delimiters, as in `\raisebox{0.25em}{$\frac a b$}`
|
|
||||||
|
|
||||||
### Overlap and Spacing
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------|:-------|
|
|
||||||
|${=}\mathllap{/\,}$ `{=}\mathllap{/\,}` | $\left(x^{\smash{2}}\right)$ `\left(x^{\smash{2}}\right)`
|
|
||||||
|$\mathrlap{\,/}{=}$ `\mathrlap{\,/}{=}` | $\sqrt{\smash[b]{y}}$ `\sqrt{\smash[b]{y}} `
|
|
||||||
|
|
||||||
$\displaystyle\sum_{\mathclap{1\le i\le j\le n}} x_{ij}$ `\sum_{\mathclap{1\le i\le j\le n}} x_{ij}`
|
|
||||||
|
|
||||||
KaTeX also supports `\llap`, `\rlap`, and `\clap`, but they will take only text, not math, as arguments.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="spacing-tbl">
|
|
||||||
|
|
||||||
**Spacing**
|
|
||||||
|
|
||||||
| Function | Produces | Function | Produces|
|
|
||||||
|:----------------|:-------------------|:---------------------|:--------------------------------------|
|
|
||||||
| `\,` | ³∕₁₈ em space | `\kern{distance}` | space, width = *distance*
|
|
||||||
| `\thinspace` | ³∕₁₈ em space | `\mkern{distance}` | space, width = *distance*
|
|
||||||
| `\>` | ⁴∕₁₈ em space | `\mskip{distance}` | space, width = *distance*
|
|
||||||
| `\:` | ⁴∕₁₈ em space | `\hskip{distance}` | space, width = *distance*
|
|
||||||
| `\medspace` | ⁴∕₁₈ em space | `\hspace{distance}` | space, width = *distance*
|
|
||||||
| `\;` | ⁵∕₁₈ em space | `\hspace*{distance}` | space, width = *distance*
|
|
||||||
| `\thickspace` | ⁵∕₁₈ em space | `\phantom{content}` | space the width and height of content
|
|
||||||
| `\enspace` | ½ em space | `\hphantom{content}` | space the width of content
|
|
||||||
| `\quad` | 1 em space | `\vphantom{content}` | a strut the height of content
|
|
||||||
| `\qquad` | 2 em space | `\!` | – ³∕₁₈ em space
|
|
||||||
| `~` | non-breaking space | `\negthinspace` | – ³∕₁₈ em space
|
|
||||||
| `\<space>` | space | `\negmedspace` | – ⁴∕₁₈ em space
|
|
||||||
| `\nobreakspace` | non-breaking space | `\negthickspace` | – ⁵∕₁₈ em space
|
|
||||||
| `\space` | space |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
**Notes:**
|
|
||||||
|
|
||||||
`distance` will accept any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
`\kern`, `\mkern`, `\mskip`, and `\hspace` accept unbraced distances, as in: `\kern1em`.
|
|
||||||
|
|
||||||
`\mkern` and `\mskip` will not work in text mode and both will write a console warning for any unit except `mu`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Logic and Set Theory
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:--------------------|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\forall$ `\forall` |$\complement$ `\complement`|$\therefore$ `\therefore` |$\emptyset$ `\emptyset`
|
|
||||||
|$\exists$ `\exists` |$\subset$ `\subset` |$\because$ `\because` |$\empty$ `\empty`
|
|
||||||
|$\exist$ `\exist` |$\supset$ `\supset` |$\mapsto$ `\mapsto` |$\varnothing$ `\varnothing`
|
|
||||||
|$\nexists$ `\nexists`|$\mid$ `\mid` |$\to$ `\to` |$\implies$ `\implies`
|
|
||||||
|$\in$ `\in` |$\land$ `\land` |$\gets$ `\gets` |$\impliedby$ `\impliedby`
|
|
||||||
|$\isin$ `\isin` |$\lor$ `\lor` |$\leftrightarrow$ `\leftrightarrow`|$\iff$ `\iff`
|
|
||||||
|$\notin$ `\notin` |$\ni$ `\ni` |$\notni$ `\notni` |$\neg$ `\neg` or `\lnot`
|
|
||||||
|
|
||||||
Direct Input: $∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬$ ℂ ℍ ℕ ℙ ℚ ℝ
|
|
||||||
|
|
||||||
## Macros
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------------------------------------|:------
|
|
||||||
|$\def\foo{x^2} \foo + \foo$ | `\def\foo{x^2} \foo + \foo`
|
|
||||||
|$\gdef\bar#1{#1^2} \bar{y} + \bar{y}$ | `\gdef\bar#1{#1^2} \bar{y} + \bar{y}`
|
|
||||||
| | `\edef\macroname#1#2…{definition to be expanded}`
|
|
||||||
| | `\xdef\macroname#1#2…{definition to be expanded}`
|
|
||||||
| | `\let\foo=\bar`
|
|
||||||
| | `\futurelet\foo\bar x`
|
|
||||||
| | `\global\def\macroname#1#2…{definition}`
|
|
||||||
| | `\newcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\renewcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\providecommand\macroname[numargs]{definition}`
|
|
||||||
|
|
||||||
Macros can also be defined in the KaTeX [rendering options](options.md).
|
|
||||||
|
|
||||||
Macros accept up to nine arguments: #1, #2, etc.
|
|
||||||
Delimiters (such as `\def\add#1+#2{#1\oplus#2}`) are not currently supported.
|
|
||||||
|
|
||||||
`\gdef`, `\xdef`, `\global\def`, `\global\edef`, `\global\let`, and `\global\futurelet` will persist between math expressions.
|
|
||||||
|
|
||||||
KaTeX has no `\par`, so all macros are long by default and `\long` will be ignored.
|
|
||||||
|
|
||||||
Available functions include:
|
|
||||||
|
|
||||||
`\char` `\mathchoice` `\TextOrMath` `\@ifstar` `\@ifnextchar` `\@firstoftwo` `\@secondoftwo` `\relax` `\expandafter` `\noexpand`
|
|
||||||
|
|
||||||
@ is a valid character for commands, as if `\makeatletter` were in effect.
|
|
||||||
|
|
||||||
## Operators
|
|
||||||
|
|
||||||
### Big Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|------------------|-------------------------|--------------------------|--------------|
|
|
||||||
| $\sum$ `\sum` | $\prod$ `\prod` | $\bigotimes$ `\bigotimes`| $\bigvee$ `\bigvee`
|
|
||||||
| $\int$ `\int` | $\coprod$ `\coprod` | $\bigoplus$ `\bigoplus` | $\bigwedge$ `\bigwedge`
|
|
||||||
| $\iint$ `\iint` | $\intop$ `\intop` | $\bigodot$ `\bigodot` | $\bigcap$ `\bigcap`
|
|
||||||
| $\iiint$ `\iiint`| $\smallint$ `\smallint` | $\biguplus$ `\biguplus` | $\bigcup$ `\bigcup`
|
|
||||||
| $\oint$ `\oint` | $\oiint$ `\oiint` | $\oiiint$ `\oiiint` | $\bigsqcup$ `\bigsqcup`
|
|
||||||
|
|
||||||
Direct Input: $∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆$
|
|
||||||
|
|
||||||
### Binary Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-------------|-------------------|-------------------|--------------------|
|
|
||||||
| $+$ `+`| $\cdot$ `\cdot` | $\gtrdot$ `\gtrdot`| $x \pmod a$ `x \pmod a`|
|
|
||||||
| $-$ `-`| $\cdotp$ `\cdotp` | $\intercal$ `\intercal` | $x \pod a$ `x \pod a` |
|
|
||||||
| $/$ `/`| $\centerdot$ `\centerdot`| $\land$ `\land` | $\rhd$ `\rhd` |
|
|
||||||
| $*$ `*`| $\circ$ `\circ` | $\leftthreetimes$ `\leftthreetimes` | $\rightthreetimes$ `\rightthreetimes` |
|
|
||||||
| $\amalg$ `\amalg` | $\circledast$ `\circledast` | $\ldotp$ `\ldotp` | $\rtimes$ `\rtimes` |
|
|
||||||
| $\And$ `\And`| $\circledcirc$ `\circledcirc` | $\lor$ `\lor`| $\setminus$ `\setminus` |
|
|
||||||
| $\ast$ `\ast`| $\circleddash$ `\circleddash` | $\lessdot$ `\lessdot` | $\smallsetminus$ `\smallsetminus`|
|
|
||||||
| $\barwedge$ `\barwedge` | $\Cup$ `\Cup`| $\lhd$ `\lhd`| $\sqcap$ `\sqcap` |
|
|
||||||
| $\bigcirc$ `\bigcirc` | $\cup$ `\cup`| $\ltimes$ `\ltimes`| $\sqcup$ `\sqcup` |
|
|
||||||
| $\bmod$ `\bmod` | $\curlyvee$ `\curlyvee` | $x \mod a$ `x\mod a`| $\times$ `\times` |
|
|
||||||
| $\boxdot$ `\boxdot`| $\curlywedge$ `\curlywedge` | $\mp$ `\mp` | $\unlhd$ `\unlhd` |
|
|
||||||
| $\boxminus$ `\boxminus` | $\div$ `\div`| $\odot$ `\odot` | $\unrhd$ `\unrhd` |
|
|
||||||
| $\boxplus$ `\boxplus` | $\divideontimes$ `\divideontimes` | $\ominus$ `\ominus`| $\uplus$ `\uplus` |
|
|
||||||
| $\boxtimes$ `\boxtimes` | $\dotplus$ `\dotplus` | $\oplus$ `\oplus` | $\vee$ `\vee` |
|
|
||||||
| $\bullet$ `\bullet`| $\doublebarwedge$ `\doublebarwedge` | $\otimes$ `\otimes`| $\veebar$ `\veebar` |
|
|
||||||
| $\Cap$ `\Cap`| $\doublecap$ `\doublecap`| $\oslash$ `\oslash`| $\wedge$ `\wedge` |
|
|
||||||
| $\cap$ `\cap`| $\doublecup$ `\doublecup`| $\pm$ `\pm` or `\plusmn` | $\wr$ `\wr` |
|
|
||||||
|
|
||||||
Direct Input: $+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝$
|
|
||||||
|
|
||||||
### Fractions and Binomials
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\frac{a}{b}$ `\frac{a}{b}`|$\tfrac{a}{b}$ `\tfrac{a}{b}`|$\genfrac ( ] {2pt}{1}a{a+1}$ `\genfrac ( ] {2pt}{1}a{a+1}`
|
|
||||||
|${a \over b}$ `{a \over b}`|$\dfrac{a}{b}$ `\dfrac{a}{b}`|${a \above{2pt} b+1}$ `{a \above{2pt} b+1}`
|
|
||||||
|$a/b$ `a/b` | |$\cfrac{a}{1 + \cfrac{1}{b}}$ `\cfrac{a}{1 + \cfrac{1}{b}}`
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:--------
|
|
||||||
|$\binom{n}{k}$ `\binom{n}{k}` |$\dbinom{n}{k}$ `\dbinom{n}{k}`|${n\brace k}$ `{n\brace k}`
|
|
||||||
|${n \choose k}$ `{n \choose k}`|$\tbinom{n}{k}$ `\tbinom{n}{k}`|${n\brack k}$ `{n\brack k}`
|
|
||||||
|
|
||||||
### Math Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-----------|---------|-----------------|-----------|
|
|
||||||
| $\arcsin$ `\arcsin` | $\cotg$ `\cotg` | $\ln$ `\ln` | $\det$ `\det` |
|
|
||||||
| $\arccos$ `\arccos` | $\coth$ `\coth` | $\log$ `\log` | $\gcd$ `\gcd` |
|
|
||||||
| $\arctan$ `\arctan` | $\csc$ `\csc` | $\sec$ `\sec` | $\inf$ `\inf` |
|
|
||||||
| $\arctg$ `\arctg` | $\ctg$ `\ctg` | $\sin$ `\sin` | $\lim$ `\lim` |
|
|
||||||
| $\arcctg$ `\arcctg` | $\cth$ `\cth` | $\sinh$ `\sinh`| $\liminf$ `\liminf` |
|
|
||||||
| $\arg$ `\arg` | $\deg$ `\deg` | $\sh$ `\sh` | $\limsup$ `\limsup` |
|
|
||||||
| $\ch$ `\ch` | $\dim$ `\dim` | $\tan$ `\tan` | $\max$ `\max` |
|
|
||||||
| $\cos$ `\cos` | $\exp$ `\exp` | $\tanh$ `\tanh`| $\min$ `\min` |
|
|
||||||
| $\cosec$ `\cosec` | $\hom$ `\hom` | $\tg$ `\tg` | $\Pr$ `\Pr` |
|
|
||||||
| $\cosh$ `\cosh`| $\ker$ `\ker` | $\th$ `\th` | $\sup$ `\sup` |
|
|
||||||
| $\cot$ `\cot` | $\lg$ `\lg`| $\argmax$ `\argmax` | $\argmin$ `\argmin` |
|
|
||||||
| $\plim$ `\plim` | $\operatorname{f}$ `\operatorname{f}`| $\operatorname*{f}$ `\operatorname*{f}`| |
|
|
||||||
|
|
||||||
Functions on the right column of this table can take `\limits`.
|
|
||||||
|
|
||||||
### \sqrt
|
|
||||||
|
|
||||||
$\sqrt{x}$ `\sqrt{x}`
|
|
||||||
|
|
||||||
$\sqrt[3]{x}$ `\sqrt[3]{x}`
|
|
||||||
|
|
||||||
## Relations
|
|
||||||
|
|
||||||
$\stackrel{!}{=}$ `\stackrel{!}{=}`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:----------------------------|:--------------------------------|:--------------------------------|:-----
|
|
||||||
|$=$ `=` |$\eqcirc$ `\eqcirc` |$\lesseqgtr$ `\lesseqgtr` |$\sqsupset$ `\sqsupset`
|
|
||||||
|$<$ `<` |$\eqcolon$ `\eqcolon`|$\lesseqqgtr$ `\lesseqqgtr`|$\sqsupseteq$ `\sqsupseteq`
|
|
||||||
|$>$ `>` |$\Eqcolon$ `\Eqcolon`|$\lessgtr$ `\lessgtr`|$\Subset$ `\Subset`
|
|
||||||
|$:$ `:` |$\eqqcolon$ `\eqqcolon` |$\lesssim$ `\lesssim`|$\subset$ `\subset` or `\sub`
|
|
||||||
|$\approx$ `\approx` |$\Eqqcolon$ `\Eqqcolon` |$\ll$ `\ll` |$\subseteq$ `\subseteq` or `\sube`
|
|
||||||
|$\approxeq$ `\approxeq`|$\eqsim$ `\eqsim` |$\lll$ `\lll` |$\subseteqq$ `\subseteqq`
|
|
||||||
|$\asymp$ `\asymp`|$\eqslantgtr$ `\eqslantgtr`|$\llless$ `\llless` |$\succ$ `\succ`
|
|
||||||
|$\backepsilon$ `\backepsilon`|$\eqslantless$ `\eqslantless` |$\lt$ `\lt` |$\succapprox$ `\succapprox`
|
|
||||||
|$\backsim$ `\backsim` |$\equiv$ `\equiv` |$\mid$ `\mid` |$\succcurlyeq$ `\succcurlyeq`
|
|
||||||
|$\backsimeq$ `\backsimeq` |$\fallingdotseq$ `\fallingdotseq`|$\models$ `\models` |$\succeq$ `\succeq`
|
|
||||||
|$\between$ `\between` |$\frown$ `\frown` |$\multimap$ `\multimap` |$\succsim$ `\succsim`
|
|
||||||
|$\bowtie$ `\bowtie` |$\ge$ `\ge` |$\owns$ `\owns`|$\Supset$ `\Supset`
|
|
||||||
|$\bumpeq$ `\bumpeq` |$\geq$ `\geq` |$\parallel$ `\parallel` |$\supset$ `\supset`
|
|
||||||
|$\Bumpeq$ `\Bumpeq` |$\geqq$ `\geqq`|$\perp$ `\perp`|$\supseteq$ `\supseteq` or `\supe`
|
|
||||||
|$\circeq$ `\circeq` |$\geqslant$ `\geqslant` |$\pitchfork$ `\pitchfork` |$\supseteqq$ `\supseteqq`
|
|
||||||
|$\colonapprox$ `\colonapprox`|$\gg$ `\gg` |$\prec$ `\prec`|$\thickapprox$ `\thickapprox`
|
|
||||||
|$\Colonapprox$ `\Colonapprox`|$\ggg$ `\ggg` |$\precapprox$ `\precapprox`|$\thicksim$ `\thicksim`
|
|
||||||
|$\coloneq$ `\coloneq` |$\gggtr$ `\gggtr` |$\preccurlyeq$ `\preccurlyeq` |$\trianglelefteq$ `\trianglelefteq`
|
|
||||||
|$\Coloneq$ `\Coloneq` |$\gt$ `\gt` |$\preceq$ `\preceq` |$\triangleq$ `\triangleq`
|
|
||||||
|$\coloneqq$ `\coloneqq`|$\gtrapprox$ `\gtrapprox` |$\precsim$ `\precsim`|$\trianglerighteq$ `\trianglerighteq`
|
|
||||||
|$\Coloneqq$ `\Coloneqq`|$\gtreqless$ `\gtreqless` |$\propto$ `\propto` |$\varpropto$ `\varpropto`
|
|
||||||
|$\colonsim$ `\colonsim`|$\gtreqqless$ `\gtreqqless`|$\risingdotseq$ `\risingdotseq` |$\vartriangle$ `\vartriangle`
|
|
||||||
|$\Colonsim$ `\Colonsim`|$\gtrless$ `\gtrless`|$\shortmid$ `\shortmid` |$\vartriangleleft$ `\vartriangleleft`
|
|
||||||
|$\cong$ `\cong` |$\gtrsim$ `\gtrsim` |$\shortparallel$ `\shortparallel`|$\vartriangleright$ `\vartriangleright`
|
|
||||||
|$\curlyeqprec$ `\curlyeqprec`|$\in$ `\in` or `\isin` |$\sim$ `\sim` |$\vcentcolon$ `\vcentcolon`
|
|
||||||
|$\curlyeqsucc$ `\curlyeqsucc`|$\Join$ `\Join`|$\simeq$ `\simeq` |$\vdash$ `\vdash`
|
|
||||||
|$\dashv$ `\dashv`|$\le$ `\le` |$\smallfrown$ `\smallfrown`|$\vDash$ `\vDash`
|
|
||||||
|$\dblcolon$ `\dblcolon`|$\leq$ `\leq` |$\smallsmile$ `\smallsmile`|$\Vdash$ `\Vdash`
|
|
||||||
|$\doteq$ `\doteq`|$\leqq$ `\leqq`|$\smile$ `\smile` |$\Vvdash$ `\Vvdash`
|
|
||||||
|$\Doteq$ `\Doteq`|$\leqslant$ `\leqslant` |$\sqsubset$ `\sqsubset` |
|
|
||||||
|$\doteqdot$ `\doteqdot`|$\lessapprox$ `\lessapprox`|$\sqsubseteq$ `\sqsubseteq`|
|
|
||||||
|
|
||||||
|
|
||||||
Direct Input: $= < > : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⟂ ⊨$ `≔ ≕ ⩴`
|
|
||||||
|
|
||||||
### Negated Relations
|
|
||||||
|
|
||||||
$\not =$ `\not =`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|--------------|-------------------|---------------------|------------------|
|
|
||||||
| $\gnapprox$ `\gnapprox` | $\ngeqslant$ `\ngeqslant`| $\nsubseteq$ `\nsubseteq` | $\precneqq$ `\precneqq`|
|
|
||||||
| $\gneq$ `\gneq`| $\ngtr$ `\ngtr` | $\nsubseteqq$ `\nsubseteqq` | $\precnsim$ `\precnsim`|
|
|
||||||
| $\gneqq$ `\gneqq` | $\nleq$ `\nleq` | $\nsucc$ `\nsucc`| $\subsetneq$ `\subsetneq` |
|
|
||||||
| $\gnsim$ `\gnsim` | $\nleqq$ `\nleqq` | $\nsucceq$ `\nsucceq` | $\subsetneqq$ `\subsetneqq` |
|
|
||||||
| $\gvertneqq$ `\gvertneqq` | $\nleqslant$ `\nleqslant`| $\nsupseteq$ `\nsupseteq` | $\succnapprox$ `\succnapprox`|
|
|
||||||
| $\lnapprox$ `\lnapprox` | $\nless$ `\nless` | $\nsupseteqq$ `\nsupseteqq` | $\succneqq$ `\succneqq`|
|
|
||||||
| $\lneq$ `\lneq`| $\nmid$ `\nmid` | $\ntriangleleft$ `\ntriangleleft` | $\succnsim$ `\succnsim`|
|
|
||||||
| $\lneqq$ `\lneqq` | $\notin$ `\notin` | $\ntrianglelefteq$ `\ntrianglelefteq` | $\supsetneq$ `\supsetneq` |
|
|
||||||
| $\lnsim$ `\lnsim` | $\notni$ `\notni` | $\ntriangleright$ `\ntriangleright`| $\supsetneqq$ `\supsetneqq` |
|
|
||||||
| $\lvertneqq$ `\lvertneqq` | $\nparallel$ `\nparallel`| $\ntrianglerighteq$ `\ntrianglerighteq` | $\varsubsetneq$ `\varsubsetneq` |
|
|
||||||
| $\ncong$ `\ncong` | $\nprec$ `\nprec` | $\nvdash$ `\nvdash` | $\varsubsetneqq$ `\varsubsetneqq` |
|
|
||||||
| $\ne$ `\ne` | $\npreceq$ `\npreceq` | $\nvDash$ `\nvDash` | $\varsupsetneq$ `\varsupsetneq` |
|
|
||||||
| $\neq$ `\neq` | $\nshortmid$ `\nshortmid`| $\nVDash$ `\nVDash` | $\varsupsetneqq$ `\varsupsetneqq` |
|
|
||||||
| $\ngeq$ `\ngeq`| $\nshortparallel$ `\nshortparallel` | $\nVdash$ `\nVdash` |
|
|
||||||
| $\ngeqq$ `\ngeqq` | $\nsim$ `\nsim` | $\precnapprox$ `\precnapprox`|
|
|
||||||
|
|
||||||
Direct Input: $∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌$
|
|
||||||
|
|
||||||
### Arrows
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|$\circlearrowleft$ `\circlearrowleft`|$\leftharpoonup$ `\leftharpoonup`|$\rArr$ `\rArr`
|
|
||||||
|$\circlearrowright$ `\circlearrowright`|$\leftleftarrows$ `\leftleftarrows`|$\rarr$ `\rarr`
|
|
||||||
|$\curvearrowleft$ `\curvearrowleft`|$\leftrightarrow$ `\leftrightarrow`|$\restriction$ `\restriction`
|
|
||||||
|$\curvearrowright$ `\curvearrowright`|$\Leftrightarrow$ `\Leftrightarrow`|$\rightarrow$ `\rightarrow`
|
|
||||||
|$\Darr$ `\Darr`|$\leftrightarrows$ `\leftrightarrows`|$\Rightarrow$ `\Rightarrow`
|
|
||||||
|$\dArr$ `\dArr`|$\leftrightharpoons$ `\leftrightharpoons`|$\rightarrowtail$ `\rightarrowtail`
|
|
||||||
|$\darr$ `\darr`|$\leftrightsquigarrow$ `\leftrightsquigarrow`|$\rightharpoondown$ `\rightharpoondown`
|
|
||||||
|$\dashleftarrow$ `\dashleftarrow`|$\Lleftarrow$ `\Lleftarrow`|$\rightharpoonup$ `\rightharpoonup`
|
|
||||||
|$\dashrightarrow$ `\dashrightarrow`|$\longleftarrow$ `\longleftarrow`|$\rightleftarrows$ `\rightleftarrows`
|
|
||||||
|$\downarrow$ `\downarrow`|$\Longleftarrow$ `\Longleftarrow`|$\rightleftharpoons$ `\rightleftharpoons`
|
|
||||||
|$\Downarrow$ `\Downarrow`|$\longleftrightarrow$ `\longleftrightarrow`|$\rightrightarrows$ `\rightrightarrows`
|
|
||||||
|$\downdownarrows$ `\downdownarrows`|$\Longleftrightarrow$ `\Longleftrightarrow`|$\rightsquigarrow$ `\rightsquigarrow`
|
|
||||||
|$\downharpoonleft$ `\downharpoonleft`|$\longmapsto$ `\longmapsto`|$\Rrightarrow$ `\Rrightarrow`
|
|
||||||
|$\downharpoonright$ `\downharpoonright`|$\longrightarrow$ `\longrightarrow`|$\Rsh$ `\Rsh`
|
|
||||||
|$\gets$ `\gets`|$\Longrightarrow$ `\Longrightarrow`|$\searrow$ `\searrow`
|
|
||||||
|$\Harr$ `\Harr`|$\looparrowleft$ `\looparrowleft`|$\swarrow$ `\swarrow`
|
|
||||||
|$\hArr$ `\hArr`|$\looparrowright$ `\looparrowright`|$\to$ `\to`
|
|
||||||
|$\harr$ `\harr`|$\Lrarr$ `\Lrarr`|$\twoheadleftarrow$ `\twoheadleftarrow`
|
|
||||||
|$\hookleftarrow$ `\hookleftarrow`|$\lrArr$ `\lrArr`|$\twoheadrightarrow$ `\twoheadrightarrow`
|
|
||||||
|$\hookrightarrow$ `\hookrightarrow`|$\lrarr$ `\lrarr`|$\Uarr$ `\Uarr`
|
|
||||||
|$\iff$ `\iff`|$\Lsh$ `\Lsh`|$\uArr$ `\uArr`
|
|
||||||
|$\impliedby$ `\impliedby`|$\mapsto$ `\mapsto`|$\uarr$ `\uarr`
|
|
||||||
|$\implies$ `\implies`|$\nearrow$ `\nearrow`|$\uparrow$ `\uparrow`
|
|
||||||
|$\Larr$ `\Larr`|$\nleftarrow$ `\nleftarrow`|$\Uparrow$ `\Uparrow`
|
|
||||||
|$\lArr$ `\lArr`|$\nLeftarrow$ `\nLeftarrow`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$\larr$ `\larr`|$\nleftrightarrow$ `\nleftrightarrow`|$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\leadsto$ `\leadsto`|$\nLeftrightarrow$ `\nLeftrightarrow`|$\upharpoonleft$ `\upharpoonleft`
|
|
||||||
|$\leftarrow$ `\leftarrow`|$\nrightarrow$ `\nrightarrow`|$\upharpoonright$ `\upharpoonright`
|
|
||||||
|$\Leftarrow$ `\Leftarrow`|$\nRightarrow$ `\nRightarrow`|$\upuparrows$ `\upuparrows`
|
|
||||||
|$\leftarrowtail$ `\leftarrowtail`|$\nwarrow$ `\nwarrow`
|
|
||||||
|$\leftharpoondown$ `\leftharpoondown`|$\Rarr$ `\Rarr`
|
|
||||||
|
|
||||||
Direct Input: $← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼$ ↽
|
|
||||||
|
|
||||||
**Extensible Arrows**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------------------------------------|:-----
|
|
||||||
|$\xleftarrow{abc}$ `\xleftarrow{abc}` |$\xrightarrow[under]{over}$ `\xrightarrow[under]{over}`
|
|
||||||
|$\xLeftarrow{abc}$ `\xLeftarrow{abc}` |$\xRightarrow{abc}$ `\xRightarrow{abc}`
|
|
||||||
|$\xleftrightarrow{abc}$ `\xleftrightarrow{abc}` |$\xLeftrightarrow{abc}$ `\xLeftrightarrow{abc}`
|
|
||||||
|$\xhookleftarrow{abc}$ `\xhookleftarrow{abc}` |$\xhookrightarrow{abc}$ `\xhookrightarrow{abc}`
|
|
||||||
|$\xtwoheadleftarrow{abc}$ `\xtwoheadleftarrow{abc}` |$\xtwoheadrightarrow{abc}$ `\xtwoheadrightarrow{abc}`
|
|
||||||
|$\xleftharpoonup{abc}$ `\xleftharpoonup{abc}` |$\xrightharpoonup{abc}$ `\xrightharpoonup{abc}`
|
|
||||||
|$\xleftharpoondown{abc}$ `\xleftharpoondown{abc}` |$\xrightharpoondown{abc}$ `\xrightharpoondown{abc}`
|
|
||||||
|$\xleftrightharpoons{abc}$ `\xleftrightharpoons{abc}`|$\xrightleftharpoons{abc}$ `\xrightleftharpoons{abc}`
|
|
||||||
|$\xtofrom{abc}$ `\xtofrom{abc}` |$\xmapsto{abc}$ `\xmapsto{abc}`
|
|
||||||
|$\xlongequal{abc}$ `\xlongequal{abc}`
|
|
||||||
|
|
||||||
Extensible arrows all can take an optional argument in the same manner<br>as `\xrightarrow[under]{over}`.
|
|
||||||
|
|
||||||
## Special Notation
|
|
||||||
|
|
||||||
**Bra-ket Notation**
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|$\bra{\phi}$ `\bra{\phi}` |$\ket{\psi}$ `\ket{\psi}` |$\braket{\phi\vert\psi}$ `\braket{\phi\vert\psi}` |
|
|
||||||
|$\Bra{\phi}$ `\Bra{\phi}` |$\Ket{\psi}$ `\Ket{\psi}` ||
|
|
||||||
|
|
||||||
## Style, Color, Size, and Font
|
|
||||||
|
|
||||||
**Class Assignment**
|
|
||||||
|
|
||||||
`\mathbin` `\mathclose` `\mathinner` `\mathop`<br>
|
|
||||||
`\mathopen` `\mathord` `\mathpunct` `\mathrel`
|
|
||||||
|
|
||||||
**Color**
|
|
||||||
|
|
||||||
$\color{blue} F=ma$ `\color{blue} F=ma`
|
|
||||||
|
|
||||||
Note that KaTeX `\color` acts like a switch. This aligns with LaTeX and differs from MathJax.
|
|
||||||
Other KaTeX color functions expect the content to be a function argument:
|
|
||||||
|
|
||||||
$\textcolor{blue}{F=ma}$ `\textcolor{blue}{F=ma}`<br>
|
|
||||||
$\textcolor{#228B22}{F=ma}$ `\textcolor{#228B22}{F=ma}`<br>
|
|
||||||
$\colorbox{aqua}{$F=ma$}$ `\colorbox{aqua}{$F=ma$}`<br>
|
|
||||||
$\fcolorbox{red}{aqua}{$F=ma$}$ `\fcolorbox{red}{aqua}{$F=ma$}`
|
|
||||||
|
|
||||||
Note that, as in LaTeX, `\colorbox` & `\fcolorbox` renders its third argument as text, so you may want to switch back to math mode with `$` as in the examples above.
|
|
||||||
|
|
||||||
For color definition, KaTeX color functions will accept the standard HTML [predefined color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords). They will also accept an RGB argument in CSS hexadecimal style. The "#" is optional before a six-digit specification.
|
|
||||||
|
|
||||||
**Font**
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:-----
|
|
||||||
|$\mathrm{Ab0}$ `\mathrm{Ab0}` |$\mathbf{Ab0}$ `\mathbf{Ab0}` |$\mathit{Ab0}$ `\mathit{Ab0}`
|
|
||||||
|$\mathnormal{Ab0}$ `\mathnormal{Ab0}`|$\textbf{Ab0}$ `\textbf{Ab0}` |$\textit{Ab0}$ `\textit{Ab0}`
|
|
||||||
|$\textrm{Ab0}$ `\textrm{Ab0}` |$\bf Ab0$ `\bf Ab0` |$\it Ab0$ `\it Ab0`
|
|
||||||
|$\rm Ab0$ `\rm Ab0` |$\bold{Ab0}$ `\bold{Ab0}` |$\textup{Ab0}$ `\textup{Ab0}`
|
|
||||||
|$\textnormal{Ab0}$ `\textnormal{Ab0}`|$\boldsymbol{Ab0}$ `\boldsymbol{Ab}`|$\Bbb{AB}$ `\Bbb{AB}`
|
|
||||||
|$\text{Ab0}$ `\text{Ab0}` |$\bm{Ab0}$ `\bm{Ab0}` |$\mathbb{AB}$ `\mathbb{AB}`
|
|
||||||
|$\mathsf{Ab0}$ `\mathsf{Ab0}` |$\textmd{Ab0}$ `\textmd{Ab0}` |$\frak{Ab0}$ `\frak{Ab0}`
|
|
||||||
|$\textsf{Ab0}$ `\textsf{Ab0}` |$\mathtt{Ab0}$ `\mathtt{Ab0}` |$\mathfrak{Ab0}$ `\mathfrak{Ab0}`
|
|
||||||
|$\sf Ab0$ `\sf Ab0` |$\texttt{Ab0}$ `\texttt{Ab0}` |$\mathcal{AB0}$ `\mathcal{AB0}`
|
|
||||||
| |$\tt Ab0$ `\tt Ab0` |$\cal AB0$ `\cal AB0`
|
|
||||||
| | |$\mathscr{AB}$ `\mathscr{AB}`
|
|
||||||
|
|
||||||
One can stack font family, font weight, and font shape by using the `\textXX` versions of the font functions. So `\textsf{\textbf{H}}` will produce $\textsf{\textbf{H}}$. The other versions do not stack, e.g., `\mathsf{\mathbf{H}}` will produce $\mathsf{\mathbf{H}}$.
|
|
||||||
|
|
||||||
In cases where KaTeX fonts do not have a bold glyph, `\pmb` can simulate one. For example, `\pmb{\mu}` renders as : $\pmb{\mu}$
|
|
||||||
|
|
||||||
**Size**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------|:-----
|
|
||||||
|$\Huge AB$ `\Huge AB` |$\normalsize AB$ `\normalsize AB`
|
|
||||||
|$\huge AB$ `\huge AB` |$\small AB$ `\small AB`
|
|
||||||
|$\LARGE AB$ `\LARGE AB`|$\footnotesize AB$ `\footnotesize AB`
|
|
||||||
|$\Large AB$ `\Large AB`|$\scriptsize AB$ `\scriptsize AB`
|
|
||||||
|$\large AB$ `\large AB`|$\tiny AB$ `\tiny AB`
|
|
||||||
|
|
||||||
|
|
||||||
**Style**
|
|
||||||
|
|
||||||
||
|
|
||||||
|:-------------------------------------------------------|
|
|
||||||
|$\displaystyle\sum_{i=1}^n$ `\displaystyle\sum_{i=1}^n`
|
|
||||||
|$\textstyle\sum_{i=1}^n$ `\textstyle\sum_{i=1}^n`
|
|
||||||
|$\scriptstyle x$ `\scriptstyle x` (The size of a first sub/superscript)
|
|
||||||
|$\scriptscriptstyle x$ `\scriptscriptstyle x` (The size of subsequent sub/superscripts)
|
|
||||||
|$\lim\limits_x$ `\lim\limits_x`
|
|
||||||
|$\lim\nolimits_x$ `\lim\nolimits_x`
|
|
||||||
|$\verb!x^2!$ `\verb!x^2!`
|
|
||||||
|
|
||||||
`\text{…}` will accept nested `$…$` fragments and render them in math mode.
|
|
||||||
|
|
||||||
## Symbols and Punctuation
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|`% comment`|$\dots$ `\dots`|$\KaTeX$ `\KaTeX`
|
|
||||||
|$\%$ `\%`|$\cdots$ `\cdots`|$\LaTeX$ `\LaTeX`
|
|
||||||
|$\#$ `\#`|$\ddots$ `\ddots`|$\TeX$ `\TeX`
|
|
||||||
|$\&$ `\&`|$\ldots$ `\ldots`|$\nabla$ `\nabla`
|
|
||||||
|$\_$ `\_`|$\vdots$ `\vdots`|$\infty$ `\infty`
|
|
||||||
|$\text{\textunderscore}$ `\text{\textunderscore}`|$\dotsb$ `\dotsb`|$\infin$ `\infin`
|
|
||||||
|$\text{--}$ `\text{--}`|$\dotsc$ `\dotsc`|$\checkmark$ `\checkmark`
|
|
||||||
|$\text{\textendash}$ `\text{\textendash}`|$\dotsi$ `\dotsi`|$\dag$ `\dag`
|
|
||||||
|$\text{---}$ `\text{---}`|$\dotsm$ `\dotsm`|$\dagger$ `\dagger`
|
|
||||||
|$\text{\textemdash}$ `\text{\textemdash}`|$\dotso$ `\dotso`|$\text{\textdagger}$ `\text{\textdagger}`
|
|
||||||
|$\text{\textasciitilde}$ `\text{\textasciitilde}`|$\sdot$ `\sdot`|$\ddag$ `\ddag`
|
|
||||||
|$\text{\textasciicircum}$ `\text{\textasciicircum}`|$\mathellipsis$ `\mathellipsis`|$\ddagger$ `\ddagger`
|
|
||||||
|$`$ <code>`</code>|$\text{\textellipsis}$ `\text{\textellipsis}`|$\text{\textdaggerdbl}$ `\text{\textdaggerdbl}`
|
|
||||||
|$\text{\textquoteleft}$ `text{\textquoteleft}`|$\Box$ `\Box`|$\Dagger$ `\Dagger`
|
|
||||||
|$\lq$ `\lq`|$\square$ `\square`|$\angle$ `\angle`
|
|
||||||
|$\text{\textquoteright}$ `\text{\textquoteright}`|$\blacksquare$ `\blacksquare`|$\measuredangle$ `\measuredangle`
|
|
||||||
|$\rq$ `\rq`|$\triangle$ `\triangle`|$\sphericalangle$ `\sphericalangle`
|
|
||||||
|$\text{\textquotedblleft}$ `\text{\textquotedblleft}`|$\triangledown$ `\triangledown`|$\top$ `\top`
|
|
||||||
|$"$ `"`|$\triangleleft$ `\triangleleft`|$\bot$ `\bot`
|
|
||||||
|$\text{\textquotedblright}$ `\text{\textquotedblright}`|$\triangleright$ `\triangleright`|$\$$ `\$`
|
|
||||||
|$\colon$ `\colon`|$\bigtriangledown$ `\bigtriangledown`|$\text{\textdollar}$ `\text{\textdollar}`
|
|
||||||
|$\backprime$ `\backprime`|$\bigtriangleup$ `\bigtriangleup`|$\pounds$ `\pounds`
|
|
||||||
|$\prime$ `\prime`|$\blacktriangle$ `\blacktriangle`|$\mathsterling$ `\mathsterling`
|
|
||||||
|$\text{\textless}$ `\text{\textless}`|$\blacktriangledown$ `\blacktriangledown`|$\text{\textsterling}$ `\text{\textsterling}`
|
|
||||||
|$\text{\textgreater}$ `\text{\textgreater}`|$\blacktriangleleft$ `\blacktriangleleft`|$\yen$ `\yen`
|
|
||||||
|$\text{\textbar}$ `\text{\textbar}`|$\blacktriangleright$ `\blacktriangleright`|$\surd$ `\surd`
|
|
||||||
|$\text{\textbardbl}$ `\text{\textbardbl}`|$\diamond$ `\diamond`|$\degree$ `\degree`
|
|
||||||
|$\text{\textbraceleft}$ `\text{\textbraceleft}`|$\Diamond$ `\Diamond`|$\text{\textdegree}$ `\text{\textdegree}`
|
|
||||||
|$\text{\textbraceright}$ `\text{\textbraceright}`|$\lozenge$ `\lozenge`|$\mho$ `\mho`
|
|
||||||
|$\text{\textbackslash}$ `\text{\textbackslash}`|$\blacklozenge$ `\blacklozenge`|$\diagdown$ `\diagdown`
|
|
||||||
|$\text{\P}$ `\text{\P}`|$\star$ `\star`|$\diagup$ `\diagup`
|
|
||||||
|$\text{\S}$ `\text{\S}`|$\bigstar$ `\bigstar`|$\flat$ `\flat`
|
|
||||||
|$\text{\sect}$ `\text{\sect}`|$\clubsuit$ `\clubsuit`|$\natural$ `\natural`
|
|
||||||
|$\copyright$ `\copyright`|$\clubs$ `\clubs`|$\sharp$ `\sharp`
|
|
||||||
|$\circledR$ `\circledR`|$\diamondsuit$ `\diamondsuit`|$\heartsuit$ `\heartsuit`
|
|
||||||
|$\text{\textregistered}$ `\text{\textregistered}`|$\diamonds$ `\diamonds`|$\hearts$ `\hearts`
|
|
||||||
|$\circledS$ `\circledS`|$\spadesuit$ `\spadesuit`|$\spades$ `\spades`
|
|
||||||
|$\text{\textcircled a}$ `\text{\textcircled a}`|$\maltese$ `\maltese`|$\minuso$ `\minuso`|
|
|
||||||
|
|
||||||
Direct Input: $£ ¥ ∇ ∞ · ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ … ⋮ ⋯ ⋱ !$ ‼ ⦵
|
|
||||||
|
|
||||||
## Units
|
|
||||||
|
|
||||||
In KaTeX, units are proportioned as they are in TeX.<br>
|
|
||||||
KaTeX units are different than CSS units.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="unit-tbl">
|
|
||||||
|
|
||||||
| KaTeX Unit | Value | KaTeX Unit | Value |
|
|
||||||
|:---|:---------------------|:---|:----------------|
|
|
||||||
| em | CSS em | bp | 1/72 inch × F × G|
|
|
||||||
| ex | CSS ex | pc | 12 KaTeX pt|
|
|
||||||
| mu | 1/18 CSS em | dd | 1238/1157 KaTeX pt |
|
|
||||||
| pt | 1/72.27 inch × F × G | cc | 14856/1157 KaTeX pt |
|
|
||||||
| mm | 1 mm × F × G | nd | 685/642 KaTeX pt |
|
|
||||||
| cm | 1 cm × F × G | nc | 1370/107 KaTeX pt|
|
|
||||||
| in | 1 inch × F × G | sp | 1/65536 KaTeX pt |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
where:
|
|
||||||
|
|
||||||
<div style="margin-left: 1.5em;">
|
|
||||||
|
|
||||||
F = (font size of surrounding HTML text)/(10 pt)
|
|
||||||
|
|
||||||
G = 1.21 by default, because KaTeX font-size is normally 1.21 × the surrounding font size. This value [can be overridden](font.md#font-size-and-lengths) by the CSS of an HTML page.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
The effect of style and size:
|
|
||||||
|
|
||||||
<div class="katex-cards" id="unit-blocks">
|
|
||||||
|
|
||||||
| Unit | textstyle | scriptscript | huge |
|
|
||||||
|:------:|:-----------------:|:------------:|:------:|
|
|
||||||
|em or ex|$\rule{1em}{1em}$ |$\scriptscriptstyle\rule{1em}{1em}$ |$\huge\rule{1em}{1em}$
|
|
||||||
| mu |$\rule{18mu}{18mu}$|$\scriptscriptstyle\rule{18mu}{18mu}$|$\huge\rule{18mu}{18mu}$
|
|
||||||
| others |$\rule{10pt}{10pt}$|$\scriptscriptstyle\rule{10pt}{10pt}$|$\huge\rule{10pt}{10pt}$
|
|
||||||
|
|
||||||
</div>
|
|
@@ -1,66 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.13.0-api
|
|
||||||
title: API
|
|
||||||
original_id: api
|
|
||||||
---
|
|
||||||
## In-browser rendering
|
|
||||||
Call `katex.render` with a TeX expression and a DOM element to render into:
|
|
||||||
|
|
||||||
```js
|
|
||||||
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
|
|
||||||
throwOnError: false
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
To avoid escaping the backslash (double backslash), you can use
|
|
||||||
[`String.raw`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
|
|
||||||
(but beware that `${`, `\u` and `\x` may still need escaping):
|
|
||||||
```js
|
|
||||||
katex.render(String.raw`c = \pm\sqrt{a^2 + b^2}`, element, {
|
|
||||||
throwOnError: false
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Server-side rendering or rendering to a string
|
|
||||||
To generate HTML on the server or to generate an HTML string of the rendered math, you can use `katex.renderToString`:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
|
|
||||||
throwOnError: false
|
|
||||||
});
|
|
||||||
// '<span class="katex">...</span>'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Handling errors
|
|
||||||
|
|
||||||
The examples above use the `throwOnError: false` option, which renders invalid
|
|
||||||
inputs as the TeX source code in red (by default), with the error message as
|
|
||||||
hover text. Without this option, invalid LaTeX will cause a
|
|
||||||
`katex.ParseError` exception to be thrown. See [handling errors](error.md).
|
|
||||||
|
|
||||||
## Configuring KaTeX
|
|
||||||
|
|
||||||
The last argument to `katex.render` and `katex.renderToString` can contain
|
|
||||||
[a variety of rendering options](options.md).
|
|
||||||
|
|
||||||
## Persistent Macros
|
|
||||||
|
|
||||||
KaTeX’s [macro documentation](supported.html#gdef) tells the author that `\gdef` will create a macro that persists between KaTeX elements. In order to enable that persistence, you must create one shared `macros` object that you pass into every call to `katex.render` or `katex.renderToString`. (Do not create a fresh `macros` object for each call.)
|
|
||||||
|
|
||||||
For example, suppose that you have an array `mathElements` of DOM elements that contain math. Then you could write this code:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const macros = {};
|
|
||||||
for (let element of mathElements) {
|
|
||||||
katex.render(element.textContent, element, {
|
|
||||||
throwOnError: false,
|
|
||||||
macros
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Notice that you create the `macros` object outside the loop. If an author uses `\gdef`, KaTeX will insert that macro definition into the `macros` object and since `macros` continues to exist between calls to `katex.render`, `\gdef` macros will persist between `mathElements`.
|
|
||||||
|
|
||||||
### Security of Persistent Macros
|
|
||||||
|
|
||||||
Persistent macros can change the behavior of KaTeX (e.g. redefining standard commands), so for security, such a setup should be used only for multiple elements of common trust. For example, you might enable persistent macros within a message posted by a single user (by creating a `macros` object for that message), but you probably should not enable persistent macros across multiple messages posted by multiple users.
|
|
@@ -1,129 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.13.0-autorender
|
|
||||||
title: Auto-render Extension
|
|
||||||
original_id: autorender
|
|
||||||
---
|
|
||||||
This is an extension to automatically render all of the math inside of text. It
|
|
||||||
searches all of the text nodes within a given element for the given delimiters,
|
|
||||||
ignoring certain tags like `<pre>`, and renders the math in place.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
This extension isn't part of KaTeX proper, so the script needs to be included
|
|
||||||
(via a `<script>` tag) in the page along with KaTeX itself. For example,
|
|
||||||
using a CDN:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.css" integrity="sha384-t5CR+zwDAROtph0PXGte6ia8heboACF9R5l/DiY+WZ3P2lxNgvJkQk5n7GPvLMYw" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.js" integrity="sha384-FaFLTlohFghEIZkw6VGwmf9ISTubWAVYW8tG8+w2LAIftJEULZABrF9PPFv+tVkH" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/contrib/auto-render.min.js" integrity="sha384-bHBqxz8fokvgoJ/sc17HODNxa42TlaEhB+w8ZJXTc2nZf1VgEaFZeZvT4Mznfz0v" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above, the [`defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
indicates that the script doesn't need to execute until the page has loaded,
|
|
||||||
speeding up page rendering; and the `onload` attribute calls
|
|
||||||
`renderMathInElement` once the auto-render script loads.
|
|
||||||
|
|
||||||
Alternatively, you can call the `renderMathInElement` when (or after) the
|
|
||||||
[`DOMContentLoaded` event](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded)
|
|
||||||
fires on the document or in another deferred script.
|
|
||||||
This approach is useful for specifying or computing options, or if you don't
|
|
||||||
want to use a `defer` or `onload` attribute.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.css" integrity="sha384-t5CR+zwDAROtph0PXGte6ia8heboACF9R5l/DiY+WZ3P2lxNgvJkQk5n7GPvLMYw" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.js" integrity="sha384-FaFLTlohFghEIZkw6VGwmf9ISTubWAVYW8tG8+w2LAIftJEULZABrF9PPFv+tVkH" crossorigin="anonymous"></script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/contrib/auto-render.min.js" integrity="sha384-bHBqxz8fokvgoJ/sc17HODNxa42TlaEhB+w8ZJXTc2nZf1VgEaFZeZvT4Mznfz0v" crossorigin="anonymous"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
renderMathInElement(document.body, {
|
|
||||||
// ...options...
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
ECMAScript module is also available:
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.css" integrity="sha384-t5CR+zwDAROtph0PXGte6ia8heboACF9R5l/DiY+WZ3P2lxNgvJkQk5n7GPvLMYw" crossorigin="anonymous">
|
|
||||||
<script type="module">
|
|
||||||
import renderMathInElement from "https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/contrib/auto-render.mjs";
|
|
||||||
renderMathInElement(document.body);
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules. -->
|
|
||||||
|
|
||||||
## API
|
|
||||||
This extension exposes a single function, `window.renderMathInElement`, with
|
|
||||||
the following API:
|
|
||||||
|
|
||||||
```js
|
|
||||||
function renderMathInElement(elem, options)
|
|
||||||
```
|
|
||||||
|
|
||||||
`elem` is an HTML DOM element. The function will recursively search for text
|
|
||||||
nodes inside this element and render the math in them.
|
|
||||||
|
|
||||||
`options` is an optional object argument that can have the same keys as [the
|
|
||||||
object passed to `katex.render`](https://github.com/KaTeX/KaTeX/#rendering-options),
|
|
||||||
in addition to two auto-render-specific keys:
|
|
||||||
|
|
||||||
- `delimiters`: This is a list of delimiters to look for math, processed in
|
|
||||||
the same order as the list. Each delimiter has three properties:
|
|
||||||
|
|
||||||
- `left`: A string which starts the math expression (i.e. the left delimiter).
|
|
||||||
- `right`: A string which ends the math expression (i.e. the right delimiter).
|
|
||||||
- `display`: A boolean of whether the math in the expression should be
|
|
||||||
rendered in display mode or not.
|
|
||||||
|
|
||||||
The default value is:
|
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{left: "$$", right: "$$", display: true},
|
|
||||||
{left: "\\(", right: "\\)", display: false},
|
|
||||||
{left: "\\begin{equation}", right: "\\end{equation}", display: true},
|
|
||||||
{left: "\\begin{align}", right: "\\end{align}", display: true},
|
|
||||||
{left: "\\begin{alignat}", right: "\\end{alignat}", display: true},
|
|
||||||
{left: "\\begin{gather}", right: "\\end{gather}", display: true},
|
|
||||||
{left: "\\begin{CD}", right: "\\end{CD}", display: true},
|
|
||||||
{left: "\\[", right: "\\]", display: true}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
If you want to add support for inline math via `$...$`, be sure to list it
|
|
||||||
*after* `$$`, as in the following. (Because rules are processed in order,
|
|
||||||
putting a `$` rule first would catch `$$` as an empty math expression.)
|
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{left: "$$", right: "$$", display: true},
|
|
||||||
{left: "$", right: "$", display: false},
|
|
||||||
{left: "\\(", right: "\\)", display: false},
|
|
||||||
{left: "\\[", right: "\\]", display: true}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
- `ignoredTags`: This is a list of DOM node types to ignore when recursing
|
|
||||||
through. The default value is
|
|
||||||
`["script", "noscript", "style", "textarea", "pre", "code", "option"]`.
|
|
||||||
|
|
||||||
- `ignoredClasses`: This is a list of DOM node class names to ignore when
|
|
||||||
recursing through. By default, this value is not set.
|
|
||||||
|
|
||||||
- `errorCallback`: A callback method returning a message and an error stack
|
|
||||||
in case of an critical error during rendering. The default uses `console.error`.
|
|
||||||
|
|
||||||
- `preProcess`: A callback function, `(math: string) => string`, used to process
|
|
||||||
math expressions before rendering.
|
|
||||||
|
|
||||||
The `displayMode` property of the options object is ignored, and is
|
|
||||||
instead taken from the `display` key of the corresponding entry in the
|
|
||||||
`delimiters` key.
|
|
||||||
|
|
||||||
The same `options.macros` object (which defaults to an empty object `{}`)
|
|
||||||
is passed into several calls to `katex.render`, so that consecutive equations
|
|
||||||
can build up shared macros by `\gdef`.
|
|
@@ -1,119 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.13.0-browser
|
|
||||||
title: Browser
|
|
||||||
original_id: browser
|
|
||||||
---
|
|
||||||
> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 11.
|
|
||||||
|
|
||||||
## Starter template
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.css" integrity="sha384-t5CR+zwDAROtph0PXGte6ia8heboACF9R5l/DiY+WZ3P2lxNgvJkQk5n7GPvLMYw" crossorigin="anonymous">
|
|
||||||
|
|
||||||
<!-- The loading of KaTeX is deferred to speed up page rendering -->
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.js" integrity="sha384-FaFLTlohFghEIZkw6VGwmf9ISTubWAVYW8tG8+w2LAIftJEULZABrF9PPFv+tVkH" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
<!-- To automatically render math in text elements, include the auto-render extension: -->
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/contrib/auto-render.min.js" integrity="sha384-bHBqxz8fokvgoJ/sc17HODNxa42TlaEhB+w8ZJXTc2nZf1VgEaFZeZvT4Mznfz0v" crossorigin="anonymous"
|
|
||||||
onload="renderMathInElement(document.body);"></script>
|
|
||||||
</head>
|
|
||||||
...
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Loading as Global
|
|
||||||
If you include the `katex.js` directly, the `katex` object will be available as
|
|
||||||
a global variable.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.css" integrity="sha384-b1jwlKx2fZPr3OngW6CqA3niWl98suSWQIspVVyrImbCVlqAN4FS0K3kMQxWrFTy" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.js" integrity="sha384-CwDRLVcPQXU/xOQ8sXclWSwCEwSggm2TdZpCj423bHkwhH1Y5DC3IT41b3ShzFsK" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX also provides minified versions:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.css" integrity="sha384-t5CR+zwDAROtph0PXGte6ia8heboACF9R5l/DiY+WZ3P2lxNgvJkQk5n7GPvLMYw" crossorigin="anonymous">
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.js" integrity="sha384-FaFLTlohFghEIZkw6VGwmf9ISTubWAVYW8tG8+w2LAIftJEULZABrF9PPFv+tVkH" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
The examples above load the script [deferred using the `defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to speed up page rendering. The `katex` object will be available after
|
|
||||||
[`DOMContentLoaded` event is fired on the `document`](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded).
|
|
||||||
If you do not use `defer`, `katex` object will be available after the corresponding
|
|
||||||
`script` tag.
|
|
||||||
|
|
||||||
If KaTeX is not used immediately or not critical, it is possible to load KaTeX
|
|
||||||
asynchronously. Add [`async` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to `script` and use [`rel="preload"` and `onload` attribute](https://github.com/filamentgroup/loadCSS)
|
|
||||||
on `link`.
|
|
||||||
|
|
||||||
You can prefetch KaTeX fonts to prevent FOUT or FOIT. Use [Font Loading API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API)
|
|
||||||
or [Web Font Loader](https://github.com/typekit/webfontloader):
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
window.WebFontConfig = {
|
|
||||||
custom: {
|
|
||||||
families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7',
|
|
||||||
'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script',
|
|
||||||
'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3',
|
|
||||||
'KaTeX_Size4', 'KaTeX_Typewriter'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use [`rel="preload"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content).
|
|
||||||
Add `<link rel="preload" href=(path to WOFF2 font) as="font" type="font/woff2" crossorigin="anonymous">`
|
|
||||||
to `head`. Note that [only few browsers support it](https://caniuse.com/#feat=link-rel-preload)
|
|
||||||
and they all support WOFF2 so preloading WOFF2 fonts is enough.
|
|
||||||
|
|
||||||
See [Google Web Fundamentals - Web Font Optimization](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/webfont-optimization)
|
|
||||||
for more detail.
|
|
||||||
|
|
||||||
## Module Loaders
|
|
||||||
### AMD
|
|
||||||
```html
|
|
||||||
<script type="text/javascript">
|
|
||||||
require([
|
|
||||||
"https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.js",
|
|
||||||
], katex => {
|
|
||||||
...
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.css" integrity="sha384-b1jwlKx2fZPr3OngW6CqA3niWl98suSWQIspVVyrImbCVlqAN4FS0K3kMQxWrFTy" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
### ECMAScript module
|
|
||||||
```html
|
|
||||||
<script type="module" type="text/javascript">
|
|
||||||
import katex from 'https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.mjs';
|
|
||||||
...
|
|
||||||
</script>
|
|
||||||
<script nomodule defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.js" integrity="sha384-CwDRLVcPQXU/xOQ8sXclWSwCEwSggm2TdZpCj423bHkwhH1Y5DC3IT41b3ShzFsK" crossorigin="anonymous"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.css" integrity="sha384-b1jwlKx2fZPr3OngW6CqA3niWl98suSWQIspVVyrImbCVlqAN4FS0K3kMQxWrFTy" crossorigin="anonymous">
|
|
||||||
```
|
|
||||||
|
|
||||||
> Use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes)
|
|
||||||
to provide a fallback for older browsers that do not support ES modules.
|
|
||||||
|
|
||||||
## Download & Host Things Yourself
|
|
||||||
Download a [KaTeX release](https://github.com/KaTeX/KaTeX/releases),
|
|
||||||
copy `katex.js`, `katex.css`
|
|
||||||
(or `katex.min.js` and `katex.min.css` to use minified versions),
|
|
||||||
and the `fonts` directory, and include or import it like above.
|
|
||||||
|
|
||||||
You can also build from source. See [Building from Source](node.md#building-from-source)
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
## Bundler
|
|
||||||
[Use Node.js package managers to install KaTeX and import it](node.md) in your
|
|
||||||
project. Then bundle using bundlers like [webpack](https://webpack.js.org/) or
|
|
||||||
[rollup.js](https://rollupjs.org/). Note that you have to bundle the stylesheet
|
|
||||||
(`katex.css`) or include it manually.
|
|
@@ -1,67 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.13.0-cli
|
|
||||||
title: CLI
|
|
||||||
original_id: cli
|
|
||||||
---
|
|
||||||
|
|
||||||
KaTeX installed [using Node.js package managers](node.md) comes with a
|
|
||||||
built-in command-line interface (CLI) which can be used to render TeX to HTML.
|
|
||||||
By default, CLI will take the input from standard input.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npx katex
|
|
||||||
```
|
|
||||||
|
|
||||||
> Above uses the `npx` command to run the locally installed executable
|
|
||||||
after `npm install katex`. You can also execute with the relative path:
|
|
||||||
`./node_modules/.bin/katex`
|
|
||||||
|
|
||||||
> To use the CLI from local Git clone, you need to build the project first.
|
|
||||||
See [Building from Source](node.md#building-from-source) for more details.
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### `-V, --version`
|
|
||||||
output the version number
|
|
||||||
|
|
||||||
### `-d, --display-mode`
|
|
||||||
Render math in display mode, which puts the math in display style (so \int and \sum are large, for example), and centers the math on the page on its own line.
|
|
||||||
|
|
||||||
### `--leqno`
|
|
||||||
Render display math in leqno style (left-justified tags).
|
|
||||||
|
|
||||||
### `--fleqn`
|
|
||||||
Render display math flush left.
|
|
||||||
|
|
||||||
### `-t, --no-throw-on-error`
|
|
||||||
Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.
|
|
||||||
|
|
||||||
### `-c, --error-color <color>`
|
|
||||||
A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.
|
|
||||||
|
|
||||||
### `-b, --color-is-text-color`
|
|
||||||
Makes \color behave like LaTeX's 2-argument \textcolor, instead of LaTeX's one-argument \color mode change.
|
|
||||||
|
|
||||||
### `-S, --strict`
|
|
||||||
Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX
|
|
||||||
|
|
||||||
### `-s, --max-size <n>`
|
|
||||||
If non-zero, all user-specified sizes, e.g. in \rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large
|
|
||||||
|
|
||||||
### `-e, --max-expand <n>`
|
|
||||||
Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.
|
|
||||||
|
|
||||||
### `-m, --macro <def>`
|
|
||||||
Define custom macro of the form '\foo:expansion' (use multiple -m arguments for multiple macros).
|
|
||||||
|
|
||||||
### `-f, --macro-file <path>`
|
|
||||||
Read macro definitions, one per line, from the given file.
|
|
||||||
|
|
||||||
### `-i, --input <path>`
|
|
||||||
Read LaTeX input from the given file.
|
|
||||||
|
|
||||||
### `-o, --output <path>`
|
|
||||||
Write html output to the given file.
|
|
||||||
|
|
||||||
### `-h, --help`
|
|
||||||
Output usage information
|
|
@@ -1,47 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.13.0-font
|
|
||||||
title: Font
|
|
||||||
original_id: font
|
|
||||||
---
|
|
||||||
By changing the variables in the `fonts.less` file at the [katex-fonts submodule](https://github.com/KaTeX/katex-fonts/),
|
|
||||||
several properties of the way fonts are used can be changed.
|
|
||||||
|
|
||||||
## Font size and lengths
|
|
||||||
By default, KaTeX math is rendered in a 1.21× larger font than the surrounding
|
|
||||||
context, which makes super- and subscripts easier to read. You can control
|
|
||||||
this using CSS, for example, to set to 1.1×:
|
|
||||||
|
|
||||||
```css
|
|
||||||
.katex { font-size: 1.1em; }
|
|
||||||
```
|
|
||||||
|
|
||||||
KaTeX supports all TeX units, including absolute units like `cm` and `in`.
|
|
||||||
Absolute units are currently scaled relative to the default TeX font size of
|
|
||||||
10pt, so that `\kern1cm` produces the same results as `\kern2.845275em`.
|
|
||||||
As a result, relative and absolute units are both uniformly scaled relative
|
|
||||||
to LaTeX with a 10pt font; for example, the rectangle `\rule{1cm}{1em}` has
|
|
||||||
the same aspect ratio in KaTeX as in LaTeX. However, because most browsers
|
|
||||||
default to a larger font size, this typically means that a 1cm kern in KaTeX
|
|
||||||
will appear larger than 1cm in browser units.
|
|
||||||
|
|
||||||
## Kinds of fonts used
|
|
||||||
|
|
||||||
KaTeX provides fonts in three different formats: `ttf`, `woff`, and `woff2`.
|
|
||||||
|
|
||||||
- `ttf`s are included to support very old browsers and local installation. [Browser support](https://caniuse.com/#feat=ttf)
|
|
||||||
- `woff` is the format that is most widely supported (all modern browsers support it), so it probably provides the most benefit to being included. [Browser support](https://caniuse.com/#feat=woff)
|
|
||||||
- `woff2`s are included for modern browsers, because they are much smaller and faster to load. [Browser support](https://caniuse.com/#feat=woff2)
|
|
||||||
|
|
||||||
KaTeX will automatically include only necessary fonts for target environments
|
|
||||||
specified by [Browserslist config](https://github.com/browserslist/browserslist#queries).
|
|
||||||
|
|
||||||
To force a font type to be included or excluded, set `USE_(FONT NAME)` environment
|
|
||||||
variable to `"true"` or `"false"`, respectively.
|
|
||||||
|
|
||||||
## Location of font files
|
|
||||||
|
|
||||||
The default build of KaTeX expects the KaTeX fonts to be located in a directory called `fonts` which is a sibling of the `katex.min.css` stylesheet. This can be changed as follows:
|
|
||||||
|
|
||||||
1. At the top of the [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less) file, set `@font-folder` to the location of your fonts. You can use relative or absolute paths, so setting it to `"/fonts"` would cause it to search for the fonts in a root `fonts` folder, while `"../fonts"` would search in a `fonts` directory one level above the `katex.min.css` file.
|
|
||||||
2. Rebuild KaTeX by running `yarn build` from the top-level directory.
|
|
||||||
3. Use the newly generated `dist/katex.min.css` file, and place the fonts where you indicated.
|
|
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.13.0-migration
|
|
||||||
title: Migration Guide
|
|
||||||
original_id: migration
|
|
||||||
---
|
|
||||||
|
|
||||||
As of KaTeX 1.0, we've changed how MacroExpander and Parser work in order to close
|
|
||||||
some gaps between KaTeX and LaTeX and therefore there may be breaking changes.
|
|
||||||
|
|
||||||
## Macro arguments
|
|
||||||
Tokens will not be expanded while parsing a macro argument. For example, `\frac\foo\foo`,
|
|
||||||
where the `\foo` is defined as `12`, will be parsed as `\frac{12}{12}`, not
|
|
||||||
`\frac{1}{2}12`. To expand the argument before parsing, `\expandafter` can
|
|
||||||
be used like `\expandafter\frac\foo\foo`.
|
|
||||||
|
|
||||||
## `\def`
|
|
||||||
`\def` no longer accepts a control sequence enclosed in braces. For example,
|
|
||||||
`\def{\foo}{}` no longer works and should be changed to `\def\foo{}`.
|
|
||||||
|
|
||||||
It also no longer accepts replacement text not enclosed in braces. For example,
|
|
||||||
`\def\foo1` no longer works and should be changed to `\def\foo{1}`.
|
|
||||||
|
|
||||||
## `\newline` and `\cr`
|
|
||||||
`\newline` and `\cr` no longer takes an optional size argument. To specify vertical
|
|
||||||
spacing, `\\` should be used.
|
|
||||||
|
|
||||||
## `\cfrac`, `\color`, `\textcolor`, `\colorbox`, `\fcolorbox`
|
|
||||||
They are no longer allowed as an argument to primitive commands, such as `\sqrt`
|
|
||||||
(without the optional argument) and super/subscript. For example,
|
|
||||||
`\sqrt\textcolor{red}{x}` no longer works and should be changed to
|
|
||||||
`\sqrt{\textcolor{red}{x}}`.
|
|
@@ -1,72 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.13.0-options
|
|
||||||
title: Options
|
|
||||||
original_id: options
|
|
||||||
---
|
|
||||||
You can provide an object of options as the last argument to [`katex.render` and `katex.renderToString`](api.md). Available options are:
|
|
||||||
|
|
||||||
- `displayMode`: `boolean`. If `true` the math will be rendered in display mode, which will put the math in display style (so `\int` and `\sum` are large, for example), and will center the math on the page on its own line. If `false` the math will be rendered in inline mode. (default: `false`)
|
|
||||||
- `output`: `string`. Determines the markup language of the output. The valid choices are:
|
|
||||||
- `html`: Outputs KaTeX in HTML only.
|
|
||||||
- `mathml`: Outputs KaTeX in MathML only.
|
|
||||||
- `htmlAndMathml`: Outputs HTML for visual rendering and includes MathML for accessibility. This is the default.
|
|
||||||
- `leqno`: `boolean`. If `true`, display math has `\tag`s rendered on the left instead of the right, like `\usepackage[leqno]{amsmath}` in LaTeX.
|
|
||||||
- `fleqn`: `boolean`. If `true`, display math renders flush left with a `2em` left margin, like `\documentclass[fleqn]` in LaTeX with the `amsmath` package.
|
|
||||||
- `throwOnError`: `boolean`. If `true` (the default), KaTeX will throw a `ParseError` when it encounters an unsupported command or invalid LaTeX. If `false`, KaTeX will render unsupported commands as text, and render invalid LaTeX as its source code with hover text giving the error, in the color given by `errorColor`.
|
|
||||||
- `errorColor`: `string`. A color string given in the format `"#XXX"` or `"#XXXXXX"`. This option determines the color that unsupported commands and invalid LaTeX are rendered in when `throwOnError` is set to `false`. (default: `#cc0000`)
|
|
||||||
- `macros`: `object`. A collection of custom macros. Each macro is a property with a name like `\name` (written `"\\name"` in JavaScript) which maps to a string that describes the expansion of the macro, or a function that accepts an instance of `MacroExpander` as first argument and returns the expansion as a string. `MacroExpander` is an internal API and subject to non-backwards compatible changes. See [`src/macros.js`](https://github.com/KaTeX/KaTeX/blob/master/src/macros.js) for its usage. Single-character keys can also be included in which case the character will be redefined as the given macro (similar to TeX active characters). *This object will be modified* if the LaTeX code defines its own macros via `\gdef`, which enables consecutive calls to KaTeX to share state.
|
|
||||||
- `minRuleThickness`: `number`. Specifies a minimum thickness, in ems, for fraction lines, `\sqrt` top lines, `{array}` vertical lines, `\hline`, `\hdashline`, `\underline`, `\overline`, and the borders of `\fbox`, `\boxed`, and `\fcolorbox`. The usual value for these items is `0.04`, so for `minRuleThickness` to be effective it should probably take a value slightly above `0.04`, say `0.05` or `0.06`. Negative values will be ignored.
|
|
||||||
- `colorIsTextColor`: `boolean`. In early versions of both KaTeX (<0.8.0) and MathJax, the `\color` function expected the content to be a function argument, as in `\color{blue}{hello}`. In current KaTeX, `\color` is a switch, as in `\color{blue} hello`. This matches LaTeX behavior. If you want the old `\color` behavior, set option `colorIsTextColor` to true.
|
|
||||||
- `maxSize`: `number`. All user-specified sizes, e.g. in `\rule{500em}{500em}`, will be capped to `maxSize` ems. If set to `Infinity` (the default), users can make elements and spaces arbitrarily large.
|
|
||||||
- `maxExpand`: `number`. Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to `Infinity`, the macro expander will try to fully expand as in LaTeX. (default: 1000)
|
|
||||||
- `strict`: `boolean` or `string` or `function` (default: `"warn"`). If `false` or `"ignore`", allow features that make writing LaTeX convenient but are not actually supported by (Xe)LaTeX (similar to MathJax). If `true` or `"error"` (LaTeX faithfulness mode), throw an error for any such transgressions. If `"warn"` (the default), warn about such behavior via `console.warn`. Provide a custom function `handler(errorCode, errorMsg, token)` to customize behavior depending on the type of transgression (summarized by the string code `errorCode` and detailed in `errorMsg`); this function can also return `"ignore"`, `"error"`, or `"warn"` to use a built-in behavior. A list of such features and their `errorCode`s:
|
|
||||||
|
|
||||||
- `"unknownSymbol"`: Use of unknown Unicode symbol, which will likely also
|
|
||||||
lead to warnings about missing character metrics, and layouts may be
|
|
||||||
incorrect (especially in terms of vertical heights).
|
|
||||||
- `"unicodeTextInMathMode"`: Use of Unicode text characters in math mode.
|
|
||||||
- `"mathVsTextUnits"`: Mismatch of math vs. text commands and units/mode.
|
|
||||||
- `"commentAtEnd"`: Use of `%` comment without a terminating newline.
|
|
||||||
LaTeX would thereby comment out the end of math mode (e.g. `$`),
|
|
||||||
causing an error.
|
|
||||||
- `"htmlExtension"`: Use of HTML extension (`\html`-prefixed) commands,
|
|
||||||
which are provieded for HTML manipulation.
|
|
||||||
|
|
||||||
A second category of `errorCode`s never throw errors, but their strictness
|
|
||||||
affects the behavior of KaTeX:
|
|
||||||
|
|
||||||
- `"newLineInDisplayMode"`: Use of `\\` or `\newline` in display mode
|
|
||||||
(outside an array/tabular environment). In strict mode, no line break
|
|
||||||
results, as in LaTeX.
|
|
||||||
|
|
||||||
- `trust`: `boolean` or `function` (default: `false`). If `false` (do not trust input), prevent any commands like `\includegraphics` that could enable adverse behavior, rendering them instead in `errorColor`. If `true` (trust input), allow all such commands. Provide a custom function `handler(context)` to customize behavior depending on the context (command, arguments e.g. a URL, etc.). A list of possible contexts:
|
|
||||||
|
|
||||||
- `{command: "\\url", url, protocol}`
|
|
||||||
- `{command: "\\href", url, protocol}`
|
|
||||||
- `{command: "\\includegraphics", url, protocol}`
|
|
||||||
- `{command: "\\htmlClass", class}`
|
|
||||||
- `{command: "\\htmlId", id}`
|
|
||||||
- `{command: "\\htmlStyle", style}`
|
|
||||||
- `{command: "\\htmlData", attributes}`
|
|
||||||
|
|
||||||
Here are some sample trust settings:
|
|
||||||
|
|
||||||
- Forbid specific command: `trust: (context) => context.command !== '\\includegraphics'`
|
|
||||||
- Allow specific command: `trust: (context) => context.command === '\\url'`
|
|
||||||
- Allow multiple specific commands: `trust: (context) => ['\\url', '\\href'].includes(context.command)`
|
|
||||||
- Allow all commands with a specific protocol: `trust: (context) => context.protocol === 'http'`
|
|
||||||
- Allow all commands with specific protocols: `trust: (context) => ['http', 'https', '_relative'].includes(context.protocol)`
|
|
||||||
- Allow all commands but forbid specific protocol: `trust: (context) => context.protocol !== 'file'`
|
|
||||||
- Allow certain commands with specific protocols: `trust: (context) => ['\\url', '\\href'].includes(context.command) && ['http', 'https', '_relative'].includes(context.protocol)`
|
|
||||||
- `globalGroup`: `boolean` (default: `false`). Place KaTeX code in the global group. As a consequence, `\def` and `\newcommand` persist in `macros` across render calls. In LaTeX, constructs such as `\begin{equation}` and `$$` create a local group and prevent definitions from becoming visible outside of those blocks.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
katex.render("c = \\pm\\sqrt{a^2 + b^2}\\in\\RR", element, {
|
|
||||||
displayMode: true,
|
|
||||||
macros: {
|
|
||||||
"\\RR": "\\mathbb{R}"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,715 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-0.13.0-supported
|
|
||||||
title: Supported Functions
|
|
||||||
original_id: supported
|
|
||||||
---
|
|
||||||
This is a list of TeX functions supported by KaTeX. It is sorted into logical groups.
|
|
||||||
|
|
||||||
There is a similar [Support Table](support_table.md), sorted alphabetically, that lists both supported and un-supported functions.
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/static/katex.min.css"/>
|
|
||||||
<style>
|
|
||||||
p {overflow-wrap: break-word;}
|
|
||||||
table tr,
|
|
||||||
table td {
|
|
||||||
vertical-align: middle;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Accents
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------------------------|:----------------------------------------------------|:------
|
|
||||||
|$a'$ `a'` |$\tilde{a}$ `\tilde{a}`|$\mathring{g}$ `\mathring{g}`
|
|
||||||
|$a''$ `a''`|$\widetilde{ac}$ `\widetilde{ac}` |$\overgroup{AB}$ `\overgroup{AB}`
|
|
||||||
|$a^{\prime}$ `a^{\prime}` |$\utilde{AB}$ `\utilde{AB}` |$\undergroup{AB}$ `\undergroup{AB}`
|
|
||||||
|$\acute{a}$ `\acute{a}`|$\vec{F}$ `\vec{F}` |$\Overrightarrow{AB}$ `\Overrightarrow{AB}`
|
|
||||||
|$\bar{y}$ `\bar{y}` |$\overleftarrow{AB}$ `\overleftarrow{AB}`|$\overrightarrow{AB}$ `\overrightarrow{AB}`
|
|
||||||
|$\breve{a}$ `\breve{a}`|$\underleftarrow{AB}$ `\underleftarrow{AB}` |$\underrightarrow{AB}$ `\underrightarrow{AB}`
|
|
||||||
|$\check{a}$ `\check{a}`|$\overleftharpoon{ac}$ `\overleftharpoon{ac}` |$\overrightharpoon{ac}$ `\overrightharpoon{ac}`
|
|
||||||
|$\dot{a}$ `\dot{a}` |$\overleftrightarrow{AB}$ `\overleftrightarrow{AB}` |$\overbrace{AB}$ `\overbrace{AB}`
|
|
||||||
|$\ddot{a}$ `\ddot{a}` |$\underleftrightarrow{AB}$ `\underleftrightarrow{AB}`|$\underbrace{AB}$ `\underbrace{AB}`
|
|
||||||
|$\grave{a}$ `\grave{a}`|$\overline{AB}$ `\overline{AB}` |$\overlinesegment{AB}$ `\overlinesegment{AB}`
|
|
||||||
|$\hat{\theta}$ `\hat{\theta}`|$\underline{AB}$ `\underline{AB}` |$\underlinesegment{AB}$ `\underlinesegment{AB}`
|
|
||||||
|$\widehat{ac}$ `\widehat{ac}`|$\widecheck{ac}$ `\widecheck{ac}` |$\underbar{X}$ `\underbar{X}`
|
|
||||||
|
|
||||||
***Accent functions inside \\text{…}***
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:-----
|
|
||||||
|$\text{\'{a}}$ `\'{a}`|$\text{\~{a}}$ `\~{a}`|$\text{\.{a}}$ `\.{a}`|$\text{\H{a}}$ `\H{a}`
|
|
||||||
|$\text{\`{a}}$ <code>\\`{a}</code>|$\text{\={a}}$ `\={a}`|$\text{\"{a}}$ `\"{a}`|$\text{\v{a}}$ `\v{a}`
|
|
||||||
|$\text{\^{a}}$ `\^{a}`|$\text{\u{a}}$ `\u{a}`|$\text{\r{a}}$ `\r{a}`|
|
|
||||||
|
|
||||||
See also [letters](#letters)
|
|
||||||
|
|
||||||
## Delimiters
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:-----------------------------------|:---------------------------------------|:----------|:-------------------------------------------------------|:-----
|
|
||||||
|$(~)$ `( )` |$\lparen~\rparen$ `\lparen`<br>$~~~~$`\rparen`|$⌈~⌉$ `⌈ ⌉`|$\lceil~\rceil$ `\lceil`<br>$~~~~~$`\rceil` |$\uparrow$ `\uparrow`
|
|
||||||
|$[~]$ `[ ]` |$\lbrack~\rbrack$ `\lbrack`<br>$~~~~$`\rbrack`|$⌊~⌋$ `⌊ ⌋`|$\lfloor~\rfloor$ `\lfloor`<br>$~~~~~$`\rfloor` |$\downarrow$ `\downarrow`
|
|
||||||
|$\{ \}$ `\{ \}`|$\lbrace \rbrace$ `\lbrace`<br>$~~~~$`\rbrace`|$⎰⎱$ `⎰⎱` |$\lmoustache \rmoustache$ `\lmoustache`<br>$~~~~$`\rmoustache`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$⟨~⟩$ `⟨ ⟩` |$\langle~\rangle$ `\langle`<br>$~~~~$`\rangle`|$⟮~⟯$ `⟮ ⟯`|$\lgroup~\rgroup$ `\lgroup`<br>$~~~~~$`\rgroup` |$\Uparrow$ `\Uparrow`
|
|
||||||
|$\vert$ <code>|</code> |$\vert$ `\vert` |$┌ ┐$ `┌ ┐`|$\ulcorner \urcorner$ `\ulcorner`<br>$~~~~$`\urcorner` |$\Downarrow$ `\Downarrow`
|
|
||||||
|$\Vert$ <code>\|</code> |$\Vert$ `\Vert` |$└ ┘$ `└ ┘`|$\llcorner \lrcorner$ `\llcorner`<br>$~~~~$`\lrcorner` |$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\lvert~\rvert$ `\lvert`<br>$~~~~$`\rvert`|$\lVert~\rVert$ `\lVert`<br>$~~~~~$`\rVert` |`\left.`| `\right.` |$\backslash$ `\backslash`
|
|
||||||
|$\lang~\rang$ `\lang`<br>$~~~~$`\rang`|$\lt~\gt$ `\lt \gt`|$⟦~⟧$ `⟦ ⟧`|$\llbracket~\rrbracket$ `\llbracket`<br>$~~~~$`\rrbracket`|$\lBrace~\rBrace$ `\lBrace \rBrace`
|
|
||||||
|
|
||||||
**Delimiter Sizing**
|
|
||||||
|
|
||||||
$\left(\LARGE{AB}\right)$ `\left(\LARGE{AB}\right)`
|
|
||||||
|
|
||||||
$( \big( \Big( \bigg( \Bigg($ `( \big( \Big( \bigg( \Bigg(`
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:--------|:------|:--------|:-------|:------|
|
|
||||||
|`\left` |`\big` |`\bigl` |`\bigm` |`\bigr`
|
|
||||||
|`\middle`|`\Big` |`\Bigl` |`\Bigm` | `\Bigr`
|
|
||||||
|`\right` |`\bigg`|`\biggl` |`\biggm`|`\biggr`
|
|
||||||
| |`\Bigg`|`\Biggl` |`\Biggm`|`\Biggr`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Environments
|
|
||||||
|
|
||||||
<div class="katex-cards" id="environments">
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:--------
|
|
||||||
|$\begin{matrix} a & b \\ c & d \end{matrix}$ | `\begin{matrix}`<br> `a & b \\`<br> `c & d`<br>`\end{matrix}` |$\begin{array}{cc}a & b\\c & d\end{array}$ | `\begin{array}{cc}`<br> `a & b \\`<br> `c & d`<br>`\end{array}`
|
|
||||||
|$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$ |`\begin{pmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{pmatrix}` |$\begin{bmatrix} a & b \\ c & d \end{bmatrix}$ | `\begin{bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{bmatrix}`
|
|
||||||
|$\begin{vmatrix} a & b \\ c & d \end{vmatrix}$ |`\begin{vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{vmatrix}` |$\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}$ |`\begin{Vmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Vmatrix}`
|
|
||||||
|$\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}$ |`\begin{Bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Bmatrix}`|$\def\arraystretch{1.5}\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}$|`\def\arraystretch{1.5}`<br> `\begin{array}{c:c:c}`<br> `a & b & c \\ \hline`<br> `d & e & f \\`<br> `\hdashline`<br> `g & h & i`<br>`\end{array}`
|
|
||||||
|$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$ |`x = \begin{cases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{cases}`|$\begin{rcases} a &\text{if } b \\ c &\text{if } d \end{rcases}⇒…$ |`\begin{rcases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{rcases}⇒…`|
|
|
||||||
|$\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}$ | `\begin{smallmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{smallmatrix}` |$$\sum_{\begin{subarray}{l} i\in\Lambda\\ 0<j<n\end{subarray}}$$ | `\sum_{`<br>`\begin{subarray}{l}`<br> `i\in\Lambda\\`<br> `0<j<n`<br>`\end{subarray}}`|
|
|
||||||
|
|
||||||
The auto-render extension will render the following environments even if they are not inside math delimiters such as `$$…$$`. They are display-mode only.
|
|
||||||
|
|
||||||
<style>
|
|
||||||
#env + table tr td:nth-child(1) { min-width: 11em }
|
|
||||||
#env + table tr td:nth-child(3) { min-width: 13em }
|
|
||||||
</style>
|
|
||||||
<div id="env"></div>
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:---------------------|:---------------------|:---------------------|:--------
|
|
||||||
|$$\begin{equation}\begin{split}a &=b+c\\&=e+f\end{split}\end{equation}$$ |`\begin{equation}`<br>`\begin{split}` `a &=b+c\\`<br> `&=e+f`<br>`\end{split}`<br>`\end{equation}` |$$\begin{align} a&=b+c \\ d+e&=f \end{align}$$ |`\begin{align}`<br> `a&=b+c \\`<br> `d+e&=f`<br>`\end{align}` |
|
|
||||||
|$$\begin{gather} a=b \\ e=b+c \end{gather}$$ |`\begin{gather}`<br> `a=b \\ `<br> `e=b+c`<br>`\end{gather}`|$$\begin{alignat}{2}10&x+&3&y=2\\3&x+&13&y=4\end{alignat}$$ | `\begin{alignat}{2}`<br> `10&x+&3&y=2\\`<br> `3&x+&13&y=4`<br>`\end{alignat}`
|
|
||||||
|$$\begin{CD}A @>a>> B \\@VbVV @AAcA\\C @= D\end{CD}$$ | `\begin{CD}`<br> `A @>a>> B \\`<br>`@VbVV @AAcA \\`<br> `C @= D`<br>`\\end{CD}`
|
|
||||||
|
|
||||||
#### Other KaTeX Environments
|
|
||||||
|
|
||||||
| Environments | How they differ from those shown above |
|
|
||||||
|:-----------------------------------------------|:------------------|
|
|
||||||
| `darray`, `dcases`, `drcases` | … apply `displaystyle` |
|
|
||||||
| `matrix*`, `pmatrix*`, `bmatrix*`<br>`Bmatrix*`, `vmatrix*`, `Vmatrix*` | … take an optional argument to set column<br>alignment, as in `\begin{matrix*}[r]`
|
|
||||||
| `equation*`, `gather*`<br>`align*`, `alignat*` | … have no automatic numbering. |
|
|
||||||
| `gathered`, `aligned`, `alignedat` | … do not need to be in display mode.<br> … have no automatic numbering.<br> … must be inside math delimiters in<br>order to be rendered by the auto-render<br>extension. |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
Acceptable line separators include: `\\`, `\cr`, `\\[distance]`, and `\cr[distance]`. *Distance* can be written with any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
The `{array}` environment supports `|` and `:` vertical separators.
|
|
||||||
|
|
||||||
The `{array}` environment does not yet support `\cline` or `\multicolumn`.
|
|
||||||
|
|
||||||
`\tag` can not yet be applied to individual environment rows.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## HTML
|
|
||||||
|
|
||||||
The following "raw HTML" features are potentially dangerous for untrusted
|
|
||||||
inputs, so they are disabled by default, and attempting to use them produces
|
|
||||||
the command names in red (which you can configure via the `errorColor`
|
|
||||||
[option](options.md)). To fully trust your LaTeX input, you need to pass
|
|
||||||
an option of `trust: true`; you can also enable just some of the commands
|
|
||||||
or for just some URLs via the `trust` [option](options.md).
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------|:-------------------|
|
|
||||||
| $\href{https://katex.org/}{\KaTeX}$ | `\href{https://katex.org/}{\KaTeX}` |
|
|
||||||
| $\url{https://katex.org/}$ | `\url{https://katex.org/}` |
|
|
||||||
| $\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://katex.org/img/khan-academy.png}$ | `\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://katex.org/img/khan-academy.png}` |
|
|
||||||
| $\htmlId{bar}{x}$ <code>…<span id="bar" class="enclosing">…x…</span>…</code> | `\htmlId{bar}{x}` |
|
|
||||||
| $\htmlClass{foo}{x}$ <code>…<span class="enclosing foo">…x…</span>…</code> | `\htmlClass{foo}{x}` |
|
|
||||||
| $\htmlStyle{color: red;}{x}$ <code>…<span style="color: red;" class="enclosing">…x…</span>…</code> | `\htmlStyle{color: red;}{x}` |
|
|
||||||
| $\htmlData{foo=a, bar=b}{x}$ <code>…<span data-foo="a" data-bar="b" class="enclosing">…x…</span>…</code> | `\htmlData{foo=a, bar=b}{x}` |
|
|
||||||
|
|
||||||
`\includegraphics` supports `height`, `width`, `totalheight`, and `alt` in its first argument. `height` is required.
|
|
||||||
|
|
||||||
HTML extension (`\html`-prefixed) commands are non-standard, so loosening `strict` option for `htmlExtension` is required.
|
|
||||||
|
|
||||||
|
|
||||||
## Letters and Unicode
|
|
||||||
|
|
||||||
**Greek Letters**
|
|
||||||
|
|
||||||
Direct Input: $Α Β Γ Δ Ε Ζ Η Θ Ι \allowbreak Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω$
|
|
||||||
$\allowbreak α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π \allowbreak ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ ϝ$
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|---------------|-------------|-------------|---------------|
|
|
||||||
| $\Alpha$ `\Alpha` | $\Beta$ `\Beta` | $\Gamma$ `\Gamma`| $\Delta$ `\Delta`
|
|
||||||
| $\Epsilon$ `\Epsilon` | $\Zeta$ `\Zeta` | $\Eta$ `\Eta` | $\Theta$ `\Theta`
|
|
||||||
| $\Iota$ `\Iota` | $\Kappa$ `\Kappa` | $\Lambda$ `\Lambda` | $\Mu$ `\Mu`
|
|
||||||
| $\Nu$ `\Nu` | $\Xi$ `\Xi` | $\Omicron$ `\Omicron` | $\Pi$ `\Pi`
|
|
||||||
| $\Rho$ `\Rho` | $\Sigma$ `\Sigma` | $\Tau$ `\Tau` | $\Upsilon$ `\Upsilon`
|
|
||||||
| $\Phi$ `\Phi` | $\Chi$ `\Chi` | $\Psi$ `\Psi` | $\Omega$ `\Omega`
|
|
||||||
| $\varGamma$ `\varGamma`| $\varDelta$ `\varDelta` | $\varTheta$ `\varTheta` | $\varLambda$ `\varLambda` |
|
|
||||||
| $\varXi$ `\varXi`| $\varPi$ `\varPi` | $\varSigma$ `\varSigma` | $\varUpsilon$ `\varUpsilon` |
|
|
||||||
| $\varPhi$ `\varPhi` | $\varPsi$ `\varPsi`| $\varOmega$ `\varOmega` ||
|
|
||||||
| $\alpha$ `\alpha`| $\beta$ `\beta` | $\gamma$ `\gamma` | $\delta$ `\delta`|
|
|
||||||
| $\epsilon$ `\epsilon` | $\zeta$ `\zeta` | $\eta$ `\eta`| $\theta$ `\theta`|
|
|
||||||
| $\iota$ `\iota` | $\kappa$ `\kappa` | $\lambda$ `\lambda`| $\mu$ `\mu`|
|
|
||||||
| $\nu$ `\nu`| $\xi$ `\xi` | $\omicron$ `\omicron` | $\pi$ `\pi`|
|
|
||||||
| $\rho$ `\rho` | $\sigma$ `\sigma` | $\tau$ `\tau`| $\upsilon$ `\upsilon` |
|
|
||||||
| $\phi$ `\phi` | $\chi$ `\chi`| $\psi$ `\psi`| $\omega$ `\omega`|
|
|
||||||
| $\varepsilon$ `\varepsilon` | $\varkappa$ `\varkappa` | $\vartheta$ `\vartheta` | $\thetasym$ `\thetasym`
|
|
||||||
| $\varpi$ `\varpi`| $\varrho$ `\varrho` | $\varsigma$ `\varsigma` | $\varphi$ `\varphi`
|
|
||||||
| $\digamma $ `\digamma`
|
|
||||||
|
|
||||||
**Other Letters**
|
|
||||||
|
|
||||||
||||||
|
|
||||||
|:----------|:----------|:----------|:----------|:----------|
|
|
||||||
|$\imath$ `\imath`|$\nabla$ `\nabla`|$\Im$ `\Im`|$\Reals$ `\Reals`|$\text{\OE}$ `\text{\OE}`
|
|
||||||
|$\jmath$ `\jmath`|$\partial$ `\partial`|$\image$ `\image`|$\wp$ `\wp`|$\text{\o}$ `\text{\o}`
|
|
||||||
|$\aleph$ `\aleph`|$\Game$ `\Game`|$\Bbbk$ `\Bbbk`|$\weierp$ `\weierp`|$\text{\O}$ `\text{\O}`
|
|
||||||
|$\alef$ `\alef`|$\Finv$ `\Finv`|$\N$ `\N`|$\Z$ `\Z`|$\text{\ss}$ `\text{\ss}`
|
|
||||||
|$\alefsym$ `\alefsym`|$\cnums$ `\cnums`|$\natnums$ `\natnums`|$\text{\aa}$ `\text{\aa}`|$\text{\i}$ `\text{\i}`
|
|
||||||
|$\beth$ `\beth`|$\Complex$ `\Complex`|$\R$ `\R`|$\text{\AA}$ `\text{\AA}`|$\text{\j}$ `\text{\j}`
|
|
||||||
|$\gimel$ `\gimel`|$\ell$ `\ell`|$\Re$ `\Re`|$\text{\ae}$ `\text{\ae}`
|
|
||||||
|$\daleth$ `\daleth`|$\hbar$ `\hbar`|$\real$ `\real`|$\text{\AE}$ `\text{\AE}`
|
|
||||||
|$\eth$ `\eth`|$\hslash$ `\hslash`|$\reals$ `\reals`|$\text{\oe}$ `\text{\oe}`
|
|
||||||
|
|
||||||
Direct Input: $∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð$
|
|
||||||
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåçèéêëìíîïðñòóôöùúûüýþÿ
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="math-alpha">
|
|
||||||
|
|
||||||
**Unicode Mathematical Alphanumeric Symbols**
|
|
||||||
|
|
||||||
| Item | Range | Item | Range |
|
|
||||||
|-------------|---------------------|-------------------|---------------|
|
|
||||||
| Bold | $\text{𝐀-𝐙 𝐚-𝐳 𝟎-𝟗}$ | Double-struck | $\text{𝔸-}ℤ\ 𝕜$
|
|
||||||
| Italic | $\text{𝐴-𝑍 𝑎-𝑧}$ | Sans serif | $\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}$
|
|
||||||
| Bold Italic | $\text{𝑨-𝒁 𝒂-𝒛}$ | Sans serif bold | $\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}$
|
|
||||||
| Script | $\text{𝒜-𝒵}$ | Sans serif italic | $\text{𝘈-𝘡 𝘢-𝘻}$
|
|
||||||
| Fractur | $\text{𝔄-}ℨ\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
**Unicode**
|
|
||||||
|
|
||||||
The letters listed above will render properly in any KaTeX rendering mode.
|
|
||||||
|
|
||||||
In addition, Armenian, Brahmic, Georgian, Chinese, Japanese, and Korean glyphs are always accepted in text mode. However, these glyphs will be rendered from system fonts (not KaTeX-supplied fonts) so their typography may clash.
|
|
||||||
You can provide rules for CSS classes `.latin_fallback`, `.cyrillic_fallback`, `.brahmic_fallback`, `.georgian_fallback`, `.cjk_fallback`, and `.hangul_fallback` to provide fallback fonts for these languages.
|
|
||||||
Use of these glyphs may cause small vertical alignment issues: KaTeX has detailed metrics for listed symbols and most Latin, Greek, and Cyrillic letters, but other accepted glyphs are treated as if they are each as tall as the letter M in the current KaTeX font.
|
|
||||||
|
|
||||||
If the KaTeX rendering mode is set to `strict: false` or `strict: "warn"` (default), then KaTeX will accept all Unicode letters in both text and math mode.
|
|
||||||
All unrecognized characters will be treated as if they appeared in text mode, and are subject to the same issues of using system fonts and possibly using incorrect vertical alignment.
|
|
||||||
|
|
||||||
For Persian composite characters, a user-supplied [plug-in](https://github.com/HosseinAgha/persian-katex-plugin) is under development.
|
|
||||||
|
|
||||||
Any character can be written with the `\char` function and the Unicode code in hex. For example `\char"263a` will render as $\char"263a$.
|
|
||||||
|
|
||||||
## Layout
|
|
||||||
|
|
||||||
### Annotation
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:------------------------------|:-----
|
|
||||||
|$\cancel{5}$ `\cancel{5}`|$\overbrace{a+b+c}^{\text{note}}$ `\overbrace{a+b+c}^{\text{note}}`
|
|
||||||
|$\bcancel{5}$ `\bcancel{5}` |$\underbrace{a+b+c}_{\text{note}}$ `\underbrace{a+b+c}_{\text{note}}`
|
|
||||||
|$\xcancel{ABC}$ `\xcancel{ABC}`|$\not =$ `\not =`
|
|
||||||
|$\sout{abc}$ `\sout{abc}`|$\boxed{\pi=\frac c d}$ `\boxed{\pi=\frac c d}`
|
|
||||||
|$a_{\angl n}$ `$a_{\angl n}`|$a_\angln$ `a_\angln`
|
|
||||||
|$\phase{-78^\circ}$`\phase{-78^\circ}` |
|
|
||||||
|
|
||||||
`\tag{hi} x+y^{2x}`
|
|
||||||
$$\tag{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
`\tag*{hi} x+y^{2x}`
|
|
||||||
$$\tag*{hi} x+y^{2x}$$
|
|
||||||
|
|
||||||
### Line Breaks
|
|
||||||
|
|
||||||
KaTeX 0.10.0+ will insert automatic line breaks in inline math after relations or binary operators such as “=” or “+”. These can be suppressed by `\nobreak` or by placing math inside a pair of braces, as in `{F=ma}`. `\allowbreak` will allow automatic line breaks at locations other than relations or operators.
|
|
||||||
|
|
||||||
Hard line breaks are `\\` and `\newline`.
|
|
||||||
|
|
||||||
In display math, KaTeX does not insert automatic line breaks. It ignores display math hard line breaks when rendering option `strict: true`.
|
|
||||||
|
|
||||||
### Vertical Layout
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------|:----------------------------------------|:-----
|
|
||||||
|$x_n$ `x_n` |$\stackrel{!}{=}$ `\stackrel{!}{=}`| $a \atop b$ `a \atop b`
|
|
||||||
|$e^x$ `e^x` |$\overset{!}{=}$ `\overset{!}{=}` | $a\raisebox{0.25em}{$b$}c$ `a\raisebox{0.25em}{$b$}c`
|
|
||||||
|$_u^o $ `_u^o `| $\underset{!}{=}$ `\underset{!}{=}` | $a+\left(\vcenter{\frac{\frac a b}c}\right)$ `a+\left(\vcenter{\hbox{$\frac{\frac a b}c$}}\right)`
|
|
||||||
||| $$\sum_{\substack{0<i<m\\0<j<n}}$$ `\sum_{\substack{0<i<m\\0<j<n}}`
|
|
||||||
|
|
||||||
`\raisebox` and `\hbox` put their argument into text mode. To raise math, nest `$…$` delimiters inside the argument as shown above.
|
|
||||||
|
|
||||||
`\vcenter` can be written without an `\hbox` if the `strict` rendering option is *false*. In that case, omit the nested `$…$` delimiters.
|
|
||||||
|
|
||||||
### Overlap and Spacing
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------|:-------|
|
|
||||||
|${=}\mathllap{/\,}$ `{=}\mathllap{/\,}` | $\left(x^{\smash{2}}\right)$ `\left(x^{\smash{2}}\right)`
|
|
||||||
|$\mathrlap{\,/}{=}$ `\mathrlap{\,/}{=}` | $\sqrt{\smash[b]{y}}$ `\sqrt{\smash[b]{y}} `
|
|
||||||
|
|
||||||
$\displaystyle\sum_{\mathclap{1\le i\le j\le n}} x_{ij}$ `\sum_{\mathclap{1\le i\le j\le n}} x_{ij}`
|
|
||||||
|
|
||||||
KaTeX also supports `\llap`, `\rlap`, and `\clap`, but they will take only text, not math, as arguments.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="spacing-tbl">
|
|
||||||
|
|
||||||
**Spacing**
|
|
||||||
|
|
||||||
| Function | Produces | Function | Produces|
|
|
||||||
|:----------------|:-------------------|:---------------------|:--------------------------------------|
|
|
||||||
| `\,` | ³∕₁₈ em space | `\kern{distance}` | space, width = *distance*
|
|
||||||
| `\thinspace` | ³∕₁₈ em space | `\mkern{distance}` | space, width = *distance*
|
|
||||||
| `\>` | ⁴∕₁₈ em space | `\mskip{distance}` | space, width = *distance*
|
|
||||||
| `\:` | ⁴∕₁₈ em space | `\hskip{distance}` | space, width = *distance*
|
|
||||||
| `\medspace` | ⁴∕₁₈ em space | `\hspace{distance}` | space, width = *distance*
|
|
||||||
| `\;` | ⁵∕₁₈ em space | `\hspace*{distance}` | space, width = *distance*
|
|
||||||
| `\thickspace` | ⁵∕₁₈ em space | `\phantom{content}` | space the width and height of content
|
|
||||||
| `\enspace` | ½ em space | `\hphantom{content}` | space the width of content
|
|
||||||
| `\quad` | 1 em space | `\vphantom{content}` | a strut the height of content
|
|
||||||
| `\qquad` | 2 em space | `\!` | – ³∕₁₈ em space
|
|
||||||
| `~` | non-breaking space | `\negthinspace` | – ³∕₁₈ em space
|
|
||||||
| `\<space>` | space | `\negmedspace` | – ⁴∕₁₈ em space
|
|
||||||
| `\nobreakspace` | non-breaking space | `\negthickspace` | – ⁵∕₁₈ em space
|
|
||||||
| `\space` | space | `\mathstrut` | `\vphantom{(}`
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
**Notes:**
|
|
||||||
|
|
||||||
`distance` will accept any of the [KaTeX units](#units).
|
|
||||||
|
|
||||||
`\kern`, `\mkern`, `\mskip`, and `\hspace` accept unbraced distances, as in: `\kern1em`.
|
|
||||||
|
|
||||||
`\mkern` and `\mskip` will not work in text mode and both will write a console warning for any unit except `mu`.
|
|
||||||
|
|
||||||
<div class="katex-hopscotch">
|
|
||||||
|
|
||||||
## Logic and Set Theory
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:--------------------|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\forall$ `\forall` |$\complement$ `\complement`|$\therefore$ `\therefore` |$\emptyset$ `\emptyset`
|
|
||||||
|$\exists$ `\exists` |$\subset$ `\subset` |$\because$ `\because` |$\empty$ `\empty`
|
|
||||||
|$\exist$ `\exist` |$\supset$ `\supset` |$\mapsto$ `\mapsto` |$\varnothing$ `\varnothing`
|
|
||||||
|$\nexists$ `\nexists`|$\mid$ `\mid` |$\to$ `\to` |$\implies$ `\implies`
|
|
||||||
|$\in$ `\in` |$\land$ `\land` |$\gets$ `\gets` |$\impliedby$ `\impliedby`
|
|
||||||
|$\isin$ `\isin` |$\lor$ `\lor` |$\leftrightarrow$ `\leftrightarrow`|$\iff$ `\iff`
|
|
||||||
|$\notin$ `\notin` |$\ni$ `\ni` |$\notni$ `\notni` |$\neg$ `\neg` or `\lnot`
|
|
||||||
|
|
||||||
Direct Input: $∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬$ ℂ ℍ ℕ ℙ ℚ ℝ
|
|
||||||
|
|
||||||
## Macros
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:-------------------------------------|:------
|
|
||||||
|$\def\foo{x^2} \foo + \foo$ | `\def\foo{x^2} \foo + \foo`
|
|
||||||
|$\gdef\bar#1{#1^2} \bar{y} + \bar{y}$ | `\gdef\bar#1{#1^2} \bar{y} + \bar{y}`
|
|
||||||
| | `\edef\macroname#1#2…{definition to be expanded}`
|
|
||||||
| | `\xdef\macroname#1#2…{definition to be expanded}`
|
|
||||||
| | `\let\foo=\bar`
|
|
||||||
| | `\futurelet\foo\bar x`
|
|
||||||
| | `\global\def\macroname#1#2…{definition}`
|
|
||||||
| | `\newcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\renewcommand\macroname[numargs]{definition}`
|
|
||||||
| | `\providecommand\macroname[numargs]{definition}`
|
|
||||||
|
|
||||||
Macros can also be defined in the KaTeX [rendering options](options.md).
|
|
||||||
|
|
||||||
Macros accept up to nine arguments: #1, #2, etc.
|
|
||||||
|
|
||||||
<div id="gdef"></div>
|
|
||||||
|
|
||||||
Macros defined by `\gdef`, `\xdef`, `\global\def`, `\global\edef`, `\global\let`, and `\global\futurelet` will persist between math expressions. (Exception: macro persistence may be disabled. There are legitimate security reasons for that.)
|
|
||||||
|
|
||||||
KaTeX has no `\par`, so all macros are long by default and `\long` will be ignored.
|
|
||||||
|
|
||||||
Available functions include:
|
|
||||||
|
|
||||||
`\char` `\mathchoice` `\TextOrMath` `\@ifstar` `\@ifnextchar` `\@firstoftwo` `\@secondoftwo` `\relax` `\expandafter` `\noexpand`
|
|
||||||
|
|
||||||
@ is a valid character for commands, as if `\makeatletter` were in effect.
|
|
||||||
|
|
||||||
## Operators
|
|
||||||
|
|
||||||
### Big Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|------------------|-------------------------|--------------------------|--------------|
|
|
||||||
| $\sum$ `\sum` | $\prod$ `\prod` | $\bigotimes$ `\bigotimes`| $\bigvee$ `\bigvee`
|
|
||||||
| $\int$ `\int` | $\coprod$ `\coprod` | $\bigoplus$ `\bigoplus` | $\bigwedge$ `\bigwedge`
|
|
||||||
| $\iint$ `\iint` | $\intop$ `\intop` | $\bigodot$ `\bigodot` | $\bigcap$ `\bigcap`
|
|
||||||
| $\iiint$ `\iiint`| $\smallint$ `\smallint` | $\biguplus$ `\biguplus` | $\bigcup$ `\bigcup`
|
|
||||||
| $\oint$ `\oint` | $\oiint$ `\oiint` | $\oiiint$ `\oiiint` | $\bigsqcup$ `\bigsqcup`
|
|
||||||
|
|
||||||
Direct Input: $∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆$ ∯ ∰
|
|
||||||
|
|
||||||
### Binary Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|-------------|-------------------|-------------------|--------------------|
|
|
||||||
| $+$ `+`| $\cdot$ `\cdot` | $\gtrdot$ `\gtrdot`| $x \pmod a$ `x \pmod a`|
|
|
||||||
| $-$ `-`| $\cdotp$ `\cdotp` | $\intercal$ `\intercal` | $x \pod a$ `x \pod a` |
|
|
||||||
| $/$ `/`| $\centerdot$ `\centerdot`| $\land$ `\land` | $\rhd$ `\rhd` |
|
|
||||||
| $*$ `*`| $\circ$ `\circ` | $\leftthreetimes$ `\leftthreetimes` | $\rightthreetimes$ `\rightthreetimes` |
|
|
||||||
| $\amalg$ `\amalg` | $\circledast$ `\circledast` | $\ldotp$ `\ldotp` | $\rtimes$ `\rtimes` |
|
|
||||||
| $\And$ `\And`| $\circledcirc$ `\circledcirc` | $\lor$ `\lor`| $\setminus$ `\setminus` |
|
|
||||||
| $\ast$ `\ast`| $\circleddash$ `\circleddash` | $\lessdot$ `\lessdot` | $\smallsetminus$ `\smallsetminus`|
|
|
||||||
| $\barwedge$ `\barwedge` | $\Cup$ `\Cup`| $\lhd$ `\lhd`| $\sqcap$ `\sqcap` |
|
|
||||||
| $\bigcirc$ `\bigcirc` | $\cup$ `\cup`| $\ltimes$ `\ltimes`| $\sqcup$ `\sqcup` |
|
|
||||||
| $\bmod$ `\bmod` | $\curlyvee$ `\curlyvee` | $x \mod a$ `x\mod a`| $\times$ `\times` |
|
|
||||||
| $\boxdot$ `\boxdot`| $\curlywedge$ `\curlywedge` | $\mp$ `\mp` | $\unlhd$ `\unlhd` |
|
|
||||||
| $\boxminus$ `\boxminus` | $\div$ `\div`| $\odot$ `\odot` | $\unrhd$ `\unrhd` |
|
|
||||||
| $\boxplus$ `\boxplus` | $\divideontimes$ `\divideontimes` | $\ominus$ `\ominus`| $\uplus$ `\uplus` |
|
|
||||||
| $\boxtimes$ `\boxtimes` | $\dotplus$ `\dotplus` | $\oplus$ `\oplus` | $\vee$ `\vee` |
|
|
||||||
| $\bullet$ `\bullet`| $\doublebarwedge$ `\doublebarwedge` | $\otimes$ `\otimes`| $\veebar$ `\veebar` |
|
|
||||||
| $\Cap$ `\Cap`| $\doublecap$ `\doublecap`| $\oslash$ `\oslash`| $\wedge$ `\wedge` |
|
|
||||||
| $\cap$ `\cap`| $\doublecup$ `\doublecup`| $\pm$ `\pm` or `\plusmn` | $\wr$ `\wr` |
|
|
||||||
|
|
||||||
Direct Input: $+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝ ◯$
|
|
||||||
|
|
||||||
### Fractions and Binomials
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:--------------------------|:----------------------------|:-----
|
|
||||||
|$\frac{a}{b}$ `\frac{a}{b}`|$\tfrac{a}{b}$ `\tfrac{a}{b}`|$\genfrac ( ] {2pt}{1}a{a+1}$ `\genfrac ( ] {2pt}{1}a{a+1}`
|
|
||||||
|${a \over b}$ `{a \over b}`|$\dfrac{a}{b}$ `\dfrac{a}{b}`|${a \above{2pt} b+1}$ `{a \above{2pt} b+1}`
|
|
||||||
|$a/b$ `a/b` | |$\cfrac{a}{1 + \cfrac{1}{b}}$ `\cfrac{a}{1 + \cfrac{1}{b}}`
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:--------
|
|
||||||
|$\binom{n}{k}$ `\binom{n}{k}` |$\dbinom{n}{k}$ `\dbinom{n}{k}`|${n\brace k}$ `{n\brace k}`
|
|
||||||
|${n \choose k}$ `{n \choose k}`|$\tbinom{n}{k}$ `\tbinom{n}{k}`|${n\brack k}$ `{n\brack k}`
|
|
||||||
|
|
||||||
### Math Operators
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:--------------------|:--------------------|:----------------|:--------------|
|
|
||||||
| $\arcsin$ `\arcsin` | $\cosec$ `\cosec` | $\deg$ `\deg` | $\sec$ `\sec` |
|
|
||||||
| $\arccos$ `\arccos` | $\cosh$ `\cosh` | $\dim$ `\dim` | $\sin$ `\sin` |
|
|
||||||
| $\arctan$ `\arctan` | $\cot$ `\cot` | $\exp$ `\exp` | $\sinh$ `\sinh` |
|
|
||||||
| $\arctg$ `\arctg` | $\cotg$ `\cotg` | $\hom$ `\hom` | $\sh$ `\sh` |
|
|
||||||
| $\arcctg$ `\arcctg` | $\coth$ `\coth` | $\ker$ `\ker` | $\tan$ `\tan` |
|
|
||||||
| $\arg$ `\arg` | $\csc$ `\csc` | $\lg$ `\lg` | $\tanh$ `\tanh` |
|
|
||||||
| $\ch$ `\ch` | $\ctg$ `\ctg` | $\ln$ `\ln` | $\tg$ `\tg` |
|
|
||||||
| $\cos$ `\cos` | $\cth$ `\cth` | $\log$ `\log` | $\th$ `\th` |
|
|
||||||
| $\operatorname{f}$ `\operatorname{f}` | |||
|
|
||||||
| $\argmax$ `\argmax` | $\injlim$ `\injlim` | $\min$ `\min` | $\varinjlim$ `\varinjlim` |
|
|
||||||
| $\argmin$ `\argmin` | $\lim$ `\lim` | $\plim$ `\plim` | $\varliminf$ `\varliminf` |
|
|
||||||
| $\det$ `\det` | $\liminf$ `\liminf` | $\Pr$ `\Pr` | $\varlimsup$ `\varlimsup` |
|
|
||||||
| $\gcd$ `\gcd` | $\limsup$ `\limsup` | $\projlim$ `\projlim` | $\varprojlim$ `\varprojlim` |
|
|
||||||
| $\inf$ `\inf` | $\max$ `\max` | $\sup$ `\sup` |$\operatorname*{f}$ `\operatorname*{f}`|
|
|
||||||
|
|
||||||
|
|
||||||
Functions in the bottom five rows of this table can take `\limits`.
|
|
||||||
|
|
||||||
### \sqrt
|
|
||||||
|
|
||||||
$\sqrt{x}$ `\sqrt{x}`
|
|
||||||
|
|
||||||
$\sqrt[3]{x}$ `\sqrt[3]{x}`
|
|
||||||
|
|
||||||
## Relations
|
|
||||||
|
|
||||||
$\stackrel{!}{=}$ `\stackrel{!}{=}`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|:--------|:------------------------|:----------------------------|:------------------|
|
|
||||||
| $=$ `=` | $\doteqdot$ `\doteqdot` | $\lessapprox$ `\lessapprox` | $\smile$ `\smile` |
|
|
||||||
| $<$ `<` | $\eqcirc$ `\eqcirc` | $\lesseqgtr$ `\lesseqgtr` | $\sqsubset$ `\sqsubset` |
|
|
||||||
| $>$ `>` | $\eqcolon$ `\eqcolon` or<br> `\minuscolon` | $\lesseqqgtr$ `\lesseqqgtr` | $\sqsubseteq$ `\sqsubseteq` |
|
|
||||||
| $:$ `:` | $\Eqcolon$ `\Eqcolon` or<br> `\minuscoloncolon` | $\lessgtr$ `\lessgtr` | $\sqsupset$ `\sqsupset` |
|
|
||||||
| $\approx$ `\approx` | $\eqqcolon$ `\eqqcolon` or<br> `\equalscolon` | $\lesssim$ `\lesssim` | $\sqsupseteq$ `\sqsupseteq` |
|
|
||||||
| $\approxcolon$ `\approxcolon` | $\Eqqcolon$ `\Eqqcolon` or<br> `\equalscoloncolon` | $\ll$ `\ll` | $\Subset$ `\Subset` |
|
|
||||||
| $\approxcoloncolon$ `\approxcoloncolon` | $\eqsim$ `\eqsim` | $\lll$ `\lll` | $\subset$ `\subset` or `\sub` |
|
|
||||||
| $\approxeq$ `\approxeq` | $\eqslantgtr$ `\eqslantgtr` | $\llless$ `\llless` | $\subseteq$ `\subseteq` or `\sube` |
|
|
||||||
| $\asymp$ `\asymp` | $\eqslantless$ `\eqslantless` | $\lt$ `\lt` | $\subseteqq$ `\subseteqq` |
|
|
||||||
| $\backepsilon$ `\backepsilon` | $\equiv$ `\equiv` | $\mid$ `\mid` | $\succ$ `\succ` |
|
|
||||||
| $\backsim$ `\backsim` | $\fallingdotseq$ `\fallingdotseq` | $\models$ `\models` | $\succapprox$ `\succapprox` |
|
|
||||||
| $\backsimeq$ `\backsimeq` | $\frown$ `\frown` | $\multimap$ `\multimap` | $\succcurlyeq$ `\succcurlyeq` |
|
|
||||||
| $\between$ `\between` | $\ge$ `\ge` | $\origof$ `\origof` | $\succeq$ `\succeq` |
|
|
||||||
| $\bowtie$ `\bowtie` | $\geq$ `\geq` | $\owns$ `\owns` | $\succsim$ `\succsim` |
|
|
||||||
| $\bumpeq$ `\bumpeq` | $\geqq$ `\geqq` | $\parallel$ `\parallel` | $\Supset$ `\Supset` |
|
|
||||||
| $\Bumpeq$ `\Bumpeq` | $\geqslant$ `\geqslant` | $\perp$ `\perp` | $\supset$ `\supset` |
|
|
||||||
| $\circeq$ `\circeq` | $\gg$ `\gg` | $\pitchfork$ `\pitchfork` | $\supseteq$ `\supseteq` or `\supe` |
|
|
||||||
| $\colonapprox$ `\colonapprox` | $\ggg$ `\ggg` | $\prec$ `\prec` | $\supseteqq$ `\supseteqq` |
|
|
||||||
| $\Colonapprox$ `\Colonapprox` or<br> `\coloncolonapprox` | $\gggtr$ `\gggtr` | $\precapprox$ `\precapprox` | $\thickapprox$ `\thickapprox` |
|
|
||||||
| $\coloneq$ `\coloneq` or<br> `\colonminus` | $\gt$ `\gt` | $\preccurlyeq$ `\preccurlyeq` | $\thicksim$ `\thicksim` |
|
|
||||||
| $\Coloneq$ `\Coloneq` or<br> `\coloncolonminus` | $\gtrapprox$ `\gtrapprox` | $\preceq$ `\preceq` | $\trianglelefteq$ `\trianglelefteq` |
|
|
||||||
| $\coloneqq$ `\coloneqq` or<br> `\colonequals` | $\gtreqless$ `\gtreqless` | $\precsim$ `\precsim` | $\triangleq$ `\triangleq` |
|
|
||||||
| $\Coloneqq$ `\Coloneqq` or<br> `\coloncolonequals` | $\gtreqqless$ `\gtreqqless` | $\propto$ `\propto` | $\trianglerighteq$ `\trianglerighteq` |
|
|
||||||
| $\colonsim$ `\colonsim` | $\gtrless$ `\gtrless` | $\risingdotseq$ `\risingdotseq` | $\varpropto$ `\varpropto` |
|
|
||||||
| $\Colonsim$ `\Colonsim` or<br> `\coloncolonsim` | $\gtrsim$ `\gtrsim` | $\shortmid$ `\shortmid` | $\vartriangle$ `\vartriangle` |
|
|
||||||
| $\cong$ `\cong` | $\imageof$ `\imageof` | $\shortparallel$ `\shortparallel` | $\vartriangleleft$ `\vartriangleleft` |
|
|
||||||
| $\curlyeqprec$ `\curlyeqprec` | $\in$ `\in` or `\isin` | $\sim$ `\sim` | $\vartriangleright$ `\vartriangleright` |
|
|
||||||
| $\curlyeqsucc$ `\curlyeqsucc` | $\Join$ `\Join` | $\simcolon$ `\simcolon` | $\vcentcolon$ `\vcentcolon` or<br> `\ratio` |
|
|
||||||
| $\dashv$ `\dashv` | $\le$ `\le` | $\simcoloncolon$ `\simcoloncolon` | $\vdash$ `\vdash` |
|
|
||||||
| $\dblcolon$ `\dblcolon` or<br> `\coloncolon` | $\leq$ `\leq` | $\simeq$ `\simeq` | $\vDash$ `\vDash` |
|
|
||||||
| $\doteq$ `\doteq` | $\leqq$ `\leqq` | $\smallfrown$ `\smallfrown` | $\Vdash$ `\Vdash` |
|
|
||||||
| $\Doteq$ `\Doteq` | $\leqslant$ `\leqslant` | $\smallsmile$ `\smallsmile` | $\Vvdash$ `\Vvdash` |
|
|
||||||
|
|
||||||
Direct Input: $= < > : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⟂ ⊨ ⊶ ⊷$ `≔ ≕ ⩴`
|
|
||||||
|
|
||||||
### Negated Relations
|
|
||||||
|
|
||||||
$\not =$ `\not =`
|
|
||||||
|
|
||||||
|||||
|
|
||||||
|--------------|-------------------|---------------------|------------------|
|
|
||||||
| $\gnapprox$ `\gnapprox` | $\ngeqslant$ `\ngeqslant`| $\nsubseteq$ `\nsubseteq` | $\precneqq$ `\precneqq`|
|
|
||||||
| $\gneq$ `\gneq`| $\ngtr$ `\ngtr` | $\nsubseteqq$ `\nsubseteqq` | $\precnsim$ `\precnsim`|
|
|
||||||
| $\gneqq$ `\gneqq` | $\nleq$ `\nleq` | $\nsucc$ `\nsucc`| $\subsetneq$ `\subsetneq` |
|
|
||||||
| $\gnsim$ `\gnsim` | $\nleqq$ `\nleqq` | $\nsucceq$ `\nsucceq` | $\subsetneqq$ `\subsetneqq` |
|
|
||||||
| $\gvertneqq$ `\gvertneqq` | $\nleqslant$ `\nleqslant`| $\nsupseteq$ `\nsupseteq` | $\succnapprox$ `\succnapprox`|
|
|
||||||
| $\lnapprox$ `\lnapprox` | $\nless$ `\nless` | $\nsupseteqq$ `\nsupseteqq` | $\succneqq$ `\succneqq`|
|
|
||||||
| $\lneq$ `\lneq`| $\nmid$ `\nmid` | $\ntriangleleft$ `\ntriangleleft` | $\succnsim$ `\succnsim`|
|
|
||||||
| $\lneqq$ `\lneqq` | $\notin$ `\notin` | $\ntrianglelefteq$ `\ntrianglelefteq` | $\supsetneq$ `\supsetneq` |
|
|
||||||
| $\lnsim$ `\lnsim` | $\notni$ `\notni` | $\ntriangleright$ `\ntriangleright`| $\supsetneqq$ `\supsetneqq` |
|
|
||||||
| $\lvertneqq$ `\lvertneqq` | $\nparallel$ `\nparallel`| $\ntrianglerighteq$ `\ntrianglerighteq` | $\varsubsetneq$ `\varsubsetneq` |
|
|
||||||
| $\ncong$ `\ncong` | $\nprec$ `\nprec` | $\nvdash$ `\nvdash` | $\varsubsetneqq$ `\varsubsetneqq` |
|
|
||||||
| $\ne$ `\ne` | $\npreceq$ `\npreceq` | $\nvDash$ `\nvDash` | $\varsupsetneq$ `\varsupsetneq` |
|
|
||||||
| $\neq$ `\neq` | $\nshortmid$ `\nshortmid`| $\nVDash$ `\nVDash` | $\varsupsetneqq$ `\varsupsetneqq` |
|
|
||||||
| $\ngeq$ `\ngeq`| $\nshortparallel$ `\nshortparallel` | $\nVdash$ `\nVdash` |
|
|
||||||
| $\ngeqq$ `\ngeqq` | $\nsim$ `\nsim` | $\precnapprox$ `\precnapprox`|
|
|
||||||
|
|
||||||
Direct Input: $∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌$
|
|
||||||
|
|
||||||
### Arrows
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|$\circlearrowleft$ `\circlearrowleft`|$\leftharpoonup$ `\leftharpoonup`|$\rArr$ `\rArr`
|
|
||||||
|$\circlearrowright$ `\circlearrowright`|$\leftleftarrows$ `\leftleftarrows`|$\rarr$ `\rarr`
|
|
||||||
|$\curvearrowleft$ `\curvearrowleft`|$\leftrightarrow$ `\leftrightarrow`|$\restriction$ `\restriction`
|
|
||||||
|$\curvearrowright$ `\curvearrowright`|$\Leftrightarrow$ `\Leftrightarrow`|$\rightarrow$ `\rightarrow`
|
|
||||||
|$\Darr$ `\Darr`|$\leftrightarrows$ `\leftrightarrows`|$\Rightarrow$ `\Rightarrow`
|
|
||||||
|$\dArr$ `\dArr`|$\leftrightharpoons$ `\leftrightharpoons`|$\rightarrowtail$ `\rightarrowtail`
|
|
||||||
|$\darr$ `\darr`|$\leftrightsquigarrow$ `\leftrightsquigarrow`|$\rightharpoondown$ `\rightharpoondown`
|
|
||||||
|$\dashleftarrow$ `\dashleftarrow`|$\Lleftarrow$ `\Lleftarrow`|$\rightharpoonup$ `\rightharpoonup`
|
|
||||||
|$\dashrightarrow$ `\dashrightarrow`|$\longleftarrow$ `\longleftarrow`|$\rightleftarrows$ `\rightleftarrows`
|
|
||||||
|$\downarrow$ `\downarrow`|$\Longleftarrow$ `\Longleftarrow`|$\rightleftharpoons$ `\rightleftharpoons`
|
|
||||||
|$\Downarrow$ `\Downarrow`|$\longleftrightarrow$ `\longleftrightarrow`|$\rightrightarrows$ `\rightrightarrows`
|
|
||||||
|$\downdownarrows$ `\downdownarrows`|$\Longleftrightarrow$ `\Longleftrightarrow`|$\rightsquigarrow$ `\rightsquigarrow`
|
|
||||||
|$\downharpoonleft$ `\downharpoonleft`|$\longmapsto$ `\longmapsto`|$\Rrightarrow$ `\Rrightarrow`
|
|
||||||
|$\downharpoonright$ `\downharpoonright`|$\longrightarrow$ `\longrightarrow`|$\Rsh$ `\Rsh`
|
|
||||||
|$\gets$ `\gets`|$\Longrightarrow$ `\Longrightarrow`|$\searrow$ `\searrow`
|
|
||||||
|$\Harr$ `\Harr`|$\looparrowleft$ `\looparrowleft`|$\swarrow$ `\swarrow`
|
|
||||||
|$\hArr$ `\hArr`|$\looparrowright$ `\looparrowright`|$\to$ `\to`
|
|
||||||
|$\harr$ `\harr`|$\Lrarr$ `\Lrarr`|$\twoheadleftarrow$ `\twoheadleftarrow`
|
|
||||||
|$\hookleftarrow$ `\hookleftarrow`|$\lrArr$ `\lrArr`|$\twoheadrightarrow$ `\twoheadrightarrow`
|
|
||||||
|$\hookrightarrow$ `\hookrightarrow`|$\lrarr$ `\lrarr`|$\Uarr$ `\Uarr`
|
|
||||||
|$\iff$ `\iff`|$\Lsh$ `\Lsh`|$\uArr$ `\uArr`
|
|
||||||
|$\impliedby$ `\impliedby`|$\mapsto$ `\mapsto`|$\uarr$ `\uarr`
|
|
||||||
|$\implies$ `\implies`|$\nearrow$ `\nearrow`|$\uparrow$ `\uparrow`
|
|
||||||
|$\Larr$ `\Larr`|$\nleftarrow$ `\nleftarrow`|$\Uparrow$ `\Uparrow`
|
|
||||||
|$\lArr$ `\lArr`|$\nLeftarrow$ `\nLeftarrow`|$\updownarrow$ `\updownarrow`
|
|
||||||
|$\larr$ `\larr`|$\nleftrightarrow$ `\nleftrightarrow`|$\Updownarrow$ `\Updownarrow`
|
|
||||||
|$\leadsto$ `\leadsto`|$\nLeftrightarrow$ `\nLeftrightarrow`|$\upharpoonleft$ `\upharpoonleft`
|
|
||||||
|$\leftarrow$ `\leftarrow`|$\nrightarrow$ `\nrightarrow`|$\upharpoonright$ `\upharpoonright`
|
|
||||||
|$\Leftarrow$ `\Leftarrow`|$\nRightarrow$ `\nRightarrow`|$\upuparrows$ `\upuparrows`
|
|
||||||
|$\leftarrowtail$ `\leftarrowtail`|$\nwarrow$ `\nwarrow`
|
|
||||||
|$\leftharpoondown$ `\leftharpoondown`|$\Rarr$ `\Rarr`
|
|
||||||
|
|
||||||
Direct Input: $← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼$ ↽
|
|
||||||
|
|
||||||
**Extensible Arrows**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------------------------------------|:-----
|
|
||||||
|$\xleftarrow{abc}$ `\xleftarrow{abc}` |$\xrightarrow[under]{over}$ `\xrightarrow[under]{over}`
|
|
||||||
|$\xLeftarrow{abc}$ `\xLeftarrow{abc}` |$\xRightarrow{abc}$ `\xRightarrow{abc}`
|
|
||||||
|$\xleftrightarrow{abc}$ `\xleftrightarrow{abc}` |$\xLeftrightarrow{abc}$ `\xLeftrightarrow{abc}`
|
|
||||||
|$\xhookleftarrow{abc}$ `\xhookleftarrow{abc}` |$\xhookrightarrow{abc}$ `\xhookrightarrow{abc}`
|
|
||||||
|$\xtwoheadleftarrow{abc}$ `\xtwoheadleftarrow{abc}` |$\xtwoheadrightarrow{abc}$ `\xtwoheadrightarrow{abc}`
|
|
||||||
|$\xleftharpoonup{abc}$ `\xleftharpoonup{abc}` |$\xrightharpoonup{abc}$ `\xrightharpoonup{abc}`
|
|
||||||
|$\xleftharpoondown{abc}$ `\xleftharpoondown{abc}` |$\xrightharpoondown{abc}$ `\xrightharpoondown{abc}`
|
|
||||||
|$\xleftrightharpoons{abc}$ `\xleftrightharpoons{abc}`|$\xrightleftharpoons{abc}$ `\xrightleftharpoons{abc}`
|
|
||||||
|$\xtofrom{abc}$ `\xtofrom{abc}` |$\xmapsto{abc}$ `\xmapsto{abc}`
|
|
||||||
|$\xlongequal{abc}$ `\xlongequal{abc}`
|
|
||||||
|
|
||||||
Extensible arrows all can take an optional argument in the same manner<br>as `\xrightarrow[under]{over}`.
|
|
||||||
|
|
||||||
## Special Notation
|
|
||||||
|
|
||||||
**Bra-ket Notation**
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|$\bra{\phi}$ `\bra{\phi}` |$\ket{\psi}$ `\ket{\psi}` |$\braket{\phi\vert\psi}$ `\braket{\phi\vert\psi}` |
|
|
||||||
|$\Bra{\phi}$ `\Bra{\phi}` |$\Ket{\psi}$ `\Ket{\psi}` ||
|
|
||||||
|
|
||||||
## Style, Color, Size, and Font
|
|
||||||
|
|
||||||
**Class Assignment**
|
|
||||||
|
|
||||||
`\mathbin` `\mathclose` `\mathinner` `\mathop`<br>
|
|
||||||
`\mathopen` `\mathord` `\mathpunct` `\mathrel`
|
|
||||||
|
|
||||||
**Color**
|
|
||||||
|
|
||||||
$\color{blue} F=ma$ `\color{blue} F=ma`
|
|
||||||
|
|
||||||
Note that `\color` acts like a switch. Other color functions expect the content to be a function argument:
|
|
||||||
|
|
||||||
$\textcolor{blue}{F=ma}$ `\textcolor{blue}{F=ma}`<br>
|
|
||||||
$\textcolor{#228B22}{F=ma}$ `\textcolor{#228B22}{F=ma}`<br>
|
|
||||||
$\colorbox{aqua}{$F=ma$}$ `\colorbox{aqua}{$F=ma$}`<br>
|
|
||||||
$\fcolorbox{red}{aqua}{$F=ma$}$ `\fcolorbox{red}{aqua}{$F=ma$}`
|
|
||||||
|
|
||||||
Note that, as in LaTeX, `\colorbox` & `\fcolorbox` renders its third argument as text, so you may want to switch back to math mode with `$` as in the examples above.
|
|
||||||
|
|
||||||
For color definition, KaTeX color functions will accept the standard HTML [predefined color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords). They will also accept an RGB argument in CSS hexadecimal style. The "#" is optional before a six-digit specification.
|
|
||||||
|
|
||||||
**Font**
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:------------------------------|:------------------------------|:-----
|
|
||||||
|$\mathrm{Ab0}$ `\mathrm{Ab0}` |$\mathbf{Ab0}$ `\mathbf{Ab0}` |$\mathit{Ab0}$ `\mathit{Ab0}`
|
|
||||||
|$\mathnormal{Ab0}$ `\mathnormal{Ab0}`|$\textbf{Ab0}$ `\textbf{Ab0}` |$\textit{Ab0}$ `\textit{Ab0}`
|
|
||||||
|$\textrm{Ab0}$ `\textrm{Ab0}` |$\bf Ab0$ `\bf Ab0` |$\it Ab0$ `\it Ab0`
|
|
||||||
|$\rm Ab0$ `\rm Ab0` |$\bold{Ab0}$ `\bold{Ab0}` |$\textup{Ab0}$ `\textup{Ab0}`
|
|
||||||
|$\textnormal{Ab0}$ `\textnormal{Ab0}`|$\boldsymbol{Ab0}$ `\boldsymbol{Ab}`|$\Bbb{AB}$ `\Bbb{AB}`
|
|
||||||
|$\text{Ab0}$ `\text{Ab0}` |$\bm{Ab0}$ `\bm{Ab0}` |$\mathbb{AB}$ `\mathbb{AB}`
|
|
||||||
|$\mathsf{Ab0}$ `\mathsf{Ab0}` |$\textmd{Ab0}$ `\textmd{Ab0}` |$\frak{Ab0}$ `\frak{Ab0}`
|
|
||||||
|$\textsf{Ab0}$ `\textsf{Ab0}` |$\mathtt{Ab0}$ `\mathtt{Ab0}` |$\mathfrak{Ab0}$ `\mathfrak{Ab0}`
|
|
||||||
|$\sf Ab0$ `\sf Ab0` |$\texttt{Ab0}$ `\texttt{Ab0}` |$\mathcal{AB0}$ `\mathcal{AB0}`
|
|
||||||
| |$\tt Ab0$ `\tt Ab0` |$\cal AB0$ `\cal AB0`
|
|
||||||
| | |$\mathscr{AB}$ `\mathscr{AB}`
|
|
||||||
|
|
||||||
One can stack font family, font weight, and font shape by using the `\textXX` versions of the font functions. So `\textsf{\textbf{H}}` will produce $\textsf{\textbf{H}}$. The other versions do not stack, e.g., `\mathsf{\mathbf{H}}` will produce $\mathsf{\mathbf{H}}$.
|
|
||||||
|
|
||||||
In cases where KaTeX fonts do not have a bold glyph, `\pmb` can simulate one. For example, `\pmb{\mu}` renders as : $\pmb{\mu}$
|
|
||||||
|
|
||||||
**Size**
|
|
||||||
|
|
||||||
|||
|
|
||||||
|:----------------------|:-----
|
|
||||||
|$\Huge AB$ `\Huge AB` |$\normalsize AB$ `\normalsize AB`
|
|
||||||
|$\huge AB$ `\huge AB` |$\small AB$ `\small AB`
|
|
||||||
|$\LARGE AB$ `\LARGE AB`|$\footnotesize AB$ `\footnotesize AB`
|
|
||||||
|$\Large AB$ `\Large AB`|$\scriptsize AB$ `\scriptsize AB`
|
|
||||||
|$\large AB$ `\large AB`|$\tiny AB$ `\tiny AB`
|
|
||||||
|
|
||||||
|
|
||||||
**Style**
|
|
||||||
|
|
||||||
||
|
|
||||||
|:-------------------------------------------------------|
|
|
||||||
|$\displaystyle\sum_{i=1}^n$ `\displaystyle\sum_{i=1}^n`
|
|
||||||
|$\textstyle\sum_{i=1}^n$ `\textstyle\sum_{i=1}^n`
|
|
||||||
|$\scriptstyle x$ `\scriptstyle x` (The size of a first sub/superscript)
|
|
||||||
|$\scriptscriptstyle x$ `\scriptscriptstyle x` (The size of subsequent sub/superscripts)
|
|
||||||
|$\lim\limits_x$ `\lim\limits_x`
|
|
||||||
|$\lim\nolimits_x$ `\lim\nolimits_x`
|
|
||||||
|$\verb!x^2!$ `\verb!x^2!`
|
|
||||||
|
|
||||||
`\text{…}` will accept nested `$…$` fragments and render them in math mode.
|
|
||||||
|
|
||||||
## Symbols and Punctuation
|
|
||||||
|
|
||||||
||||
|
|
||||||
|:----------|:----------|:----------|
|
|
||||||
|`% comment`|$\dots$ `\dots`|$\KaTeX$ `\KaTeX`
|
|
||||||
|$\%$ `\%`|$\cdots$ `\cdots`|$\LaTeX$ `\LaTeX`
|
|
||||||
|$\#$ `\#`|$\ddots$ `\ddots`|$\TeX$ `\TeX`
|
|
||||||
|$\&$ `\&`|$\ldots$ `\ldots`|$\nabla$ `\nabla`
|
|
||||||
|$\_$ `\_`|$\vdots$ `\vdots`|$\infty$ `\infty`
|
|
||||||
|$\text{\textunderscore}$ `\text{\textunderscore}`|$\dotsb$ `\dotsb`|$\infin$ `\infin`
|
|
||||||
|$\text{--}$ `\text{--}`|$\dotsc$ `\dotsc`|$\checkmark$ `\checkmark`
|
|
||||||
|$\text{\textendash}$ `\text{\textendash}`|$\dotsi$ `\dotsi`|$\dag$ `\dag`
|
|
||||||
|$\text{---}$ `\text{---}`|$\dotsm$ `\dotsm`|$\dagger$ `\dagger`
|
|
||||||
|$\text{\textemdash}$ `\text{\textemdash}`|$\dotso$ `\dotso`|$\text{\textdagger}$ `\text{\textdagger}`
|
|
||||||
|$\text{\textasciitilde}$ `\text{\textasciitilde}`|$\sdot$ `\sdot`|$\ddag$ `\ddag`
|
|
||||||
|$\text{\textasciicircum}$ `\text{\textasciicircum}`|$\mathellipsis$ `\mathellipsis`|$\ddagger$ `\ddagger`
|
|
||||||
|$`$ <code>`</code>|$\text{\textellipsis}$ `\text{\textellipsis}`|$\text{\textdaggerdbl}$ `\text{\textdaggerdbl}`
|
|
||||||
|$\text{\textquoteleft}$ `text{\textquoteleft}`|$\Box$ `\Box`|$\Dagger$ `\Dagger`
|
|
||||||
|$\lq$ `\lq`|$\square$ `\square`|$\angle$ `\angle`
|
|
||||||
|$\text{\textquoteright}$ `\text{\textquoteright}`|$\blacksquare$ `\blacksquare`|$\measuredangle$ `\measuredangle`
|
|
||||||
|$\rq$ `\rq`|$\triangle$ `\triangle`|$\sphericalangle$ `\sphericalangle`
|
|
||||||
|$\text{\textquotedblleft}$ `\text{\textquotedblleft}`|$\triangledown$ `\triangledown`|$\top$ `\top`
|
|
||||||
|$"$ `"`|$\triangleleft$ `\triangleleft`|$\bot$ `\bot`
|
|
||||||
|$\text{\textquotedblright}$ `\text{\textquotedblright}`|$\triangleright$ `\triangleright`|$\$$ `\$`
|
|
||||||
|$\colon$ `\colon`|$\bigtriangledown$ `\bigtriangledown`|$\text{\textdollar}$ `\text{\textdollar}`
|
|
||||||
|$\backprime$ `\backprime`|$\bigtriangleup$ `\bigtriangleup`|$\pounds$ `\pounds`
|
|
||||||
|$\prime$ `\prime`|$\blacktriangle$ `\blacktriangle`|$\mathsterling$ `\mathsterling`
|
|
||||||
|$\text{\textless}$ `\text{\textless}`|$\blacktriangledown$ `\blacktriangledown`|$\text{\textsterling}$ `\text{\textsterling}`
|
|
||||||
|$\text{\textgreater}$ `\text{\textgreater}`|$\blacktriangleleft$ `\blacktriangleleft`|$\yen$ `\yen`
|
|
||||||
|$\text{\textbar}$ `\text{\textbar}`|$\blacktriangleright$ `\blacktriangleright`|$\surd$ `\surd`
|
|
||||||
|$\text{\textbardbl}$ `\text{\textbardbl}`|$\diamond$ `\diamond`|$\degree$ `\degree`
|
|
||||||
|$\text{\textbraceleft}$ `\text{\textbraceleft}`|$\Diamond$ `\Diamond`|$\text{\textdegree}$ `\text{\textdegree}`
|
|
||||||
|$\text{\textbraceright}$ `\text{\textbraceright}`|$\lozenge$ `\lozenge`|$\mho$ `\mho`
|
|
||||||
|$\text{\textbackslash}$ `\text{\textbackslash}`|$\blacklozenge$ `\blacklozenge`|$\diagdown$ `\diagdown`
|
|
||||||
|$\text{\P}$ `\text{\P}`|$\star$ `\star`|$\diagup$ `\diagup`
|
|
||||||
|$\text{\S}$ `\text{\S}`|$\bigstar$ `\bigstar`|$\flat$ `\flat`
|
|
||||||
|$\text{\sect}$ `\text{\sect}`|$\clubsuit$ `\clubsuit`|$\natural$ `\natural`
|
|
||||||
|$\copyright$ `\copyright`|$\clubs$ `\clubs`|$\sharp$ `\sharp`
|
|
||||||
|$\circledR$ `\circledR`|$\diamondsuit$ `\diamondsuit`|$\heartsuit$ `\heartsuit`
|
|
||||||
|$\text{\textregistered}$ `\text{\textregistered}`|$\diamonds$ `\diamonds`|$\hearts$ `\hearts`
|
|
||||||
|$\circledS$ `\circledS`|$\spadesuit$ `\spadesuit`|$\spades$ `\spades`
|
|
||||||
|$\text{\textcircled a}$ `\text{\textcircled a}`|$\maltese$ `\maltese`|$\minuso$ `\minuso`|
|
|
||||||
|
|
||||||
Direct Input: $£ ¥ ∇ ∞ · ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ … ⋮ ⋯ ⋱ !$ ‼ ⦵
|
|
||||||
|
|
||||||
## Units
|
|
||||||
|
|
||||||
In KaTeX, units are proportioned as they are in TeX.<br>
|
|
||||||
KaTeX units are different than CSS units.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="katex-cards" id="unit-tbl">
|
|
||||||
|
|
||||||
| KaTeX Unit | Value | KaTeX Unit | Value |
|
|
||||||
|:---|:---------------------|:---|:----------------|
|
|
||||||
| em | CSS em | bp | 1/72 inch × F × G|
|
|
||||||
| ex | CSS ex | pc | 12 KaTeX pt|
|
|
||||||
| mu | 1/18 CSS em | dd | 1238/1157 KaTeX pt |
|
|
||||||
| pt | 1/72.27 inch × F × G | cc | 14856/1157 KaTeX pt |
|
|
||||||
| mm | 1 mm × F × G | nd | 685/642 KaTeX pt |
|
|
||||||
| cm | 1 cm × F × G | nc | 1370/107 KaTeX pt|
|
|
||||||
| in | 1 inch × F × G | sp | 1/65536 KaTeX pt |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
where:
|
|
||||||
|
|
||||||
<div style="margin-left: 1.5em;">
|
|
||||||
|
|
||||||
F = (font size of surrounding HTML text)/(10 pt)
|
|
||||||
|
|
||||||
G = 1.21 by default, because KaTeX font-size is normally 1.21 × the surrounding font size. This value [can be overridden](font.md#font-size-and-lengths) by the CSS of an HTML page.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
The effect of style and size:
|
|
||||||
|
|
||||||
<div class="katex-cards" id="unit-blocks">
|
|
||||||
|
|
||||||
| Unit | textstyle | scriptscript | huge |
|
|
||||||
|:------:|:-----------------:|:------------:|:------:|
|
|
||||||
|em or ex|$\rule{1em}{1em}$ |$\scriptscriptstyle\rule{1em}{1em}$ |$\huge\rule{1em}{1em}$
|
|
||||||
| mu |$\rule{18mu}{18mu}$|$\scriptscriptstyle\rule{18mu}{18mu}$|$\huge\rule{18mu}{18mu}$
|
|
||||||
| others |$\rule{10pt}{10pt}$|$\scriptscriptstyle\rule{10pt}{10pt}$|$\huge\rule{10pt}{10pt}$
|
|
||||||
|
|
||||||
</div>
|
|
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"version-0.10.0-docs": {
|
|
||||||
"Installation": [
|
|
||||||
"version-0.10.0-node",
|
|
||||||
"version-0.10.0-browser"
|
|
||||||
],
|
|
||||||
"Usage": [
|
|
||||||
"version-0.10.0-api",
|
|
||||||
"version-0.10.0-cli",
|
|
||||||
"version-0.10.0-autorender",
|
|
||||||
"version-0.10.0-libs"
|
|
||||||
],
|
|
||||||
"Configuring KaTeX": [
|
|
||||||
"version-0.10.0-options",
|
|
||||||
"version-0.10.0-security",
|
|
||||||
"version-0.10.0-error",
|
|
||||||
"version-0.10.0-font"
|
|
||||||
],
|
|
||||||
"Misc": [
|
|
||||||
"version-0.10.0-supported",
|
|
||||||
"version-0.10.0-support_table",
|
|
||||||
"version-0.10.0-issues"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"version-0.13.0-docs": {
|
|
||||||
"Installation": [
|
|
||||||
"version-0.13.0-node",
|
|
||||||
"version-0.13.0-browser"
|
|
||||||
],
|
|
||||||
"Usage": [
|
|
||||||
"version-0.13.0-api",
|
|
||||||
"version-0.13.0-cli",
|
|
||||||
"version-0.13.0-autorender",
|
|
||||||
"version-0.13.0-libs"
|
|
||||||
],
|
|
||||||
"Configuring KaTeX": [
|
|
||||||
"version-0.13.0-options",
|
|
||||||
"version-0.13.0-security",
|
|
||||||
"version-0.13.0-error",
|
|
||||||
"version-0.13.0-font"
|
|
||||||
],
|
|
||||||
"Misc": [
|
|
||||||
"version-0.13.0-supported",
|
|
||||||
"version-0.13.0-support_table",
|
|
||||||
"version-0.13.0-issues",
|
|
||||||
"version-0.13.0-migration"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,9 +0,0 @@
|
|||||||
[
|
|
||||||
"0.13.0",
|
|
||||||
"0.12.0",
|
|
||||||
"0.11.1",
|
|
||||||
"0.11.0",
|
|
||||||
"0.10.2",
|
|
||||||
"0.10.1",
|
|
||||||
"0.10.0"
|
|
||||||
]
|
|
1176
website/yarn.lock
1176
website/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user