LaTex (1) Common Grammar

1. About LeTex

LaTeX, a typesetting system based on TeX, was developed by American computer scientist Leslie Lambert in the early 1980s. With the processing of this format system, even users without knowledge of typesetting and programming can To give full play to the powerful functions provided by TeX, you don't have to design or proofread one by one, and you can generate a lot of book-quality prints in a few days or even a few hours.

  • Wikipedia

2. Use

In the site, insert:

html
1
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>

Plugs into the MathJax library.

If InstantClick/PJAX is used, insert in the callback function:

JavaScript
1
2
3
4
5
6
7
8
if (typeof(MathJax) !== 'undefined') {
     MathJax.Hub.Config({
         'HTML-CSS': {matchFontHeight: false},
         SVG: {matchFontHeight: false},
         CommonHTML: {matchFontHeight: false}
     });
     MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}

Config can be changed to your own configuration, or removed.

3, basic grammar

MathJax uses LaTeX math delimiters, use \(...\) to display inline formulas, and \[...\] to display interline formulas.

It also recognizes the TeX delimiters $$...$$ to display interline formulas. Defining $…$ as an inline math delimiter is not supported due to the frequent occurrence of the dollar sign ($) in non-mathematical contexts, which may cause some text to be treated unexpectedly as math.

Therefore need to set:

JavaScript
1
2
3
4
5
6
7
8
9
MathJax = {
     tex: {
         inlineMath: [['$', '$'], ['\\(', '\\)']],
         packages: ['base', 'newcommand', 'configMacros']
     },
     svg: {
         fontCache: 'global'
     }
};

E.g:

TypeFormulaEffect
InlineCircle area formula: \\(S=\pi r^2\\)\(S=\pi r^2\)
Between linesArea formula of a circle: $$S=\pi r^2$$$$S=\pi r^2$$

Indicates priority:

Use {...}

E.g:

TypeFormulaEffect
None$$x_i^2$$\(x_i^2\)
priority$$x_{i^2}$$$$x_{i^2}$$
Author
Hsukqi Lee
Posted on

2022-12-13

Edited on

2022-12-13

Licensed under

CC BY-NC-ND 4.0

Comments

Name
Mail
Site
None yet