crossnote
    Preparing search index...

    Interface KatexOptions

    Options for katex.render and katex.renderToString.

    interface KatexOptions {
        colorIsTextColor?: boolean;
        displayMode?: boolean;
        errorColor?: string;
        fleqn?: boolean;
        globalGroup?: boolean;
        leqno?: boolean;
        macros?: Record<
            string,
            string
            | object
            | ((macroExpander: object) => string | object),
        >;
        maxExpand?: number;
        maxSize?: number;
        minRuleThickness?: number;
        output?: "html" | "mathml" | "htmlAndMathml";
        strict?: boolean | "error" | "ignore" | "warn" | StrictFunction;
        throwOnError?: boolean;
        trust?: boolean | ((context: TrustContext) => boolean);
    }
    Index

    Properties

    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.

    displayMode?: boolean

    If true the math will be rendered in display mode. If false the math will be rendered in inline mode.

    false
    
    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.

    "#cc0000"
    
    fleqn?: boolean

    If true, display math renders flush left with a 2em left margin, like \documentclass[fleqn] in LaTeX with the amsmath package.

    false
    
    globalGroup?: boolean

    Run KaTeX code in the global group. As a consequence, macros defined at the top level by \def and \newcommand are added to the macros argument and can be used in subsequent render calls. In LaTeX, constructs such as \begin{equation} and $$ create a local group and prevent definitions other than \gdef from becoming visible outside of those blocks, so this is KaTeX's default behavior.

    false
    
    leqno?: boolean

    If true, display math has \tags rendered on the left instead of the right, like \usepackage[leqno]{amsmath} in LaTeX.

    false
    
    macros?: Record<
        string,
        string
        | object
        | ((macroExpander: object) => string | object),
    >

    A collection of custom macros.

    maxExpand?: number

    Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. \edef expansion counts all expanded tokens. If set to Infinity, the macro expander will try to fully expand as in LaTeX.

    1000
    
    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.

    Infinity
    
    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.

    output?: "html" | "mathml" | "htmlAndMathml"

    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.
    "htmlAndMathml"
    
    strict?: boolean | "error" | "ignore" | "warn" | StrictFunction

    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.

    "warn"
    
    throwOnError?: boolean

    If true, 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.

    true
    
    trust?: boolean | ((context: TrustContext) => boolean)

    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.).

    false